Skip to content

feat(inventory): DeviceClaim and Device in Milo, with a staff portal view - #90

Draft
scotwells wants to merge 670 commits into
mainfrom
feat/manual-inventory-records
Draft

scotwells wants to merge 670 commits into
mainfrom
feat/manual-inventory-records

Conversation

@scotwells

@scotwells scotwells commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Update: Milo is the single home, plus a staff portal view

Registration in Milo. config/milo now includes config/components/inventory:

  • Both CRDs, annotated discovery.miloapis.com/parent-contexts: Project.
  • ProtectedResources fleet.datumapis.com-deviceclaim and -device. Their serviceRef is fleet.datumapis.com, because openfga-provider indexes ProtectedResources by {apiGroup}/{plural}. They grant no updateStatus.
  • Roles fleet.datumapis.com-inventory-viewer (get, list, watch) and -editor (inherits the viewer role and adds writes).

Access. No metal.datumapis.com role includes or inherits these roles, so consumer, claimant, viewer and provider roles grant no inventory access. Environments bind the inventory roles explicitly, scoped to the provider project. Records live in the provider project next to MachineCapacity, so deviceRef resolves by name. Neither management-cluster overlay installs the kinds.

config/inventory. It now renders only the component's CRDs, for the management-cluster install that predates the move. It is removed once that environment has cut over.

Staff portal. The provider plugin (ui/provider), the staff-portal Module Federation remote already deployed with Fleet, gains a read-only Inventory tab:

  • inventory lists DeviceClaims across namespaces with placement, expected model, bound Device and serial, and separately lists Devices whose claim is missing.
  • inventory/:namespace/:claim shows the claim's placement, expected ports and peers, and provenance. It also shows each bound Device's model, serial, system UUID, BMC endpoint, interfaces, unmapped MACs and provenance. The most recently recorded Device counts as current; earlier ones are labelled.
  • The plugin reads through staff-portal's Milo proxy with the staff member's token, so viewing needs the inventory viewer role. It has no write actions, and staff-portal needs no change.

Docs. The ops doc covers where records live, the roles, the portal, and a recorded deliberate divergence from #63: Milo-resident provider inventory, instead of #63's protected management-side ledger and "private inventory" stance.

Verification for 08d6dde.

  • CI is green: validate, standalone-smoke, both UI plugin jobs, and publish.
  • New IAM tests check ProtectedResource and CRD agreement, the read/write split, and that only config/milo serves the kinds with no metal role granting them. Plugin tests (14 new, 52 total) cover the list, detail, restricted, empty, unbound and replacement cases. The consumer plugin still passes.
  • The published bundle's milo render matches the source. The provider plugin image …-20261119-232706 contains the inventory pages.
  • In staging Milo, datumctl --project datum-cloud get deviceclaims.fleet.datumapis.com returns Forbidden, not "unknown resource type": the kinds are served and access is denied until the staff binding (infra) lands.

Problem and outcome

