Skip to content

test(e2e): isolate pending-delete outage test from the mecak8s reconciler - #2177

Merged
jbeda merged 1 commit into
mainfrom
fix/k8s-pending-delete-intent-isolation
Oct 7, 2026
Merged

jbeda merged 1 commit into
mainfrom
fix/k8s-pending-delete-intent-isolation

Conversation

@jbeda

@jbeda jbeda commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes a flaky failure in the production k8s execution qualification job:

production_qualification_test.go:1234: pending-delete intent was not durable across provider outage: listed=0 exact_code=not_found exact_state="" exact_operation_match=false
--- FAIL: TestKindExecutionProductionPendingDeleteOutageRecovery

Recent runs that failed this way include three on main (37657699332, 37621455637, 37540496088) and several on unrelated branches.

Root cause

This is a race in how the test is isolated, not a provider durability bug.

  • The test creates a synthetic environment, calls PrepareReferenceDelete, restarts the provider, and expects the PendingDelete intent to still exist. It connected as the mecak8s mTLS client.
  • The real mecak8s agent is deployed in the same cluster with that same identity. It runs ReconcileReferenceIntents at startup and then every minute (internal/app/reference_intent_reconcile.go).
  • That reconciler lists every intent belonging to its client. For a pending delete whose binding has no durable session, it confirms the delete, which removes the reference (internal/adapter/server/service.go, ReconcileReferenceIntents). The test's binding is synthetic, so it never has a session.
  • When the reconciler's tick lands in the ~15-second window between prepare and re-list, the intent is legitimately removed, and the test sees listed=0 and not_found.

Other tests that use the mecak8s identity are unaffected. retireSyntheticEnvironment confirms the delete straight away, and a second confirm on a reference that's already gone returns nil. The reconciler always leaves pending creates alone.

Fix

The provider only shows each client the intents it created (via spec.clientHash). So:

  • fixture/pki: issue a dedicated spiffe://mecatl.test/client/qualification client identity and allow it in the security manifest. It has the same rights as mecak8s (can attest owners, administrator), since it needs administrator to retire and delete its own environment.
  • fixture/rotation: add the same client entry, so every manifest version has the same client list.
  • Add productionClientAs(..., identity), with productionClient now calling it for mecak8s, and run TestKindExecutionProductionPendingDeleteOutageRecovery as qualification. The privacy check against the intruder client still applies.

Testing

  • go vet -tags kind_execution_e2e ./e2e/k8s_execution/...
  • Ran both fixture generators. qualification.crt has the expected SPIFFE URI and the client appears in the rotation manifests. The new manifest entry passes the provider's client-policy checks.
  • task lint, task test:race, and the mecademo smoke test pass.
  • Not run locally: the kind production profile itself. The CI execution provider production profile (kind) job is the verification.

Note for local kind runs: deploy/mecatl-execution-kind/run.sh skips certificate generation when $state/pki/ca.crt already exists. Delete $state/pki from a reused state directory so qualification.crt gets generated.

…iler

TestKindExecutionProductionPendingDeleteOutageRecovery held a synthetic
PendingDelete intent open across a provider restart using the mecak8s
client identity. The deployed mecak8s agent shares that identity and its
reference-intent reconciler confirms any of its client's pending deletes
whose binding has no durable session, so whenever its one-minute tick
landed in the restart window the intent vanished and the test failed with
listed=0 exact_code=not_found.

Issue a dedicated qualification client identity in the PKI fixture (and
keep the rotation manifests' client list in step) and run this test as
that client. Intents are client-scoped, so the agent can no longer see
the synthetic intent.

Co-authored-by: Mecatl <[email protected]>
@jbeda
jbeda merged commit 9cda76e into main Oct 7, 2026
36 checks passed
@jbeda
jbeda deleted the fix/k8s-pending-delete-intent-isolation branch October 7, 2026 18:32
@toolhive-release-app toolhive-release-app Bot mentioned this pull request Oct 7, 2026
2 tasks
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