Skip to content

test(e2e): check storage UIDs across SDK destroy and expired-token refusal - #13161

Closed
cuongdangn wants to merge 3 commits into
v1from
test-12731-live-identity-expired-token
Closed

cuongdangn wants to merge 3 commits into
v1from
test-12731-live-identity-expired-token

Conversation

@cuongdangn

@cuongdangn cuongdangn commented Oct 14, 2026 •

Copy link
Copy Markdown

Adds scenario 12 from the recovery scenarios in #12731 to the kind live tests. SDK destroy must keep the namespace, the KEK Secret and the gateway's PersistentVolumeClaim with unchanged UIDs. The gateway installed from the pinned chart must refuse an expired development token signed by the deployment's own key. Production code is unchanged; docs/contributing/live-tests.md describes the new checks.

Failure

Before this change, the live tests would pass two regressions:

  • deploy_to_the_health_check, which both public-SDK tests run, only checked that no destroy change names kubernetes_storage. It never read the cluster after Deployment::destroy. Its tests would pass a destroy that:

    • deleted and recreated the namespace or the key;
    • deleted the gateway's claim;
    • left the gateway installed.

    The raw OpenTofu test compares these identities, but across its own teardown graph, not across Deployment::destroy.

  • The gateway test only checked that a token signed by an unknown key is refused. A gateway that stopped checking exp would still pass it.

Decision

  • Expired token. authenticated_gateway runs in the raw OpenTofu test after each of its two installs.

    • It loads the deployment's development material from <state>/kubernetes/auth, where the OpenShell provider keeps it.
    • It first requires signing.pk8, because Development::ensure creates new material in an empty directory.
    • The gateway must accept a current token from that material, so a refusal can come only from the expiry.
    • A token issued a day ago, which expired 23 hours earlier, must make GetGatewayInfo fail with exactly Authentication. The gateway at OpenShell e1f3c82 validates bearer tokens with jsonwebtoken's default 60-second leeway and returns Unauthenticated for any decode error. Permission would mean authentication had passed.

    The public-SDK tests are not used for this, for two reasons. Presenting a token needs a gateway connection, which needs a generation that Deployment does not expose. That connection would also hold the loopback port that export and destroy bind.

  • Storage identities. deploy_to_the_health_check records three things:

    • the namespace UID;
    • the KEK Secret's UID and the SHA-256 of its key;
    • each gateway claim's name and UID.

    It records them after export, which only refreshes, and again right after destroy. It compares them after the existing cleanup. Before comparing, it asserts that destroy removed the gateway's Helm release record and StatefulSet, so the comparison spans a real removal. The Kubernetes and OpenShift profiles both run it.

  • retained().

    • It now returns a Result, so a failed observation before destroy no longer skips cleanup.
    • It selects claims by app.kubernetes.io/instance=<release>. The sandbox's workspace claim shares the namespace, and destroy deletes it asynchronously.
    • A namespace or claim with a deletion timestamp counts as not retained, because finalizers keep it readable with the same UID for a while.
    • The raw OpenTofu test unwraps it at its three call sites. That namespace holds only the gateway's claim, so the raw test compares the same objects as before.
  • No SDK re-apply after destroy. The raw test already re-applies after removal. A second SDK apply would repeat the gateway install and sandbox creation in the agent test, which already takes 67.4 to 88.5 s of its 120 s budget on recent v1 pushes.

These are characterization tests: they check behavior that already exists, so there is no failing test to observe first. No mutation probe was run. The checks need the real gateway and a cluster, and cargo ci live-kind runs only on Linux.

Validation

  • Ran locally: cargo ci on macOS arm64 at 24bdaa10f8 (this change merged with v1 33c3f11ccb) passed in 531 s. Its planner selected bundle and lifecycle, so every step ran: fmt, clippy, build, test (1485 passed), schema, bundle, and lifecycle (137 passed). It compiles and lints the live tests but does not run them. cargo run --locked -p nemoclaw-build -- fern check also passed, on Node 22.23.2 rather than the documented 24.21.0.
  • Deferred to CI: the live tests, because cargo ci live-kind runs only on Linux. This pull request's Live / Kind jobs ran them on the merge commit b9c564f362 (24bdaa10f8 into v1 4fe7431785). All five passed on both architectures, within budget:
Test linux_arm64 (Pi) linux_amd64 (OpenClaw)
an_agent_sandbox_reaches_its_health_check_and_destroy_keeps_storage passed, 73.8 s passed, 75.8 s
on_openshift_the_sandbox_runs_as_the_namespace_uid passed, 65.2 s passed, 64.5 s
the_gateway_installs_authenticates_and_is_removed_keeping_storage passed, 31.0 s passed, 29.7 s
The two kubernetes_chart tests passed, 2.0 s and 1.8 s passed, 1.8 s and 1.0 s
Nextest wall time (budget 270 s, 120 s per test) 173.8 s 172.7 s

Jobs: linux_arm64, linux_amd64. On the six v1 pushes from e0c8f19d4a to 4fe7431785 whose Live / Kind jobs ran, the three live tests took 67.4 to 88.5 s, 63.0 to 79.1 s and 26.4 to 34.8 s respectively, and the wall time was 160.9 to 200.6 s; the times above fall within those ranges.