Operators need to record two things about real servers in Fleet: where a server is planned to go, and which physical server is actually there. Recording either must not provision the server, publish capacity, or take ownership. MachineCapacity.spec.deviceRef already names a Device, but the inventory kinds are only proposed (#63).

This PR implements a minimal, operator-written subset of #63 in fleet.datumapis.com/v1alpha1:

  • DeviceClaim: the plan for one slot. It holds facility, rack, position, height and face; the expected model, with an optional serial because the serial is usually unknown at plan time; and expected ports, each with its expected cable peer (device + port). The slot outlives any one Device.
  • Device: the actual asset, created by the registrar when detected hardware is bound to a claim. It holds claimRef (required, exactly one claim); identity (model, serial, SMBIOS system UUID, at least one of serial or UUID); an optional BMC endpoint; interfaces (name, MAC if known, observed peer); unmappedMACAddresses for detected MACs that can't yet be attributed to a port; and provenance.

Both kinds are operator-written, and neither has a controller. Registration authorizes no hardware effect and creates or changes no MachineCapacity. status is a reserved subresource with no fields and no writer; later only collectors and verifiers will write it, and never identity. Fleet has no knowledge of any external inventory system.

This replaces the earlier InventoryObservation design on this branch.

Validation (CRD schema + CEL)

Rule Kind
provenance requires method: Manual, recordedBy and recordedAt; reference is optional and opaque both
Every spec edit must set a later recordedAt both
claimRef is required and immutable Device
identity is immutable, including adding a missing field; a hardware swap is a new Device Device
Port and interface names are unique (list-map); MACs are lowercase, appear at most once, and are either mapped or unmapped, not both both
The system UUID is in lowercase canonical form Device
The BMC endpoint is https without credentials Device
Position and height are at least 1 (height defaults to 1); face is front or rear DeviceClaim

Field limits keep the MAC-uniqueness rule within the API server's CEL cost budget. CEL cannot check that a referenced claim exists; until a registrar enforces it, operators create the claim first.

Relationship to #63

Names and writers match #63:

  • DeviceClaim is the installation planner's plan.
  • Device is the registrar-created canonical asset; collectors never edit its identity.
  • Status is a protected projection.
  • Serial and SMBIOS UUID are matching evidence, not authenticators.
  • Placement uses facility, not site; Site is cluster placement policy.
  • Logical LAGs and VLANs are not ports.

Omitted and deferred to #63: Facility, Rack, Cable and PowerFeed kinds (facility and rack are names, and expected peers are inline until Cable exists); plan acceptance and reservations; identity adjudication; the ledger; trust profiles and enrollment challenges; evidence; component lineage; maintenance and retirement; verification predicates; and role separation.

Divergence to resolve in #63. The agreed convention here is that a whole-server replacement binds a new Device to the same DeviceClaim. #63's current text says a replacement also creates a new DeviceClaim. The schema enforces neither convention; the ops doc records the divergence.

MachineCapacity is unchanged. The allocator keys an asset as <namespace>/fleet.datumapis.com/Device/<deviceRef.name>. Devices are objects in exactly that group and kind, so a later supply step can reference one by name if both objects share a namespace.

Changes

  • internal/api/inventory/v1alpha1: types, scheme registration, deepcopy and CRD tests.
  • config/inventory/fleet.datumapis.com.yaml: both CRDs, in an opt-in root. They carry no Milo discovery annotation, no production root references them, and CI renders the root.
  • Docs: docs/operations/physical-inventory.md covers the model, validation, a synthetic example and what is deferred to docs: propose inventory lifecycle and trust #63. Status rows are updated in the architecture, development, operations and config guides.

Verification

  • go vet ./... and go test -race ./... pass.
  • The CRD tests run the API server's schema, list-type, defaulting and CEL validation offline, with the old object defaulted as stored objects are. They cover:
    • both CRDs passing definition validation, including the cost budget;
    • valid claims and Devices, a UUID-only Device, and the default height;
    • 8 rejected claim shapes and 14 rejected Device shapes;
    • unchanged, stale, backdated and advanced edits on both kinds;
    • immutability of claimRef, serial (changed, removed or added), UUID and model;
    • a replacement Device bound to the same claim;
    • status pruning everything.
  • A one-off, uncommitted envtest run checked the same rules on a real API server. It confirmed the height default, stale-edit, retarget and identity rejection, and acceptance of an advanced edit. It also confirmed rejection of http, credential-bearing and bare BMC endpoints, and of a MAC recorded both mapped and unmapped.
  • All ci.yml kustomize roots render. The synthetic-staging, overlay-isolation, standalone, Milo validate and multiplane harness checks pass, and doc links pass.
  • Not run locally: the Docker build-context test (no daemon). Not verified: any deployed cluster. Fixtures are synthetic.

🤖 Generated with Claude Code

@scotwells
scotwells force-pushed the feat/manual-inventory-records branch from e8317b9 to f735b9c Compare November 19, 2026 21:43
@scotwells scotwells changed the title feat(inventory): accept operator-recorded inventory observations feat(inventory): add operator-written DeviceClaim and Device Nov 19, 2026
@scotwells
scotwells force-pushed the feat/manual-inventory-records branch from f735b9c to c6f1fb2 Compare November 19, 2026 22:02
@scotwells scotwells changed the title feat(inventory): add operator-written DeviceClaim and Device feat(inventory): DeviceClaim and Device in Milo, with a staff portal view Nov 19, 2026
@mattdjenkinson

Copy link
Copy Markdown
Contributor

@scotwells could you rebase feat/manual-inventory-records onto fleet's main when you get a chance?

Staging's fleet follows this branch's bundle (v0.0.0-feat-manual-inventory-records, per infra's apps/fleet-system/staging). The branch is 2 commits behind main, so it's missing #92, which replaced the staging setup fees with the service catalog's Bare Metal products (bare-metal-b300-committed-v1, bare-metal-server-setup-v1). Now that datum-cloud/infra#9445 enables service-catalog-staging on staging, fleet-milo-configuration has applied the five old setup fees from this branch, and the two new pricings aren't there.

After the rebase, staging should pick up the new pricings within a few minutes. The five old fees will stay, since the Kustomization doesn't prune. I'll clear those up separately; nothing uses them yet.

@scotwells
scotwells force-pushed the feat/manual-inventory-records branch from 08d6dde to 42086bb Compare November 20, 2026 16:53
@scotwells
scotwells changed the base branch from pxe/boot-network to main November 20, 2026 16:54
@scotwells

scotwells commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@mattdjenkinson Thanks for flagging this—updated as requested.

scotwells and others added 10 commits November 28, 2026 14:01
The local VM commissioning worker timed burn-in from the guest's start
to the journaled verdict, so a slow network boot or a worker restart
after an early receipt could make a short burn-in pass. It now uses the
Redfish worker's rules through a shared burnin package: burn-in starts
the second after the boot server's last delivery and ends at the last
stored sighting of the console without the receipt. A site that boots
its guest directly has no delivery log, so it refuses commissioning.

A short burn-in no worker watched end, because a restart fell inside
it, now fails with its own mismatch so staff know a re-run may pass.

Related to #196

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The manager's leader election records each lease change as a core Event
in fleet-system, and the API server refused it: the fleet-manager
service account could only manage its lease there. The leader-election
Role now also grants create and patch on core events in that namespace.
Patch is what the recorder uses when the same change repeats.

TestLeaderElectionCanRecordEvents reads the Deployment, the Role and
its binding, and requires the service account, in the namespace that
holds its lease, to manage the lease and record those Events.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat(bmc-discovery): Record the reset actions each BMC offers
…events

fix(manager): Let leader election record Events
An omitted resetTypes meant both "the BMC offers none" and "the read
failed". The field now uses omitzero, so an empty advertised list,
inline or from the ActionInfo, is stored as []. The previous omitempty
tag dropped it on every marshal, including the Device's JSON deep copy.
An omitted list now always means unknown.

A new ResetTypesRead condition reports why the list is unknown:
ResetActionMalformed, ActionInfoNotFound, ActionInfoUnreadable,
ActionInfoMalformed or TooManyResetTypes. More than 16 distinct types
is now unknown instead of a truncated list, which would refuse a type
the BMC offers. Discovered and the rest of the inventory are unchanged,
and a rejected credential still fails the whole read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A reset type list of only blank or null values was stored as an empty
list, which reads as "offers none" and would refuse every action. It is
now unknown with ResetActionMalformed. A truncated ActionInfo body is
ActionInfoMalformed rather than unreadable. The True ResetTypesRead
message and the docs now say it means no read failed, not that a list
was recorded.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fix(site): Time local VM burn-in from image delivery
An empty resetTypes list cannot be told from an omitted one: the field
is omitempty, and pruning, apply and other clients do not keep an
empty list reliably. resetTypes goes back to #181's tag unchanged.

A per-System resetTypesObserved boolean is now true only when this read
got an advertised list, inline or from the ActionInfo, even an empty
one. A failed read, a System that advertises no list, a list of only
blanks or more than 16 types leaves it absent, so the types are
unknown. ResetTypesRead keeps explaining failures for operators.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An empty inline reset list next to an ActionInfo without ResetType
values was observed as an empty list, which power reads as offers none
and would refuse every action. With an ActionInfo, only its values now
count, so that case is unknown and the live BMC check decides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each requester claims an IPAM address before it creates an installation
or wipe and carries it in the operation's boot network input. Admission
refuses an address its claim no longer holds. The site publishes the
admitted snapshot's boot MAC at that address only while the boot is
open, records publishing as a sent step, and succeeds only when no DHCP
instance still serves any reservation of the Device. Claims are released
only after their operation ended unheld. Site enrollment no longer names
MACs or provisioning addresses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scotwells and others added 26 commits November 30, 2026 11:05
Complete serial-only Device UUIDs from live discovery without per-host configuration
Route enrolled physical Devices through the provider custody coordinator
feat: Own reusable isolated DHCP configuration in Fleet
Prepare isolated DHCP producer runtime and proof tools
feat(ui): use datum-ui Badge, ButtonGroup and Spinner in inventory
Design Device-owned host networking and immutable installation snapshots
…oning

Add identity-bound commissioning and fence-only recovery
@cla-assistant

cla-assistant Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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