Skip to content

feat: Add a simulated switch realizer for physical claims - #968

Draft
scotwells wants to merge 2 commits into
feat/physical-port-holdsfrom
feat/physical-test-realizer
Draft

scotwells wants to merge 2 commits into
feat/physical-port-holdsfrom
feat/physical-test-realizer

Conversation

@scotwells

Copy link
Copy Markdown
Contributor

Summary

Physical claims bind and hold their port, but nothing yet changes a switch port, so no physical claim could ever report that its port carries its network. This adds a test realizer that programs a simulated switch, off by default, so NSO's tests and Fleet's can run a server attachment and a boot-to-customer handover end to end without real switches.

It follows the design's four safety rules: it withdraws Programmed before changing a port, counts a change only once the port reads back, rechecks for deleted claims after each change, and never removes a finalizer it cannot prove. Interfaces and claims now report the VLAN each network arrives on, and a periodic sweep clears any port no hold names.

Decisions for a person

  • The realizer that programs real switches is still the Networking team's to build against this contract, as listed on the design pull request.

Test plan

  • A port never carries two projects' networks, or the boot network with a customer's, at any step of an install, handover, reinstall or wipe
  • A failed, partial or unreadable switch change keeps every finalizer and converges once the switch recovers
  • A port whose hold disappears is cleared, and a surviving network keeps its VLAN
  • Tests, lint, generated files and kustomize builds pass locally the way CI runs them

Related to #963

🤖 Generated with Claude Code

@scotwells
scotwells requested review from ecv and kevwilliams November 26, 2026 06:29
scotwells and others added 2 commits November 26, 2026 16:16
NSO's tests, and any team's, can now run a physical attachment end to end.
The test realizer programs a simulated switch from each SwitchPortHold and
follows the realizer contract: it carries a boot claim's network alone and
untagged, moves a port in one change, withdraws Programmed before changing a
port, counts a change only once it reads it back, and removes the detach
finalizer only once the port no longer carries the claim's network. It runs in
a cell only when explicitly enabled.

Key changes:
- add vlanID to the interface and claim status for the VLAN a physical
  network arrives on
- add the physicalrealizer package: a one-port switch driver, an in-memory
  simulated switch with failure hooks and a change history, and a reconciler
  keyed by SwitchPortHold that reads holds and claims from the API server
- add physicalRealizer.enabled and driver to the cell config, off by default
- add PortChanging, BootAttachmentActive, PortCarriesNetwork and
  AttachmentPointAccepted to the API and the network-agent catalog
- cover handover, release, a claim deleted mid-change, partial and failed
  changes, unreadable switches, failed withdrawals and port safety with
  envtest through the real claim controller

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of the test realizer found that a port could keep a network after its
hold vanished, that VLANs moved when another claim left, and that the project
copy of an interface dropped its VLAN.

Key changes:
- sweep every port no hold names, on start, every 30 seconds and whenever a
  hold is gone, withdrawing its claims before clearing it; the realizer runs
  with one worker so the sweep and per-hold passes never race on a port
- refuse a hold whose name is not its port's, and let it protect no port
- tag every network claim on a VLAN hashed from its network, probed in name
  order, so a surviving claim keeps its VLAN
- copy vlanID to the project copy of an interface
- drop the unused PortUnverified reason
- warn at startup that the simulated realizer programs nothing real, and log
  failed changes, mismatched read-backs, kept finalizers and swept ports
- check port safety before every change in the tests, and cover the sweep,
  the name check, VLAN stability and NSO's status writes keeping what the
  realizer reports

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/physical-test-realizer branch from f709d35 to 81f1511 Compare November 26, 2026 22:22
@scotwells
scotwells force-pushed the feat/physical-port-holds branch from ccdc09f to f26e1b2 Compare November 26, 2026 22:22
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