Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix concurrency check #383

Merged
merged 1 commit into from
May 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions dkron/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
24 changes: 9 additions & 15 deletions dkron/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down