From 4430c41ac886df1bd035bae92db8f4bb6ba5170e Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Sat, 17 Aug 2013 19:49:04 +0000 Subject: [PATCH] ignore tasks that are already final --- services/tasks/state_machine.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/tasks/state_machine.go b/services/tasks/state_machine.go index 783743d..05ea862 100644 --- a/services/tasks/state_machine.go +++ b/services/tasks/state_machine.go @@ -37,6 +37,12 @@ func (sm *StateMachine) abortJob(j *task_api.Job, msg string, args ...interface{ } func (sm *StateMachine) handleJob(j *task_api.Job) { + // Don't fully trust the queue system... + if j.Final { + log.Printf("job %s is already final", j.Id) + return + } + // Find and validate plan and action. If the data is not // consistent somehow, abort the job with an error. plan, ok := sm.Plans[j.PlanName] @@ -82,6 +88,7 @@ func (sm *StateMachine) handleJob(j *task_api.Job) { } // Add a log entry summarizing the transaction. + log.Printf("%s: %s -> %s (%q %q)", j.Id, j.State, nextState, j.Error, j.Final) j.Log(fmt.Sprintf("%s -> %s", j.State, nextState)) // Set the new job state. -- GitLab