Skip to content

feat: Attach Machine interfaces through NSO on custody - #198

Open
scotwells wants to merge 3 commits into
feat/manual-inventory-recordsfrom
feat/machine-network-attachment
Open

scotwells wants to merge 3 commits into
feat/manual-inventory-recordsfrom
feat/machine-network-attachment

Conversation

@scotwells

@scotwells scotwells commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

A Machine's requested network interfaces are now checked before any capacity is reserved, attached through NSO with one interface claim each on the switch port Device inventory names, and reported on the Machine with their addresses and a NetworkReady condition. Release waits until NSO drops every claim. NSO has no physical attachment mode and no network-use authorizer exists, so every mode still refuses interfaces. Stacked on #197, beside #216.

Related to #186

How it stays inactive

Nothing wires a network owner: no binary or configuration sets one, and with none every interface request is refused before anything is reserved. Machines that request no interfaces behave as before. On staging, a Machine that requests interfaces now stays Pending with nothing reserved, instead of being rejected outright. The allocation gains an optional status field, so no existing object becomes invalid.

Decisions for a person

  • NSO and Networking must accept the asks in docs: Propose NSO-owned server networks #186: a physical attachment mode, an attachment point on the claim, provider-only claim placement and a physical realizer.
  • Network-use authorization of the admitted principal through Milo has no implementation, and Fleet's IAM grants on interface claims in consumer projects are not defined.
  • The manager now watches NSO's interface claims in every project control plane. It already watches NSO's networks there, so the CRDs should be served, but someone who owns those control planes should confirm the claims CRD and the manager's read access before this lands.
  • feat: Attach boot NICs through NSO, off by default #225 models the attachment point separately for boot NICs. Pick one model and the order: land this first and rebase feat: Attach boot NICs through NSO, off by default #225, or restack this onto feat: Attach boot NICs through NSO, off by default #225.
  • Once attachment is on, an interface whose cabling inventory cannot resolve is found only after capacity is reserved, and nothing retries it when the inventory is fixed. Both need fixing before any site enables attachment.
  • Before any environment enables attachment: a least-privilege role for creating, reading and deleting interface claims in consumer projects, in its own component no overlay includes, and a decision on whether network use is checked again when the claim is made, not only before allocation.

Test plan

  • A Machine interface attaches through NSO's API with a test realizer, and its status shows the MAC, MTU and addresses
  • Release keeps the network and address gates open until every claim is gone
  • Interfaces without a network owner keep a Machine Pending with nothing reserved, and the network check refuses another tenant's Network and fails closed with no authorizer or principal
  • Every gh pr checks entry green on the head, including the multi-plane acceptance

🤖 Generated with Claude Code

@scotwells
scotwells requested review from ecv and kevwilliams November 25, 2026 16:49
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from 02cfd99 to a67a47f Compare November 25, 2026 17:14
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch from 16556dd to d694700 Compare November 25, 2026 17:14
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from a67a47f to 7133e23 Compare November 25, 2026 17:30
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch from d694700 to 7ab592b Compare November 25, 2026 17:30
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from 7133e23 to 8c40a8a Compare November 25, 2026 20:37
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch 2 times, most recently from 0d5fc23 to e939ed4 Compare November 25, 2026 22:08
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from 54b52eb to c1d66c7 Compare November 25, 2026 23:11
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch from e939ed4 to 5bd598d Compare November 25, 2026 23:11
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from c1d66c7 to f360646 Compare November 26, 2026 00:05
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch from 5bd598d to a9fc017 Compare November 26, 2026 00:05
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from 6bc39b4 to ff91454 Compare November 28, 2026 23:14
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch from a9fc017 to be930e8 Compare November 28, 2026 23:38
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from ff91454 to f417f2d Compare November 29, 2026 01:20
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch from be930e8 to 667870c Compare November 29, 2026 01:20
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from f417f2d to ce8b479 Compare November 29, 2026 02:03
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch 2 times, most recently from 55ab503 to d9dcabb Compare November 29, 2026 02:15
@scotwells scotwells added the multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners label Nov 29, 2026
@scotwells
scotwells marked this pull request as ready for review November 29, 2026 02:59
@scotwells
scotwells requested a review from a team as a code owner November 29, 2026 02:59

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Request changes.

