Skip to content

test(kubernetes): cover managed-gateway OIDC and three agents on one in-cluster route - #13484

Merged
cv merged 3 commits into
v1from
test/12734-kubernetes-gateway-sdk
Oct 19, 2026
Merged

cv merged 3 commits into
v1from
test/12734-kubernetes-gateway-sdk

Conversation

@gaveezy

@gaveezy gaveezy commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Failure

#12734 asks for unit and fixture coverage of managed-gateway OIDC authentication, token refresh and authentication failures, and of per-agent identity and routing for agents that use cluster-local inference. The Kubernetes gateway code that #13414 and #13063 added had little of either.

OIDC. Every SDK Kubernetes operations and connect test used the development profile, so the oidc branches from #13414 had no unit or fixture test: the auth resource identified by its namespace once ready, no issuer objects or signing material, and the token read from the variable tokenEnv names. The forwarded fake-gateway tests always supplied the token the gateway expected. Only the live kubernetes_live::oidc test refuses a token on the managed Kubernetes path, and it checks neither the error class nor that nothing changed.

Several agents on an in-cluster model. kubernetes_inference covered one sandbox, from the local.yaml fixture. No test checked per-agent names or routes for the three-agent cluster examples: example_configurations_are_valid_fabric_configurations compiles them only to validate their Fabric configurations. The #13063 commit message names catalog-skip tests, such as kubernetes_inference::cluster_gateways_read_no_model_catalog_for_a_cluster_service, that v1 does not have.

Decision

These tests characterize existing behavior; no production code changes.

OIDC

  • kubernetes_operations: with an oidc spec, ensure of the auth resource adds no cluster objects and no local signing material. read reports no identity before the resource is ready, and the namespace UID after.
  • kubernetes_connect: running takes the spec to prepare from. A connection's token equals the value of the variable tokenEnv names, and no state file contains it. When that variable is unset or empty, connect fails with the tokenEnv message.
  • Tests can't safely set a variable while others run, so tokenEnv names variables that Cargo and nextest set for every test process: CARGO_MANIFEST_DIR holds a token, and CARGO_PKG_LICENSE_FILE is empty because the package declares an SPDX license. PATH, the precedent in fake_gateway_tests, can't be used: the schema forbids it as tokenEnv, so the operations refuse the spec with Query before connect reads a token.
  • fake_gateway_tests: the Forward stub's token is now a field, and Forward::client opens a new GatewayClient. A gateway that requires a fresh token refuses every call with a stale one, so nothing changes, and the provider reports ObservationError::Authentication without state. That variant carries no gateway text, so it can't echo the token. A new client with the fresh token then succeeds, as the next command's provider process would; a GatewayClient keeps its client for the process's lifetime.

No test changes a variable's value between commands. That a refreshed token takes effect on the next command follows from these tests and an_existing_issuers_token_reaches_gateway_only_runs, which resolves tokenEnv into OpenTofu's environment on each command.

Three agents on one in-cluster route

three_agents_on_a_cluster_gateway_share_one_service_registration_with_their_own_rules compiles examples/kubernetes/external-gateway.yaml and examples/openshift/external-gateway.yaml with the provider endpoint set to http://qwen.models.svc.cluster.local:8000/v1. It checks:

  • one openshell_inference whose server is the Service endpoint with the example provider's credential, and no cluster_source;
  • in each of the three sandboxes, an FQDN rule for the Service's host, port and /v1/**, without allowed_ips or cluster_grants;
  • one fabric_agent per sandbox, named by that sandbox's agent.name, whose models use the Service as base_url;
  • the same graph with spec.sandboxes reversed.

examples/kubernetes/managed-development.yaml keeps its hosted endpoint, because its explicit policies name it, and is checked only for agent names. The test reads agent names from each document: main in the external examples, primary in managed-development.

a_cluster_service_endpoint_reads_no_catalog_while_https_and_private_addresses_keep_theirs pins the skip that #13063 landed in endpoint_requests: an endpoint that fails validate_endpoint, such as plain HTTP to a Service name, has no catalog request, while an HTTPS endpoint and plain HTTP to 10.0.0.5 each keep one.

The rule lookup and the expected Service rule endpoints move into helpers that the single-sandbox test also uses. Its assertions are unchanged.

Validation

