Skip to content

feat(inventory): add the physical inventory API to Milo - #155

Merged
scotwells merged 8 commits into
mainfrom
feat/physical-inventory-api
Nov 24, 2026
Merged

scotwells merged 8 commits into
mainfrom
feat/physical-inventory-api

Conversation

@scotwells

@scotwells scotwells commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Adds the physical inventory API to Milo, so operators can record where a server is meant to go and which server is there. Recording either provisions nothing, publishes no capacity, and takes no ownership.

Related to #90. This is the first slice of that inventory feature branch to land on main. It also carries #153, so main never ships the old claim slots or inline cable peers. The staff UI, capacity registration, and the lab execution stack come in later PRs.

What changes

  • Nine kinds. Six physical record kinds: Facility, Rack, DeviceClaim, Device, Cable and PowerFeed. A hardware catalog of Manufacturer and DeviceType. An operational Site tied to the Facility it occupies.
  • Milo only. The Milo root registers the kinds, their protected resources, and four roles: viewer, editor, manager and importer. No consumer or metal role grants inventory access. The management cluster gets none of it.
  • Validation in the schema. Every claim is one installation with typed facility or rack placement that can't change, and Cable records alone say what connects to what. A Device's identity and the claim it belongs to can't change. It needs a serial, a system UUID, or an explicit marker saying neither is known. Ambiguous MAC addresses and BMC endpoints with credentials are rejected. Faceplate layouts are checked for overlaps, with a cap that keeps checks under the API server's cost limit.
  • No controller. Nothing reads these records yet.
  • Docs. An operator guide for recording a small installation, the hardware catalog contract, and the inventory proposal with its reference appendix.

The standalone CRD-only root stays for an environment that installed the CRDs on the management cluster before Milo became their home.

Test plan

  • Schema and API server tests cover every validation rule and the faceplate cost cap against Kubernetes 1.37
  • Role tests check every grant, and that only the Milo root installs the kinds
  • Full suite passes with the race detector, and manifest renders, isolation, doc link and whitespace checks pass
  • The Docker build-context check passes in CI

🤖 Generated with Claude Code

scotwells and others added 2 commits November 23, 2026 16:31
Add the fleet.datumapis.com/v1alpha1 inventory kinds: Facility, Rack,
DeviceClaim, Device, Cable and PowerFeed, the Manufacturer and DeviceType
hardware catalog, and the observational Site. config/milo registers their
CRDs, ProtectedResources and the viewer, editor, manager and importer
roles; the management-cluster roots install none of them.

The records are operator-written and observational. No controller reads
them, and creating one provisions nothing, publishes no capacity and
establishes no readiness. CEL keeps Device identity and claim binding
immutable, rejects ambiguous MACs and credential-bearing BMC endpoints,
and validates faceplate layouts within the per-call cost limit.

config/inventory renders the CRDs alone for an environment that installed
them on the management cluster before Milo became their home.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add the operator guide for planning and registering devices, the hardware
catalog contract, and the inventory proposal and reference appendix, and
index them from the configuration, architecture, development and
operations guides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells requested a review from a team as a code owner November 23, 2026 22:32
@scotwells
scotwells requested review from ecv and kevwilliams November 23, 2026 22:32
ecv
ecv previously approved these changes Nov 23, 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. Nothing deploys on merge: production pins fleet-kustomize by digest, and staging runs the feature-branch bundle. The four roles grant only explicit fleet.datumapis.com/<plural>.<verb> strings, and TestInventoryRolesSplitReadFromWrite fails if a verb is added. No customer role reaches the records: Milo's built-in roles carry no fleet grants or wildcards, and the only bindings are staff, the managers group and netbox-provider, all on project datum-cloud. The CRD matches the copy netbox-provider vendors.

Follow-ups:

  • fleet#139 is present here: importer patch can change records another writer created. The next production pin bump puts that in production Milo, so close #139 first, or name non-forced SSA as the client contract.
  • fleet#153 hasn't landed, so main gets the legacy placement text, ports[].expectedPeer and cable interfaces[].peer. Removing them later breaks v1alpha1 for netbox-provider. Land #153 before the production pin moves.
  • The BMC rule only blocks userinfo. ?token= in the query or path passes. Reject query, fragment and path, or say it isn't a secret guard.
  • The inventory roles sit in Milo's assignable namespace, so a customer org holder can bind them on their own projects. That doesn't reach Datum's records, but say whether it's intended, or keep the roles out of that namespace.

scotwells and others added 3 commits November 23, 2026 17:20
Fleet keeps no legacy physical-inventory shapes. Every DeviceClaim is now
a typed installation:

- spec.lifecycle is required and only Installation.
- spec.placement.scope is required; the text placement.facility and
  placement.rack fields are gone.
- spec.ports, ExpectedPort and PortPeer are gone. Cable records are the
  only topology authority.
- Device interfaces lose peer and keep name and macAddress.

The CEL rules that only separated legacy from typed claims are deleted.
Scope/reference agreement, the RackUnits position/height/face rule and
immutable placement now apply to every claim. The DeviceClaim printer
columns show scope and the facilityRef/rackRef names.

Existing legacy-shaped objects fail validation on update and must be
deleted or re-imported; there is no migration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Remove the legacy slot example, the legacy text placement and inline
peer descriptions, and the compatibility decision. Document the required
lifecycle and scope and immutable placement. Point the proposal
comparison at the implemented types instead of a pinned old revision.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Describe record ownership generically instead of naming a deployment's
GitOps object and path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells scotwells changed the title Add the physical inventory API to Milo feat(inventory): add the physical inventory API to Milo Nov 23, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@kevwilliams kevwilliams 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.

Hold: bmc.endpoint accepts secrets in the query, path or fragment, readable by every inventory viewer.

  • The rule rejects only @, so https://bmc/redfish?token=x and https://bmc/#pw=x are admitted; tightening after records exist breaks them on their next update.
  • Fix: also reject ? and # (via url(self).getQuery() / contains('#')).
  • Test: add query and fragment cases to TestInvalidDevicesAreRejected.

scotwells and others added 2 commits November 24, 2026 08:55
The endpoint rule rejected only userinfo, so a token in the query,
path, or fragment was admitted and readable by every inventory viewer.
Tightening it after records exist would break them on their next
update, so the endpoint is now an https host with an optional port and
nothing else.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The host may be a DNS name or a bracketed IPv6 literal and the port
must be digits, so a ';' suffix or an empty port is rejected. Tests now
also pin the endpoints that must stay admitted.

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

Copy link
Copy Markdown
Contributor Author

@kevwilliams the hold is fixed in 82569fe and 0f3d488:

  • bmc.endpoint now admits only an https host and an optional numeric port, with an optional trailing slash. The host is a DNS name or a bracketed IPv6 literal.
  • Credentials, a path, a query, a fragment, a ; suffix and an empty port are rejected. Each has a case in the invalid-device test.
  • A new test pins the forms that must stay admitted: an IP, a DNS name, a port, a trailing slash and IPv6.

@ecv this also covers the path case you raised. #153 is folded into this PR, so main never gets the legacy placement fields.

@scotwells
scotwells requested review from ecv and kevwilliams November 24, 2026 15:09

@kevwilliams kevwilliams 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.

Verified the anchored host-and-port rule rejects query, fragment, path, parameter and userinfo endpoints, each covered by a TestInvalidDevicesAreRejected case; only the two BMC commits changed.

@scotwells
scotwells merged commit ba5b6b3 into main Nov 24, 2026
9 of 10 checks passed
@scotwells
scotwells deleted the feat/physical-inventory-api branch November 24, 2026 15:09
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.

3 participants