From 5249d182e9976f31231ce6cd935641ac1ac669f5 Mon Sep 17 00:00:00 2001 From: Victor Castell Date: Wed, 23 May 2018 22:39:27 +0200 Subject: [PATCH] Fix concurrency check The runnable check was missing the status. --- dkron/agent.go | 8 ++++++-- dkron/job.go | 24 +++++++++--------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/dkron/agent.go b/dkron/agent.go index 0b6e7b618..1eef0a813 100644 --- a/dkron/agent.go +++ b/dkron/agent.go @@ -445,17 +445,21 @@ func (a *Agent) eventLoop() { } if query.Name == QueryExecutionDone { + group := string(query.Payload) + log.WithFields(logrus.Fields{ "query": query.Name, - "payload": string(query.Payload), + "payload": group, "at": query.LTime, }).Debug("agent: Execution done requested") // Find if the indicated execution is done processing var err error - if _, ok := runningExecutions.Load(string(query.Payload)); ok { + if _, ok := runningExecutions.Load(group); ok { + log.WithField("group", group).Debug("agent: Execution is still running") err = query.Respond([]byte("false")) } else { + log.WithField("group", group).Debug("agent: Execution is not running") err = query.Respond([]byte("true")) } if err != nil { diff --git a/dkron/job.go b/dkron/job.go index a212e3b75..a71b47787 100644 --- a/dkron/job.go +++ b/dkron/job.go @@ -251,21 +251,15 @@ func (j *Job) isRunnable() bool { if j.Concurrency == ConcurrencyForbid { j.Agent.RefreshJobStatus(j.Name) } - if j.Status == StatusNotSet { - j.Status = j.GetStatus() - } - - if j.Status == StatusRunning { - if j.Concurrency == ConcurrencyAllow { - return true - } else if j.Concurrency == ConcurrencyForbid { - log.WithFields(logrus.Fields{ - "job": j.Name, - "concurrency": j.Concurrency, - "job_status": j.Status, - }).Debug("scheduler: Skipping execution") - return false - } + j.Status = j.GetStatus() + + if j.Status == StatusRunning && j.Concurrency == ConcurrencyForbid { + log.WithFields(logrus.Fields{ + "job": j.Name, + "concurrency": j.Concurrency, + "job_status": j.Status, + }).Debug("scheduler: Skipping execution") + return false } return true