Skip to content

test: fix TestSessionHold_SurvivesRunnerPodDeleteAndRecreate conflict flake - #5

Merged
josephschorr merged 1 commit into
mainfrom
fix/sessionhold-test-conflict-retry
Sep 28, 2026
Merged

josephschorr merged 1 commit into
mainfrom
fix/sessionhold-test-conflict-retry

Conversation

@josephschorr

Copy link
Copy Markdown
Member

Problem

TestSessionHold_SurvivesRunnerPodDeleteAndRecreate flaked in e2e CI (seen on PR #3, whose own change is unrelated) with:

Operation cannot be fulfilled on agentsessions.agentprimitives.authzed.com "centerdot-fake-...":
the object has been modified; please apply your changes to the latest version and try again

Proof it's a flake, not a regression: that run and its sibling push-triggered run were on the same commit — one failed here, the other passed.

Cause

touchSession does Get → mutate annotation → Update with no conflict retry. Its entire purpose is to provoke the AgentSession reconciler, which is concurrently writing the same object's status (the hold reap bumps resourceVersion — the failing run's log shows two "reaped session pods" reconciles firing on that object right before the error). When that write lands between the test's Get and Update, the unretried Update loses the optimistic-concurrency race and fails the test spuriously.

Fix

Wrap the read-modify-write in retry.RetryOnConflict(retry.DefaultRetry, ...) — the idiom already used for exactly this reason in test/e2e/harness.go's ApplyManifest. Test-only change; no product code touched.

TestSessionHold_SurvivesRunnerPodDeleteAndRecreate flaked in CI with:

  Operation cannot be fulfilled on agentsessions... the object has been
  modified; please apply your changes to the latest version and try again

touchSession does Get -> mutate annotation -> Update with no conflict
retry. Its whole purpose is to provoke the AgentSession reconciler, which
is concurrently writing the same object's status (the hold reap bumps
resourceVersion). When that write lands between the test's Get and Update,
the unretried Update loses the optimistic-concurrency race and fails the
test spuriously.

Wrap the read-modify-write in retry.RetryOnConflict(retry.DefaultRetry,
...), matching the idiom already used for the same reason in
test/e2e/harness.go's ApplyManifest.
@josephschorr
josephschorr force-pushed the fix/sessionhold-test-conflict-retry branch from 9b2cd7e to 2438c0e Compare September 28, 2026 19:47
@josephschorr
josephschorr merged commit 053367a into main Sep 28, 2026
5 checks passed
@josephschorr
josephschorr deleted the fix/sessionhold-test-conflict-retry branch September 28, 2026 20:56
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