Skip to content

fix: handle requeued gang members in eviction and assertion logic#4733

Merged
dejanzele merged 2 commits intoarmadaproject:masterfrom
dejanzele:fix/gang-eviction-requeued-members
Mar 3, 2026
Merged

fix: handle requeued gang members in eviction and assertion logic#4733
dejanzele merged 2 commits intoarmadaproject:masterfrom
dejanzele:fix/gang-eviction-requeued-members

Conversation

@dejanzele
Copy link
Member

@dejanzele dejanzele commented Mar 2, 2026

What type of PR is this?

Bug fix

What this PR does / why we need it

Fixes a gang eviction assertion crash (gang was partially evicted: 2 out of 3 jobs evicted) that occurs when a gang has a member that was returned by the executor and requeued.

Root cause: When the executor returns a failed gang job, the scheduler requeues it with WithQueued(true), but LatestRun().NodeId() still points to the old node. When oversubscribed eviction later targets a running gang member, collectIdsForGangEviction reads the stale node ID from the requeued job, the filtered evictor looks at the wrong node, gang eviction is incomplete, and evictionAssertions panics because it expects all gang members to be evicted but the requeued member was never on the node the evictor checked.

Changes in preempting_queue_scheduler.go:

  1. collectIdsForGangEviction: Check the scheduling context first for a node ID (handles current-round rescheduling). If the job is not in the scheduling context and is queued, skip node collection entirely (the job is not on any node). Fall back to LatestRun().NodeId() only for running jobs.

  2. evictionAssertions: Exclude queued-and-not-evicted gang members from the expected eviction count. These members are not on any node and cannot be evicted, so they should not contribute to the total the assertion checks against.

Which issue(s) this PR fixes

Special notes for your reviewer

The crash is deterministic when a gang has a mix of running and requeued members and oversubscribed eviction is triggered.

Before this fix, the node-lookup order was: LatestRun() == nil -> scheduling context, else -> LatestRun().NodeId(). This missed the case where LatestRun() is non-nil but stale (requeued job).

The new order is: scheduling context first -> queued with no context (skip node) -> LatestRun().NodeId() for running jobs -> error for anything else.

@dejanzele dejanzele force-pushed the fix/gang-eviction-requeued-members branch 4 times, most recently from d325b90 to 2dc3edc Compare March 2, 2026 14:58
@dejanzele dejanzele requested a review from JamesMurkin March 2, 2026 15:09
@dejanzele dejanzele force-pushed the fix/gang-eviction-requeued-members branch 2 times, most recently from 1379282 to 9011ce0 Compare March 2, 2026 15:21
Signed-off-by: Dejan Zele Pejchev <pejcev.dejan@gmail.com>
@dejanzele dejanzele force-pushed the fix/gang-eviction-requeued-members branch from 9011ce0 to b119708 Compare March 2, 2026 15:22
@dejanzele dejanzele enabled auto-merge (squash) March 3, 2026 13:25
@dejanzele dejanzele merged commit 4f13138 into armadaproject:master Mar 3, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants