Skip to content

Commit

Permalink
Wipe configchecksums also on assignment changes
Browse files Browse the repository at this point in the history
If an assignemnt is changed to switch a backend from
one configuration to another, we would still send configuration requests
using the old checksum.
The server will respond with `NotModified` and we don't try to restart
the backend.

Instead of also resetting the checksum when we update the assignment
store, simply wipe the entire checksum map if either the assignment
or the backends have changed.

Fixes #352
  • Loading branch information
mpfz0r committed Mar 7, 2019
1 parent 0f71051 commit d68d605
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (dc *DaemonConfig) GetRunnerByBackendId(id string) Runner {
return nil
}

func (dc *DaemonConfig) SyncWithAssignments(configChecksums map[string]string, context *context.Ctx) {
func (dc *DaemonConfig) SyncWithAssignments(context *context.Ctx) {
if dc.Runner == nil {
return
}
Expand All @@ -125,7 +125,6 @@ func (dc *DaemonConfig) SyncWithAssignments(configChecksums map[string]string, c
log.Infof("[%s] Updating process configuration", runner.Name())
runnerServiceType := runnerBackend.ServiceType
runner.SetBackend(*backend)
configChecksums[backend.Id] = ""
if backend.ServiceType != runnerServiceType {
log.Infof("Changing process runner (%s -> %s) for: %s",
runnerServiceType, backend.ServiceType, backend.Name)
Expand All @@ -146,7 +145,6 @@ func (dc *DaemonConfig) SyncWithAssignments(configChecksums map[string]string, c
if backend == nil || assignments.Store.GetAll()[backend.Id] == "" {
log.Info("Removing process runner: " + backend.Name)
dc.DeleteRunner(id)
configChecksums[backend.Id] = ""
}
}
assignedBackends := []*backends.Backend{}
Expand Down
3 changes: 2 additions & 1 deletion services/periodicals.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ func StartPeriodicals(context *context.Ctx) {

if !response.NotModified || !backendResponse.NotModified {
assignments.Store.Update(response.Assignments)
configChecksums = make(map[string]string)
// create process instances
daemon.Daemon.SyncWithAssignments(configChecksums, context)
daemon.Daemon.SyncWithAssignments(context)
// test for new or updated configurations and start the corresponding collector
if assignments.Store.Len() == 0 {
if logOnce {
Expand Down

0 comments on commit d68d605

Please sign in to comment.