From 8ab9f88a192b94cf0ed7a500750fb1ca498e1f15 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Wed, 14 May 2014 18:09:53 -0700 Subject: [PATCH] fix(agent): Clear UnitState before unscheduling on shutdown On graceful shutdown, an Agent must clear each individual Job's UnitState before unscheduling it. If an Agent takes these two actions in the opposite order, it runs the risk of deleting legitimate state from the Registry that was published by a different Agent. --- agent/agent.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 8248dcf13..af283be54 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -168,10 +168,10 @@ func (a *Agent) Purge() { machID := a.machine.State().ID for _, jobName := range a.state.ScheduledJobs() { - log.Infof("Unscheduling Job(%s) from local machine", jobName) - a.registry.ClearJobTarget(jobName, machID) log.Infof("Unloading Job(%s) from local machine", jobName) a.UnloadJob(jobName) + log.Infof("Unscheduling Job(%s) from local machine", jobName) + a.registry.ClearJobTarget(jobName, machID) } // Jobs have been stopped, the heartbeat can stop