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 periodic dispatch and blocked evals not releasing lock #1231

Merged
merged 1 commit into from
Jun 3, 2016
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
1 change: 1 addition & 0 deletions nomad/blocked_evals.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ func (b *BlockedEvals) SetEnabled(enabled bool) {
b.l.Lock()
if b.enabled == enabled {
// No-op
b.l.Unlock()
return
} else if enabled {
go b.watchCapacity()
Expand Down
8 changes: 7 additions & 1 deletion nomad/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ func (s *Server) DispatchJob(job *structs.Job) (*structs.Evaluation, error) {

// RunningChildren checks whether the passed job has any running children.
func (s *Server) RunningChildren(job *structs.Job) (bool, error) {
state := s.fsm.State()
state, err := s.fsm.State().Snapshot()
if err != nil {
return false, err
}

prefix := fmt.Sprintf("%s%s", job.ID, structs.PeriodicLaunchSuffix)
iter, err := state.JobsByIDPrefix(prefix)
if err != nil {
Expand Down Expand Up @@ -272,11 +276,13 @@ func (p *PeriodicDispatch) ForceRun(jobID string) (*structs.Evaluation, error) {

// Do nothing if not enabled
if !p.enabled {
p.l.Unlock()
return nil, fmt.Errorf("periodic dispatch disabled")
}

job, tracked := p.tracked[jobID]
if !tracked {
p.l.Unlock()
return nil, fmt.Errorf("can't force run non-tracked job %v", jobID)
}

Expand Down