Recorded inputs, as #12730 asks for live evidence:

Input Value
NemoClaw head 24bdaa10f8 (15956c22ef merged with v1 33c3f11ccb); local cargo ci on 24bdaa10f8; Live / Kind on merge commit b9c564f362 (v1 4fe7431785)
Bundle built in the same run from the merge commit: bundle-linux_arm64-b9c564f362ef…-1 and bundle-linux_amd64-b9c564f362ef…-1, kept one day
OpenShell e1f3c82caa3e (v0.1.3): gateway sha256:ea14aa4db098…, supervisor sha256:4ab2b970cdb0…, sandbox sha256:2658534bfb3f…, chart sha256:44ec11bbf264…
Development issuer nginx-unprivileged@sha256:5aea7cc516b4…
Fabric 24f068c895e5
Cluster kind v0.33.0, kindest/node:v1.37.0@sha256:a1ed56cfb0e7…, one node with kind's default CNI and StorageClass; Agent Sandbox v0.5.0 (manifest sha256:ccfe3649de8b…)
Agent image built from the merge commit by the live-images job and imported into kind by digest: Pi on linux_arm64 (sha256:e33f7076522e…), OpenClaw on linux_amd64 (sha256:85bc11cac5d0…)
Runners GitHub ubuntu-24.04-arm image 20261004.142.1 and ubuntu-24.04 image 20261012.334.1
Authentication Development profile

Limits of this evidence

Refs #12731

🤖 Generated with Claude Code

…fusal

SDK destroy must keep the namespace, the KEK Secret and the gateway's
PersistentVolumeClaim with unchanged UIDs, and the gateway installed from
the pinned chart must refuse an expired development token signed by the
deployment's own key. The checks run in the existing kind live tests.

Refs #12731

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

cuongdangn and others added 2 commits October 15, 2026 09:42
Resolve the conflict in docs/contributing/live-tests.md: keep v1's
data.fabric_agent_readiness.assistant and this branch's destroy sentence.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@cv

cv commented Oct 18, 2026 •

Copy link
Copy Markdown
Collaborator

Continued as #13421, which keeps your commit and authorship, rebased onto current v1. It needed one adaptation: since #13379, apply completes through fabric-agent-ctl, so the destroy identity checks now run inside deploy_image_and_export (registry and OpenShift tests) instead of a separate plain-Kubernetes test. cargo ci and cargo ci live-kind pass on it. Thanks for the checks. Closing this in favor of #13421.

@cv cv closed this Oct 18, 2026
cv added a commit that referenced this pull request Oct 18, 2026
…fusal (#13421)

Part of #12731. Recreates #13161 by @cuongdangn on a fresh branch,
because that branch doesn't allow maintainer edits. The commit keeps
their authorship.

## Failure

The live Kind tests would pass two regressions:

- **SDK destroy:** the tests that deploy through the public SDK only
checked that no destroy change named `kubernetes_storage`. They never
read the cluster after `Deployment::destroy`, so they'd pass a destroy
that recreated the namespace or key, deleted the gateway's claim, or
left the gateway installed.
- **Expired tokens:** the gateway test only checked that a token signed
by an unknown key is refused. A gateway that stopped checking `exp`
would still pass.

## Decision

The same checks as #13161, adapted to current `v1`:

- **Expired token:** after each install, the gateway test signs an
expired development token with the deployment's own key and requires the
gateway to refuse it. It also requires a current token from the same key
to be accepted, so a refusal can only come from expiry.
- **SDK destroy:** destroy must remove the gateway's Helm release record
and StatefulSet. It must keep the namespace, the encryption key Secret
and the gateway's PersistentVolumeClaim with unchanged UIDs.
- **Rebased onto `v1`:** #13161 added a separate plain-Kubernetes
deployment test for the destroy checks. Since #13379, apply completes
through `fabric-agent-ctl`, and the registry test
(`kubernetes_registry.rs`) already deploys an agent on Kubernetes
through `deploy_image_and_export`. So the destroy checks run inside
`deploy_image_and_export`, covering both the registry test and the
OpenShift test, without adding another slow live test.

Production code is unchanged.

## Validation

- `cargo ci` passes locally: 1,589 unit tests and 153 lifecycle tests.
- `cargo ci live-kind` passes locally: all 7 tests, including the new
checks.

Co-authored-by: Leo Dang <[email protected]>
@wscurran wscurran added area: e2e End-to-end tests, nightly failures, or validation infrastructure area: security Security controls, permissions, secrets, or hardening chore Build, CI, dependency, or tooling maintenance platform: k8s Affects Kubernetes deployments v1 NemoClaw v1 branch labels Oct 22, 2026
@cv
cv deleted the test-12731-live-identity-expired-token branch November 21, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: e2e End-to-end tests, nightly failures, or validation infrastructure area: security Security controls, permissions, secrets, or hardening chore Build, CI, dependency, or tooling maintenance platform: k8s Affects Kubernetes deployments v1 NemoClaw v1 branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants