Repository navigation
fix(api): preserve authentication union across v1alpha1 spoke round trip (AUTH-14) - #168
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
REVIEW — MKurator/PR#168 (worktree-fix-qmc-auth-conversion-roundtrip) @ af498d2 — REQUEST CHANGES — 2026-07-29Verdict: REQUEST CHANGES Orient: Fixes the AUTH-14 post-merge E2E regression by root-causing it to
Adversarial check performed: Verified Functional correctness: Root cause is correctly diagnosed and the regression test ( Coverage delta: api/ package floor still met overall (76.4%), but the new error-handling branch in the touched file is at 0% — see F1. Summary / next steps: Solid root-cause diagnosis and a real regression test after four misdiagnosed timeout-widening PRs. Before merge: (1) add a test for the malformed-annotation |
…rip (AUTH-14) The AUTH-14 post-merge e2e regression was not a race or a timing issue (the 5m->8m timeout widenings never helped): QueueManagerConnection.ConvertTo unconditionally nils spec.authentication when up-converting the v1alpha1 spoke to the v1beta1 hub. The reconciler always works through the v1alpha1 type, and its very first reconcile of any new object adds a finalizer via a full v1alpha1 Update - a metadata-only change that still round-trips the whole object down (ConvertFrom) then back up (ConvertTo) through the spoke. For a union-auth QMC that has no v1alpha1 representation at all, that round trip permanently wiped spec.authentication in etcd moments after creation, so mqrest's cacheFingerprint failed with "resource name may not be empty" on every reconcile for the rest of the test's 8-minute window. Fix: stash the hub's authentication union as JSON on an annotation during down-conversion (ConvertFrom) and restore it during up-conversion (ConvertTo) if present, stripping the annotation so it never leaks into storage. A true v1alpha1-origin write has no snapshot and is unaffected. This is safe against concurrent v1beta1 writers because the spoke and hub share one storage object and resourceVersion, so a stale spoke write is rejected as a conflict rather than silently clobbering a newer union. Verified both at the unit level (api/v1alpha1) and end-to-end against a real envtest API server + conversion webhook (test/conversionwebhook), confirming the new test fails on the prior code and passes with the fix - the in-process conversion functions alone can't prove apiextensions-apiserver's restoreObjectMeta actually carries a webhook-set annotation through. Also: point the e2e diagnostic dump at the v1beta1 hub explicitly instead of the unqualified "queuemanagerconnection" (which silently resolves to the lossy v1alpha1 view and made the prior diagnostic inconclusive), and correct now-stale comments that claimed dropping the union on down-conversion loses "nothing at rest."
af498d2 to
6842f10
Compare
|



Summary
Root-causes and fixes the E2E regression on
main(E2Eworkflow failing onrecovers union-auth QueueManagerConnection readiness after auth-secret rotation), which the last several commits (f450f23,30d480d,f16d881,1102948,fd0da61) tried to fix as a timing/race issue without success.Actual root cause:
QueueManagerConnection.ConvertTo(v1alpha1 spoke → v1beta1 hub) unconditionally setsspec.authentication = nil. The reconciler always works through the v1alpha1 type, and the very first reconcile of any new object adds a finalizer via a full v1alpha1Update— a metadata-only change that still round-trips the whole object down (ConvertFrom) then back up (ConvertTo) through the spoke. For a union-auth QMC (no v1alpha1 representation exists for the union), this permanently wipedspec.authenticationin etcd moments after creation — not a race, so no amount of timeout widening could help.Fix: stash the hub's
authenticationunion as JSON on an annotation during down-conversion, restore it during up-conversion if present, and strip the annotation so it never leaks into storage. Safe against concurrent v1beta1 writers because the spoke/hub share one storage object + resourceVersion (a stale spoke write conflicts rather than clobbering).Verification: added a unit-level round-trip test (
api/v1alpha1) and an end-to-end envtest test against a real API server + conversion webhook (test/conversionwebhook) — confirmed the new envtest case fails on the prior code and passes with the fix, since the in-process conversion functions alone can't proveapiextensions-apiserver'srestoreObjectMetaactually carries a webhook-set annotation through a real round trip.Also included (minor doc/diagnostic gaps found along the way):
queuemanagerconnection, which silently resolved to the lossy v1alpha1 view and made the prior diagnostic inconclusive.conversion_auth.go/cacheconfig/secret.gothat claimed dropping the union on down-conversion loses "nothing at rest" (true for reads, false once a spoke write round-trips it).docs/ARCHITECTURE.mdnote on Secret/QMC-hub cache bypass (DisableFor), closing a deferred doc gap referenced ininternal/cacheconfig/secret.go.Test plan
go test ./api/v1alpha1/... -run QueueManagerConnection— unit round-trip tests passgo test ./test/conversionwebhook/...(real envtest API server + conversion webhook) — new regression test passes with the fix, fails without it (verified both ways)go test -race ./internal/... ./api/... ./test/...(withKUBEBUILDER_ASSETSviasetup-envtest) — full suite greentask lint,task verify,task scrub— all cleanE2EGitHub Actions workflow (kind + IBM MQ) — not runnable locally in this environment; should be confirmed green on this PR's CI run