The tests passed when added. If one fails later, the fix belongs in its own PR, with that test as its failing test.

  • cargo ci passed: tools, fmt, clippy, build, test (1606 passed), schema, bundle, and lifecycle (150 passed), within budget.
  • cargo nextest run -p nemoclaw-sdk -E 'test(/kubernetes_connect|kubernetes_operations|kubernetes_inference|inference_discovery/)' and cargo nextest run -p openshell-provider --lib pass.
  • cargo test -p nemoclaw-sdk --test integration on the three new OIDC tests passes, so both Cargo variables are set under cargo test too.
  • Each key assertion failed against a temporary change, since reverted.
    • OIDC inputs and fixtures: development auth on ensure; an existing auth directory; a receipt already marked ready; tokenEnv naming another variable; the token copied into the state directory; a set variable in the missing-token test; a missing client TLS Secret; the stale forward supplying the fresh token; a gateway accepting any token; a new client with a third token.
    • Production mutations: operations.rs identifying the oidc auth resource by its first issuer object; operations.rs accepting an empty token; Mutation::failed carrying state; no credential on a registration that several sandboxes share.
    • Routing inputs: a second registration, another Service port, a cluster_source, a cluster grant or allowed_ips on one sandbox, agents named after their sandboxes (also for managed-development alone), another model base_url, agent metadata that depends on sandbox order, no validation skip, rejected private HTTP, and skipped HTTPS.
  • On a single-node k3s v1.36.5 cluster (linux_arm64) with Agent Sandbox v0.5.0, the live-kind profile without the kind-only registry test passed: kubernetes_live::the_gateway_installs_authenticates_and_is_removed_keeping_storage, kubernetes_live::on_openshift_the_sandbox_runs_as_the_namespace_uid, kubernetes_live::oidc::a_managed_gateway_accepts_an_existing_issuers_tokens_and_refuses_another_audience, and the three kubernetes_chart tests. The agent was the Pi image from v1 CI's live-images-linux_arm64 artifact for d33d50647, imported into k3s by digest. 6 passed in 82 s.
  • Deferred to CI: cargo ci live-docker, and cargo ci live-kind on kind including kubernetes_live::registry, which cargo ci selects because openshell-provider changed. Docker isn't installed on this host.

🤖 Generated with Claude Code

…in-cluster route

## Failure

#12734 asks for unit and fixture coverage of managed-gateway OIDC authentication, token refresh and authentication failures, and of per-agent identity and routing for agents that use cluster-local inference. The Kubernetes gateway code that #13414 and #13063 added had little of either.

**OIDC.** Every SDK Kubernetes operations and connect test used the development profile, so the `oidc` branches from #13414 had no unit or fixture test: the auth resource identified by its namespace once ready, no issuer objects or signing material, and the token read from the variable `tokenEnv` names. The forwarded fake-gateway tests always supplied the token the gateway expected. Only the live `kubernetes_live::oidc` test refuses a token on the managed Kubernetes path, and it checks neither the error class nor that nothing changed.

**Several agents on an in-cluster model.** `kubernetes_inference` covered one sandbox, from the `local.yaml` fixture. No test checked per-agent names or routes for the three-agent cluster examples: `example_configurations_are_valid_fabric_configurations` compiles them only to validate their Fabric configurations. The #13063 commit message names catalog-skip tests, such as `kubernetes_inference::cluster_gateways_read_no_model_catalog_for_a_cluster_service`, that v1 does not have.

## Decision

These tests characterize existing behavior; no production code changes.

### OIDC

- `kubernetes_operations`: with an `oidc` spec, `ensure` of the auth resource adds no cluster objects and no local signing material. `read` reports no identity before the resource is ready, and the namespace UID after.
- `kubernetes_connect`: `running` takes the spec to prepare from. A connection's token equals the value of the variable `tokenEnv` names, and no state file contains it. When that variable is unset or empty, `connect` fails with the `tokenEnv` message.
- Tests can't safely set a variable while others run, so `tokenEnv` names variables that Cargo and nextest set for every test process: `CARGO_MANIFEST_DIR` holds a token, and `CARGO_PKG_LICENSE_FILE` is empty because the package declares an SPDX license. `PATH`, the precedent in `fake_gateway_tests`, can't be used: the schema forbids it as `tokenEnv`, so the operations refuse the spec with `Query` before `connect` reads a token.
- `fake_gateway_tests`: the `Forward` stub's token is now a field, and `Forward::client` opens a new `GatewayClient`. A gateway that requires a fresh token refuses every call with a stale one, so nothing changes, and the provider reports `ObservationError::Authentication` without state. That variant carries no gateway text, so it can't echo the token. A new client with the fresh token then succeeds, as the next command's provider process would; a `GatewayClient` keeps its client for the process's lifetime.

No test changes a variable's value between commands. That a refreshed token takes effect on the next command follows from these tests and `an_existing_issuers_token_reaches_gateway_only_runs`, which resolves `tokenEnv` into OpenTofu's environment on each command.

### Three agents on one in-cluster route

`three_agents_on_a_cluster_gateway_share_one_service_registration_with_their_own_rules` compiles `examples/kubernetes/external-gateway.yaml` and `examples/openshift/external-gateway.yaml` with the provider endpoint set to `http://qwen.models.svc.cluster.local:8000/v1`. It checks:

- one `openshell_inference` whose server is the Service endpoint with the example provider's credential, and no `cluster_source`;
- in each of the three sandboxes, an FQDN rule for the Service's host, port and `/v1/**`, without `allowed_ips` or `cluster_grants`;
- one `fabric_agent` per sandbox, named by that sandbox's `agent.name`, whose models use the Service as `base_url`;
- the same graph with `spec.sandboxes` reversed.

`examples/kubernetes/managed-development.yaml` keeps its hosted endpoint, because its explicit policies name it, and is checked only for agent names. The test reads agent names from each document: `main` in the external examples, `primary` in managed-development.