Nothing is wired (no Mode, no Authorizer, nil Network refuses every interface before anything is reserved), and the attach and release paths look right, but the tenancy and authorization guards in nso.Adapter.Check have no test that fails when they are removed. That is the guard that stops one tenant attaching a server to another tenant's Network the moment NSO gets a physical mode and someone sets Mode, so it should be pinned first.

  • Removing reference.Namespace != machine.Namespace (the cross-tenant Network refusal) leaves go test ./internal/network/... ./internal/allocation/ ./internal/staging/ green. Add a Check case that names a Network in another namespace and expects ErrUnauthorized.
  • Removing a.Authorizer == nil || principal == "" (the fail-closed default) also leaves everything green; the allocation tests set Mode and an authorizer together. Add cases for nil authorizer, empty principal, and an authorizer that denies.
  • Guards that did fail when removed: the Mode == "" refusal, the call to AuthorizeNetworkUse (TestMachineInterfacesAttachThroughNSO), the claim-UID adoption check (TestEnsureAdoptsOnlyFleetsOwnClaim), and the network gate in Release (allocation tests).

On the deletion (-1440): internal/network/contracts.go (the Plan/Lifecycle/UseAuthorizer contract) and the old adapter and its 689-line test are replaced by network.go and a smaller adapter. Nothing else imports the removed identifiers (go-test passes on all planes), and Check and Ensure now take over what the old UseAuthorizer did. Attachment happens only for an Active allocation, and Machine interface inputs are immutable on the CRD (allocation inputs are immutable), so a later edit cannot skip Check. Release closes the Network and Address gates only after every recorded claim is gone, before wipe, and stalls with ErrUnsupported if the owner is unset but claims are recorded.

Follow-ups:

  • Fleet needs RBAC to create and delete interface claims and read them in consumer projects; the body says it is undefined. Add a least-privilege Role in its own non-included component, as #194 did for IPAM, before any environment enables attachment.
  • The manager now watches NetworkInterfaceClaim in every project control plane; confirm the CRD is served everywhere first, as the body asks, or the watch may fail startup in a project without it.
  • AuthorizeNetworkUse runs only in Check, before allocation. If the authorizer's answer can change while the Machine lives, re-check at Ensure.
  • A cabling-inventory miss is found only after capacity is reserved and is never retried (already listed in the body); resolve Locate in CheckNetwork so it fails before reserving.

@scotwells
scotwells requested a review from ecv November 29, 2026 04:32
@scotwells scotwells added multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners and removed multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners labels Nov 29, 2026

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve.

The new commit pins both guards from my hold: an interface on a Network in another namespace is refused even when the authorizer would allow it, and a missing authorizer, an empty principal and a denying authorizer each refuse with ErrUnauthorized. Test-only; the rest is unchanged since d9dcabb.

@scotwells
scotwells requested a review from ecv November 29, 2026 05:51
@scotwells

Copy link
Copy Markdown
Contributor Author

Thanks. At 0699b57, a new test pins both guards in the network check: an interface on another tenant's Network is refused even when the principal may use it, and so is every interface with no authorizer, no principal or an authorizer that denies. Removing either guard now fails the test.

The follow-ups are in the body as decisions before any environment enables attachment: a least-privilege role for interface claims in its own component, re-checking network use when the claim is made, confirming the claims CRD is served in every project control plane, and resolving the cabling before capacity is reserved.

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Still approved at 0699b57: nothing has changed since my last review.

scotwells and others added 3 commits November 29, 2026 00:46
Replace the unwired NSO adapter. The Metal provider checks each Machine
interface before allocation, records its attachment point from Device
inventory and cable records on the allocation, creates one NSO claim per
interface, and reports addresses and readiness on the Machine. Claim
events wake the Machine. Release closes the Network and Address gates
only once every claim is gone. NSO has no physical attachment mode, so
every mode still refuses interfaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Write NetworkReady=Unknown when NSO cannot be read instead of keeping a
stale True, record each proven claim UID before returning a later
interface's error, test that a claim event wakes only its Machine, and
document adoption risk, Retain, and a release stalled on a missing NSO
API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removing the check that keeps a Machine's interfaces on Networks in its
own namespace, or the check that refuses every interface when no
network-use check can run, left every test passing. A test now refuses
another tenant's Network, a missing authorizer, an empty principal and an
authorizer that denies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the feat/boot-network-site-dhcp branch from 283073c to 5617a92 Compare November 29, 2026 07:18
@scotwells
scotwells force-pushed the feat/machine-network-attachment branch from 0699b57 to cb55594 Compare November 29, 2026 07:19
@scotwells scotwells added multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners and removed multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners labels Nov 29, 2026
@scotwells
scotwells requested a review from ecv November 29, 2026 07:19

@ecv ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approve.

Rebase onto the merged power stack. The only change to this PR's commit is the staging handler merge: it keeps poweredOff (unset or Off) from the base and still drops the networkless requirement only when the allocator has a network owner. Intent unchanged.

Base automatically changed from feat/boot-network-site-dhcp to feat/manual-inventory-records November 29, 2026 09:01
@scotwells
scotwells requested a review from ecv November 29, 2026 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

multiplane-acceptance Run the multiplane acceptance suites on GitHub-hosted runners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants