Merge branch 'master' of github.com:hashicorp/nomad

This commit is contained in:
Alex Dadgar 2016-06-03 14:14:36 -07:00
commit 97dc78b8e2
2 changed files with 8 additions and 1 deletions

View File

@ -106,6 +106,7 @@ func (b *BlockedEvals) SetEnabled(enabled bool) {
b.l.Lock() b.l.Lock()
if b.enabled == enabled { if b.enabled == enabled {
// No-op // No-op
b.l.Unlock()
return return
} else if enabled { } else if enabled {
go b.watchCapacity() go b.watchCapacity()

View File

@ -81,7 +81,11 @@ func (s *Server) DispatchJob(job *structs.Job) (*structs.Evaluation, error) {
// RunningChildren checks whether the passed job has any running children. // RunningChildren checks whether the passed job has any running children.
func (s *Server) RunningChildren(job *structs.Job) (bool, error) { 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) prefix := fmt.Sprintf("%s%s", job.ID, structs.PeriodicLaunchSuffix)
iter, err := state.JobsByIDPrefix(prefix) iter, err := state.JobsByIDPrefix(prefix)
if err != nil { if err != nil {
@ -272,11 +276,13 @@ func (p *PeriodicDispatch) ForceRun(jobID string) (*structs.Evaluation, error) {
// Do nothing if not enabled // Do nothing if not enabled
if !p.enabled { if !p.enabled {
p.l.Unlock()
return nil, fmt.Errorf("periodic dispatch disabled") return nil, fmt.Errorf("periodic dispatch disabled")
} }
job, tracked := p.tracked[jobID] job, tracked := p.tracked[jobID]
if !tracked { if !tracked {
p.l.Unlock()
return nil, fmt.Errorf("can't force run non-tracked job %v", jobID) return nil, fmt.Errorf("can't force run non-tracked job %v", jobID)
} }