`a_cluster_service_endpoint_reads_no_catalog_while_https_and_private_addresses_keep_theirs` pins the skip that #13063 landed in `endpoint_requests`: an endpoint that fails `validate_endpoint`, such as plain HTTP to a Service name, has no catalog request, while an HTTPS endpoint and plain HTTP to `10.0.0.5` each keep one.

The rule lookup and the expected Service rule endpoints move into helpers that the single-sandbox test also uses. Its assertions are unchanged.

## Validation

The tests passed when added. If one fails later, the fix belongs in its own PR, with that test as its failing test.

- `cargo ci` passed: tools, fmt, clippy, build, test (1606 passed), schema, bundle, and lifecycle (150 passed), within budget.
- `cargo nextest run -p nemoclaw-sdk -E 'test(/kubernetes_connect|kubernetes_operations|kubernetes_inference|inference_discovery/)'` and `cargo nextest run -p openshell-provider --lib` pass.
- `cargo test -p nemoclaw-sdk --test integration` on the three new OIDC tests passes, so both Cargo variables are set under `cargo test` too.
- Each key assertion failed against a temporary change, since reverted.
  - OIDC inputs and fixtures: development auth on `ensure`; an existing auth directory; a receipt already marked ready; `tokenEnv` naming another variable; the token copied into the state directory; a set variable in the missing-token test; a missing client TLS Secret; the stale forward supplying the fresh token; a gateway accepting any token; a new client with a third token.
  - Production mutations: `operations.rs` identifying the `oidc` auth resource by its first issuer object; `operations.rs` accepting an empty token; `Mutation::failed` carrying state; no credential on a registration that several sandboxes share.
  - Routing inputs: a second registration, another Service port, a `cluster_source`, a cluster grant or `allowed_ips` on one sandbox, agents named after their sandboxes (also for managed-development alone), another model `base_url`, agent metadata that depends on sandbox order, no validation skip, rejected private HTTP, and skipped HTTPS.
- Deferred to CI: `cargo ci live-docker` and `cargo ci live-kind`, which `cargo ci` selects because `openshell-provider` changed. Docker isn't installed on this host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

@cv
cv enabled auto-merge (squash) October 19, 2026 22:04
@cv
cv merged commit aa44a7e into v1 Oct 19, 2026
@cv
cv deleted the test/12734-kubernetes-gateway-sdk branch October 19, 2026 22:17
cv added a commit that referenced this pull request Oct 19, 2026
…fig (#13501)

## Failure

With `gateway.kubernetes.authentication.profile: oidc`, NemoClaw took
OpenShell's OIDC settings as its own fields (`issuer`, `audience`,
`rolesClaim`, `adminRole`, `userRole`, `scopesClaim`) and copied them
into the chart's `openshell.gateway.oidc` table. It also added
`jwks_ttl_secs` and `dangerously_allow_insecure_http`. Each new
OpenShell OIDC setting needed a NemoClaw field. NemoClaw's docs also
misdescribed OpenShell's behavior: omitting both roles applies
OpenShell's default roles, not "any valid token" (#13495).

## Decision

- **Where the settings live:** the `oidc` profile takes
`openshell.gateway.oidc` from `spec.gateway.config` (#13492), in
OpenShell's names, exactly as OpenShell's [gateway authentication
guide](https://github.com/NVIDIA/OpenShell/blob/5a7728c304b5528e954e9ae900cf21f84e1a12b1/docs/how-it-works/gateways/authentication.mdx#oidc)
documents for Helm. The table reaches the chart as written.
- **What NemoClaw keeps:** `profile`, the `token` reference it uses to
reach the gateway, and `caConfigMap`, a chart value rather than gateway
configuration.
- **Validation:**
  - plan requires the table, in either the dotted or the nested form;
- under `development` it still rejects the table, since NemoClaw writes
it for its own issuer;
- NemoClaw no longer checks the issuer URL's shape or the pairing of
roles; OpenShell validates its table.
- **Values NemoClaw added:** dropping them changes nothing, because
OpenShell's defaults for `jwks_ttl_secs` (3600) and
`dangerously_allow_insecure_http` (false) are the same.
- No backward compatibility.

## Validation

- **Tests:**
-
`an_oidc_profile_takes_openshells_oidc_table_and_development_takes_none`
covers the dotted and nested tables, the removed fields, and the
required and owned table.
- `an_existing_oidc_issuer_replaces_the_development_issuer` checks that
the table reaches the chart as written and that the provider row holds
only `token` and `caConfigMap`.
  - #13484's connect and operations tests use the new shape.
- **Checks:**
- `cargo ci` passed, including the bundle and lifecycle steps, after
rebasing onto #13484;
- `cargo ci live-kind` passed (7 tests), including
`kubernetes_live::oidc`, which authenticates with an existing issuer's
token through the new table and refuses another audience.

After merge, close #13495 by hand.
@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 labels Oct 23, 2026
@wscurran wscurran added the v1 NemoClaw v1 branch label Oct 28, 2026
@cv cv added this to the Roadmap: GTC DC 2026 milestone Nov 18, 2026
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