mirror of
https://github.com/kemko/nomad.git
synced 2026-01-07 02:45:42 +03:00
Fix not enqueuing eval
This commit is contained in:
committed by
Preetha Appan
parent
f95230028d
commit
01fcba1c4a
@@ -38,6 +38,7 @@ func allocPromoter(errCh chan<- error, ctx context.Context,
|
||||
|
||||
// For each alloc that doesn't have its deployment status set, set it
|
||||
var updates []*structs.Allocation
|
||||
now := time.Now()
|
||||
for _, alloc := range allocs {
|
||||
if alloc.Job.Type != structs.JobTypeService {
|
||||
continue
|
||||
@@ -48,7 +49,8 @@ func allocPromoter(errCh chan<- error, ctx context.Context,
|
||||
}
|
||||
newAlloc := alloc.Copy()
|
||||
newAlloc.DeploymentStatus = &structs.AllocDeploymentStatus{
|
||||
Healthy: helper.BoolToPtr(true),
|
||||
Healthy: helper.BoolToPtr(true),
|
||||
Timestamp: now,
|
||||
}
|
||||
updates = append(updates, newAlloc)
|
||||
logger.Printf("Marked deployment health for alloc %q", alloc.ID)
|
||||
|
||||
56
nomad/fsm.go
56
nomad/fsm.go
@@ -582,21 +582,36 @@ func (n *nomadFSM) upsertEvals(index uint64, evals []*structs.Evaluation) error
|
||||
return err
|
||||
}
|
||||
|
||||
for _, eval := range evals {
|
||||
if eval.ShouldEnqueue() {
|
||||
n.evalBroker.Enqueue(eval)
|
||||
} else if eval.ShouldBlock() {
|
||||
n.blockedEvals.Block(eval)
|
||||
} else if eval.Status == structs.EvalStatusComplete &&
|
||||
len(eval.FailedTGAllocs) == 0 {
|
||||
// If we have a successful evaluation for a node, untrack any
|
||||
// blocked evaluation
|
||||
n.blockedEvals.Untrack(eval.JobID)
|
||||
}
|
||||
}
|
||||
n.handleUpsertedEvals(evals)
|
||||
return nil
|
||||
}
|
||||
|
||||
// handleUpsertingEval is a helper for taking action after upserting
|
||||
// evaluations.
|
||||
func (n *nomadFSM) handleUpsertedEvals(evals []*structs.Evaluation) {
|
||||
for _, eval := range evals {
|
||||
n.handleUpsertedEval(eval)
|
||||
}
|
||||
}
|
||||
|
||||
// handleUpsertingEval is a helper for taking action after upserting an eval.
|
||||
func (n *nomadFSM) handleUpsertedEval(eval *structs.Evaluation) {
|
||||
if eval == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if eval.ShouldEnqueue() {
|
||||
n.evalBroker.Enqueue(eval)
|
||||
} else if eval.ShouldBlock() {
|
||||
n.blockedEvals.Block(eval)
|
||||
} else if eval.Status == structs.EvalStatusComplete &&
|
||||
len(eval.FailedTGAllocs) == 0 {
|
||||
// If we have a successful evaluation for a node, untrack any
|
||||
// blocked evaluation
|
||||
n.blockedEvals.Untrack(eval.JobID)
|
||||
}
|
||||
}
|
||||
|
||||
func (n *nomadFSM) applyDeleteEval(buf []byte, index uint64) interface{} {
|
||||
defer metrics.MeasureSince([]string{"nomad", "fsm", "delete_eval"}, time.Now())
|
||||
var req structs.EvalDeleteRequest
|
||||
@@ -730,6 +745,8 @@ func (n *nomadFSM) applyAllocUpdateDesiredTransition(buf []byte, index uint64) i
|
||||
n.logger.Printf("[ERR] nomad.fsm: UpdateAllocsDesiredTransitions failed: %v", err)
|
||||
return err
|
||||
}
|
||||
|
||||
n.handleUpsertedEvals(req.Evals)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -821,10 +838,7 @@ func (n *nomadFSM) applyDeploymentStatusUpdate(buf []byte, index uint64) interfa
|
||||
return err
|
||||
}
|
||||
|
||||
if req.Eval != nil && req.Eval.ShouldEnqueue() {
|
||||
n.evalBroker.Enqueue(req.Eval)
|
||||
}
|
||||
|
||||
n.handleUpsertedEval(req.Eval)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -841,10 +855,7 @@ func (n *nomadFSM) applyDeploymentPromotion(buf []byte, index uint64) interface{
|
||||
return err
|
||||
}
|
||||
|
||||
if req.Eval != nil && req.Eval.ShouldEnqueue() {
|
||||
n.evalBroker.Enqueue(req.Eval)
|
||||
}
|
||||
|
||||
n.handleUpsertedEval(req.Eval)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -862,10 +873,7 @@ func (n *nomadFSM) applyDeploymentAllocHealth(buf []byte, index uint64) interfac
|
||||
return err
|
||||
}
|
||||
|
||||
if req.Eval != nil && req.Eval.ShouldEnqueue() {
|
||||
n.evalBroker.Enqueue(req.Eval)
|
||||
}
|
||||
|
||||
n.handleUpsertedEval(req.Eval)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user