From 1e7cc4ed3f28c5a51470dbb5decd8b1c606f883b Mon Sep 17 00:00:00 2001 From: Ivan Kripakov Date: Mon, 18 Dec 2023 16:50:45 +0400 Subject: [PATCH] handle memberupdate event --- dkron/agent.go | 1 + dkron/serf.go | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/dkron/agent.go b/dkron/agent.go index 2ce71fa7c..d14de14fc 100644 --- a/dkron/agent.go +++ b/dkron/agent.go @@ -725,6 +725,7 @@ func (a *Agent) eventLoop() { case serf.EventMemberReap: a.localMemberEvent(me) case serf.EventMemberUpdate: + a.lanNodeUpdate(me) a.localMemberEvent(me) case serf.EventUser, serf.EventQuery: // Ignore default: diff --git a/dkron/serf.go b/dkron/serf.go index 2e18f174c..980139dc8 100644 --- a/dkron/serf.go +++ b/dkron/serf.go @@ -21,7 +21,7 @@ func (a *Agent) nodeJoin(me serf.MemberEvent) { a.logger.WithField("member", m.Name).Warn("non-server in gossip pool") continue } - a.logger.WithField("server", parts.Name).Info("adding server") + a.logger.WithField("server", parts.Name).Info("Adding LAN adding server") a.serverLookup.AddServer(parts) // Check if this server is known found := false @@ -201,3 +201,16 @@ func (a *Agent) localMemberEvent(me serf.MemberEvent) { } } } + +func (a *Agent) lanNodeUpdate(me serf.MemberEvent) { + for _, m := range me.Members { + ok, parts := isServer(m) + if !ok { + continue + } + a.logger.Info("Updating LAN server", "server", parts.String()) + + // Update server lookup + a.serverLookup.AddServer(parts) + } +}