Skip to content

fix(admission): accept verified bound Pod topology - #359

Merged
FumingZhang merged 5 commits into
mainfrom
fix/custom-terminal-topology
Oct 30, 2026
Merged

FumingZhang merged 5 commits into
mainfrom
fix/custom-terminal-topology

Conversation

@FumingZhang

Copy link
Copy Markdown
Member

Summary

Validate scheduler-added Pod topology against the current assigned Node when checking a Custom terminal's CONNECT target or updating an already-bound common-executor Pod.

Kubernetes copies region/zone labels during Pod binding. The rendered-template validator previously treated those legitimate additions as unrelated labels, leaving the Custom terminal unready even after the main container was ready. Reuse the existing Node-verified topology logic rather than ignoring labels or bypassing CONNECT authorization.

Keep exact template, owner, source and reservation checks. Reject forged topology, unavailable Nodes, unrelated labels and attempts to change an already-bound Pod's Node. Add regression coverage for both rendered workload kinds and real API-server binding on Kata/container configurations.

Related issue

Focused follow-up to #354, discovered during authorized isolated validation. This PR targets feat/custom-sandbox-runtime; it is independent of the Portal model-selection follow-up #357 and does not merge either prerequisite.

Validation

Offline checks used Go 1.27.3, Helm 3.22, pinned Kubernetes 1.37 local API-server assets and Hugo 0.164.0 extended. USE_EXISTING_CLUSTER=false and an empty kubeconfig kept these tests separate from the live environment. Commands are relative to the repository root.

Command: go -C app/cetirun-operator test ./internal/controller -run '^TestCommonCustomTerminalConnectUsesRenderedAuthority$' -count=1
Result: reproduced the observed TerminalTargetUnavailable rejection after adding legitimate bound topology, before the repair.

Command: go -C app/cetirun-operator test ./internal/sandboxworkload ./internal/admission ./internal/terminal -count=1
Result: passed.

Command: go -C app/cetirun-operator test ./internal/controller -run 'Test(CommonCustomTerminal|ReconciledSandboxAdmitsCurrentMainAndAuxiliaryPods|NativeSandboxObservesRunning)' -count=1
Result: passed.

Command: go -C app/cetirun-operator test -race ./internal/sandboxworkload ./internal/admission ./internal/terminal -count=1
Result: passed.

Command: go -C app/cetirun-operator test -race ./internal/controller -run '^TestCommonCustomTerminalConnectUsesRenderedAuthority$' -count=1
Result: passed, including bound Pod updates, reassignment rejection, stale Node topology and a missing Node.

Command: go -C app/cetirun-operator test -tags=envtest ./internal/controller ./internal/admission -run '^Test(CommonCustom(TerminalAPIServer|APIServer)|PodAdmissionAPIServerBoundaries)$' -count=1 -timeout=5m
Result: passed. The local API server applied topology labels at binding; current bound updates passed and forged topology failed. The first test-fixture attempt correctly failed because the Operator cannot bind Pods; the test now uses its existing API-server administrator for the scheduler operation, without granting the Operator new permissions.

Command: go -C app/cetirun-operator vet ./internal/sandboxworkload ./internal/admission ./internal/controller
Result: passed.

Command: go -C app/cetirun-operator build ./...
Result: passed.

Command: make docs-check
Result: passed, including 43 generated HTML pages and source headers.

Command: git diff --cached --check
Result: passed.

Not run: a new full Operator suite for this focused follow-up; affected package suites and targeted integration checks are listed above. Patched live terminal/lifecycle acceptance is still pending.

Authorized live evidence before the repair: both Custom main containers became ready with their requested runtime classes and no restarts, while their separate terminals received CONNECT rejections. The additional Pod fields were the scheduler's region/zone labels. Both failed attempts were retained and their Agents/namespaces were subsequently removed through ordinary owner deletion. No protected Agent admin exec, port-forward, finalizer stripping or forced volume detach was used. No private diagnostic bundle is attached.

Compatibility and operational impact

No CRD, dependency or RBAC expansion. Admission already has read-only Node access. Initial Pod creation still uses the exact approved template; bound updates and terminal targets additionally verify the two standard topology labels against the assigned Node. Missing or terminating Nodes fail closed.

This is not physical fencing or unavailable-node failover. Existing immutable placement, template pins and terminal caller/target restrictions remain in force. Maintainer review and the new PR's CI/CLA checks are still required.

Checklist

  • The change is focused and preserves unrelated work.
  • Tests cover the changed behavior, or I explained why no new test is needed.
  • Documentation and examples match any public behavior changes.
  • Generated artifacts were updated from source, or none are affected.
  • Dependency changes include lockfiles, source attribution, and license information, or none are affected.
  • I checked the diff and attachments for secrets, private endpoints or identifiers, customer data, agent conversations, and internal information.
  • I followed the applicable CLA instructions, or asked a maintainer about an unclear check.
  • I identified checks that need credentials or a live environment and did not run them without authorization.

FumingZhang and others added 4 commits October 29, 2026 06:58
Reuse the common executor for governed Custom creation, retained lifecycle, typed Gateway and network controls, private Chat and isolated terminal access. Preserve image entrypoints and non-root identities while retaining existing managed and non-Sandbox behavior.\n\nInclude generated policy schemas, Portal wiring, static probe packaging and offline regression coverage. Keep unsupported identity, mTLS and desktop combinations fail-closed and document the live qualification boundary.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Retain Custom ingress and terminal contracts alongside native identity pinning and expectation validation. Update the Entra renderer tests for the shared validation signature and preserve fail-closed handling of unsupported Custom Entra projection.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Yield to the Node scheduler within act before arming the window access trap. Preserve the stale-dispatch negative control and late Chat completion assertions without retries or a longer timeout.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reuse assigned-Node topology verification for rendered Pod updates and Custom terminal CONNECT. Keep exact template checks and reject changed placement, stale topology, and unavailable Nodes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@feiskyer Pengfei Ni (feiskyer) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from feat/custom-sandbox-runtime to main October 29, 2026 23:19
Resolve #359 post-squash conflicts while preserving assigned-Node topology validation, regression coverage, and current main changes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@FumingZhang
FumingZhang merged commit 9f61f2a into main Oct 30, 2026
33 checks passed
@FumingZhang
FumingZhang deleted the fix/custom-terminal-topology branch October 30, 2026 01:11
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.

2 participants