Skip to content

Commit

Permalink
handle memberupdate event
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-kripakov-m10 committed Dec 18, 2023
1 parent 028e61d commit 1e7cc4e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions dkron/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 14 additions & 1 deletion dkron/serf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 1e7cc4e

Please sign in to comment.