state: nil-check waiting evals before attempting to cancel them (#26872)

When we attempt to drop unneeded evals from the eval broker, if the eval has
been GC'd before the check is made, we hit a nil pointer. Check that the eval
actually exists before attempting to remove it from the broker.

Fixes: https://github.com/hashicorp/nomad/issues/26871
This commit is contained in:
Tim Gross
2025-10-02 12:24:59 -04:00
committed by GitHub
parent 3f7cf0b287
commit 566164a321
2 changed files with 4 additions and 1 deletions

3
.changelog/26872.txt Normal file
View File

@@ -0,0 +1,3 @@
```release-note:bug
state: Fixed a bug where the server could panic when attempting to remove unneeded evals from the eval broker
```

View File

@@ -1034,7 +1034,7 @@ func (n *nomadFSM) applyAllocClientUpdate(msgType structs.MessageType, buf []byt
"eval_id", evalID, "error", err)
return err
}
if !eval.ShouldEnqueue() {
if eval != nil && !eval.ShouldEnqueue() {
n.evalBroker.DropWaiting(eval)
}
}