diff --git a/dkron/agent.go b/dkron/agent.go index 4a05b2aea..2ce71fa7c 100644 --- a/dkron/agent.go +++ b/dkron/agent.go @@ -143,8 +143,9 @@ type AgentOption func(agent *Agent) // and running a Dkron instance. func NewAgent(config *Config, options ...AgentOption) *Agent { agent := &Agent{ - config: config, - retryJoinCh: make(chan error), + config: config, + retryJoinCh: make(chan error), + serverLookup: NewServerLookup(), } for _, option := range options { @@ -553,7 +554,6 @@ func (a *Agent) SetConfig(c *Config) { // StartServer launch a new dkron server process func (a *Agent) StartServer() { - a.serverLookup = NewServerLookup() if a.Store == nil { s, err := NewStore(a.logger) if err != nil { @@ -725,7 +725,7 @@ func (a *Agent) eventLoop() { case serf.EventMemberReap: a.localMemberEvent(me) case serf.EventMemberUpdate: - a.logger.WithField("event", e.String()).Info("agent: event member update") + a.localMemberEvent(me) case serf.EventUser, serf.EventQuery: // Ignore default: a.logger.WithField("event", e.String()).Warn("agent: Unhandled serf event") diff --git a/dkron/server_lookup.go b/dkron/server_lookup.go index 1ac7c31e5..2343cc433 100644 --- a/dkron/server_lookup.go +++ b/dkron/server_lookup.go @@ -16,6 +16,7 @@ type ServerLookup struct { func NewServerLookup() *ServerLookup { return &ServerLookup{ + lock: sync.RWMutex{}, addressToServer: make(map[raft.ServerAddress]*ServerParts), idToServer: make(map[raft.ServerID]*ServerParts), }