Skip to content

Fix install-apply integration test orphaned by #15's same-uid retry - #18

Merged
josephschorr merged 1 commit into
mainfrom
fix/install-apply-same-uid-retry-test
Oct 5, 2026
Merged

josephschorr merged 1 commit into
mainfrom
fix/install-apply-same-uid-retry-test

Conversation

@josephschorr

Copy link
Copy Markdown
Member

What

mage test:integration has been red on main since #15 merged. The failing test is TestApplyPreparedRefusesUpdateAfterPrepare in pkg/platform/oap/install — and it fails deterministically, not as a flake.

Why

#15 ("Retry install's conditional SSA apply when its own controllers win the race") intentionally narrowed ssaApply's fail-closed behavior. A bare resourceVersion conflict whose re-read still shows the same uid is a benign race — the object's own controller writing a status/finalizer in the apply window — so the apply now re-reads and retries on the current resourceVersion instead of aborting the whole install. A uid change (same-name replacement) or the object's disappearance still fails closed.

#15 added fake-client tests for the new behavior but left TestApplyPreparedRefusesUpdateAfterPrepare asserting the old contract: that any intervening update — even same-uid — must make ApplyPrepared return an error. Under #15's code the apply retries and succeeds, so require.Error now fails every run.

Because this lives in //go:build integration (which go test ./... / mage test:unit skip), the break was invisible to the unit gate and only surfaces in CI's integration job — exactly the gap called out in the repo conventions.

The fix

Rewrite the test as the real-apiserver analog of #15's fake-client TestInstall_ControllerWriteBetweenCreateAndApply_RetriesOnCurrentVersion: a same-uid intervening update must retry to success, land the install's desired spec, and leave a field owned by another field manager untouched. The replacement / disappearance fail-closed siblings (TestApplyPreparedRefusesReplacementAfterPrepare, TestApplyPreparedRefusesDisappearedApprovedObject, TestApplyPreparedRefusesReplacementBetweenCreateAndSSA) are unchanged.

Verification

Reproduced the failure in isolation first, then confirmed the rewritten test plus all three fail-closed siblings pass under go test -race -tags=integration against envtest. Test-only change; no production code touched.

PR #15 ("Retry install's conditional SSA apply when its own controllers
win the race") narrowed ssaApply's fail-closed behavior: a bare
resourceVersion conflict whose re-read still shows the approved uid is a
benign race — the object's own controller writing a status/finalizer in
the apply window — so the apply re-reads and retries on the current
resourceVersion instead of aborting the install. A uid CHANGE
(replacement) or disappearance still fails closed.

TestApplyPreparedRefusesUpdateAfterPrepare was left asserting the old
contract: that ANY intervening update, even same-uid, must make
ApplyPrepared error. Under #15's code the apply retries and succeeds, so
require.Error now fails — the integration suite has been red on main
since #15 merged, and on every branch based on it.

Rewrite it as the real-apiserver analog of #15's fake-client
TestInstall_ControllerWriteBetweenCreateAndApply_RetriesOnCurrentVersion:
a same-uid intervening update must retry to success, land the install's
desired spec, and leave a field owned by another manager untouched. The
replacement/disappearance fail-closed siblings are unchanged.
@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
openagentprimitives Ready Ready Preview Oct 5, 2026 4:39pm UTC

Request Review

@josephschorr
josephschorr merged commit 345af1e into main Oct 5, 2026
9 checks passed

This branch was successfully deployed

1 active deployment
Preview — c6301aaf Deployed Oct 5, 2026 by vercel[bot]
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.

1 participant