Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/components/inventory/roles/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ kind: Kustomization
resources:
- viewer.yaml
- editor.yaml
- manager.yaml
30 changes: 30 additions & 0 deletions config/components/inventory/roles/manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: iam.miloapis.com/v1alpha1
kind: Role
metadata:
name: fleet.datumapis.com-inventory-manager
annotations:
kubernetes.io/display-name: Fleet Inventory Manager
kubernetes.io/description: Create and maintain physical inventory records without deletion or operational control
spec:
launchStage: Alpha
inheritedRoles:
- name: fleet.datumapis.com-inventory-viewer
includedPermissions:
- fleet.datumapis.com/deviceclaims.create
- fleet.datumapis.com/deviceclaims.update
- fleet.datumapis.com/deviceclaims.patch
- fleet.datumapis.com/devices.create
- fleet.datumapis.com/devices.update
- fleet.datumapis.com/devices.patch
- fleet.datumapis.com/facilities.create
- fleet.datumapis.com/facilities.update
- fleet.datumapis.com/facilities.patch
- fleet.datumapis.com/racks.create
- fleet.datumapis.com/racks.update
- fleet.datumapis.com/racks.patch
- fleet.datumapis.com/cables.create
- fleet.datumapis.com/cables.update
- fleet.datumapis.com/cables.patch
- fleet.datumapis.com/powerfeeds.create
- fleet.datumapis.com/powerfeeds.update
- fleet.datumapis.com/powerfeeds.patch
251 changes: 251 additions & 0 deletions docs/development/staff-inventory-ui.md

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions docs/operations/netbox-physical-import.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

Start with [manual entry and operator review](physical-inventory.md#manually-record-a-small-installation).
Physical inventory needs neither NetBox access nor a bulk importer. Operators
write and review records individually; Flux remains the sole staging writer.
write and review records individually. New/imported records may use approved
direct API creation; existing Flux-owned records retain that writer until an
explicit reviewed ownership transition.

This guide covers **optional, explicitly invoked review aids**: a GET-only snapshot
command and offline candidate generation. They help compare an existing source
Expand Down Expand Up @@ -191,7 +193,7 @@ source comparison when separately requested and authorized by the operator.
namespace. Use the project's established authenticated GET/list path; do not
assume a management-cluster context addresses Milo. The envelope is an operator
attestation, not cryptographic proof of scope or freshness. Retain capturedAt and
read evidence privately; re-read before a GitOps merge.
read evidence privately; re-read before any approved creation or source merge.
5. Run `plan` with private `--snapshot`, `--mapping`, `--existing` and a fresh output
directory. Add `--previous` with the earlier source snapshot on subsequent runs.
Review source disappearances: missing rows are **retained**, never deleted,
Expand All @@ -200,17 +202,20 @@ source comparison when separately requested and authorized by the operator.
6. Obtain explicit approval for the mapping, exact target and desired cohort.
Only then generate a handoff. Do not put private exports or imported asset facts
in a public Fleet PR. Do not apply the candidate List directly to Milo.
7. Stage individual **new** records additively in the existing private
`provider-inventory` Flux source. Preserve all existing files and object names;
never replace the collection with this partial candidate list. Review the Git
diff for no deletes, no modifications of existing bindings, no capacities and
no readiness/status. Retain source/mapping/report/receipt in the approved private
evidence store. The importer does not commit, push, merge or roll out this change.

Flux remains the only writer for staging provider-inventory records. This avoids
the conflict that a direct importer would create with reconciliation. Reviewers
must check for concurrent changes since the Fleet snapshot; the offline handoff
does not provide an optimistic-concurrency apply transaction. After an interrupted
7. Use the explicitly approved writer for individual **new** records. A separately
authorized one-time API creation must be additive, reject existing names rather
than overwrite them, and retain per-record receipts for recovery. Alternatively,
if Flux ownership is chosen for those new records, stage them additively in the
private source. Preserve existing files, identities and bindings; never replace
the collection with this partial candidate list. Review exact inputs for no
deletes, modifications of existing bindings, capacities or readiness/status.
Retain source/mapping/report/receipts in the approved private evidence store.
This offline importer itself does not execute API writes, commit, push or deploy.

Flux remains the writer for records it already owns; direct creation of new records
does not authorize editing or taking over that cohort. Reviewers must check for
concurrent changes since the Fleet snapshot; the offline handoff does not provide
an optimistic-concurrency apply transaction. After an interrupted creation or
reconciliation, refresh the Fleet snapshot and rerun. Matching records become
no-ops; conflicts stay quarantined. Do not roll back by deleting occupied objects.

Expand Down
47 changes: 38 additions & 9 deletions docs/operations/physical-inventory.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ take ownership of it.
This package implements a minimal subset of the
[inventory lifecycle and trust proposal (#63)](https://github.com/datum-cloud/fleet/pull/63).
It now has six operator-written kinds in `fleet.datumapis.com/v1alpha1`.
The primary workflow is **manual entry, operator review, and explicit GitOps
ownership**. NetBox, bulk conversion, and a source reconciliation service are not
The primary workflow is **manual entry, operator review, and explicit record
ownership**. Authorized direct API creation is supported for new/imported records;
legacy Flux-owned records require a reviewed ownership transition before edits
by another writer. NetBox, bulk conversion, and a source reconciliation service are not
required. The [optional NetBox comparison guide](netbox-physical-import.md)
describes a separately invoked review aid, not an automated migration.

| Kind | What it is | Writer |
| --- | --- | --- |
| `DeviceClaim` | An observational installation plan with expected model and known placement. New records use typed placement and Cable references; existing long-lived slots retain their legacy representation. | Installation planner, through the existing GitOps writer |
| `DeviceClaim` | An observational installation plan with expected model and known placement. New records use typed placement and Cable references; existing long-lived slots retain their legacy representation. | Installation planner, through the record's explicitly assigned writer |
| `Device` | One actual asset, bound to exactly one DeviceClaim when detected hardware is registered. It carries the serial and SMBIOS system UUID, the model, an optional BMC endpoint, interfaces, and provenance. | The registrar (an operator, for now) |
| `Facility` / `Rack` | Explicit premises and rack definitions; membership is not free-capacity evidence. | Inventory operator through the environment's existing writer |
| `Cable` / `PowerFeed` | Typed termination/lane topology and physical supply dependencies. | Inventory operator through the environment's existing writer |
Expand All @@ -28,8 +30,8 @@ describes a separately invoked review aid, not an automated migration.
| Aspect | State |
| --- | --- |
| CRDs and Go types | Implemented in `config/components/inventory` and `internal/api/inventory/v1alpha1`. |
| Home | Milo. `config/milo` registers six CRDs, six ProtectedResources and two IAM roles. Management and synthetic-staging overlays install none of them. |
| Staff portal | Read-only **Inventory** tab in the Bare Metal provider plugin (`ui/provider`): a claim list and a per-claim detail page. |
| Home | Milo. `config/milo` registers six CRDs, six ProtectedResources and three IAM roles. Management and synthetic-staging overlays install none of them. |
| Staff portal | Six-kind hardware directory in the Bare Metal provider plugin (`ui/provider`), with permission-aware browsing and limited authorized Facility/Rack creation and portal-owned name edits. See [implementation scope](../development/staff-inventory-ui.md). |
| Tests | Unit tests run API-server schema, list-type and CEL validation offline for the six kinds and synthetic importer output. IAM tests check ProtectedResource and role shape and that no metal role grants inventory access. Plugin tests cover browse/detail, partial placement, reconciliation, restricted, pagination and empty states. |
| Controllers | None for inventory. Staff browsing is read-only; no reconciler accepts plans, verifies hardware, discovers or synchronizes NetBox, or publishes eligibility. Flux applies only operator-reviewed Git records. |
| Hardware qualification | None. Records hold operator-entered facts, not verified hardware state. |
Expand Down Expand Up @@ -66,13 +68,37 @@ project control plane serves the kinds. Access is what keeps consumers out:
| --- | --- |
| `fleet.datumapis.com-inventory-viewer` | `get`, `list`, `watch` on all six physical kinds |
| `fleet.datumapis.com-inventory-editor` | The viewer role plus `create`, `update`, `patch`, `delete` |
| `fleet.datumapis.com-inventory-manager` | The viewer role plus `create`, `update`, `patch`; no deletion or status writes |

No `metal.datumapis.com` role includes or inherits either. The consumer,
No `metal.datumapis.com` role includes or inherits any inventory role. The consumer,
claimant, and viewer roles that reach customer projects therefore grant no
inventory access, and the provider role does not either. Bind the inventory
roles explicitly, scoped to the provider project. No role grants status
writes, because status has no writer yet.

The manager is a separate least-privilege role for explicitly authorized inventory
staff; it does not change the existing editor or give staff viewers write access.
It grants only the six physical kinds, never hardware operations, allocation,
installation, Metal, networking, billing, or IAM administration. Fleet owns this
role and its tests; environment-specific groups and project bindings belong in
the infrastructure repository. The role ships through `config/milo`; shipping a
role does not bind it or add members in any environment.

A Project resource selector is project-wide, not a namespace filter. These
ProtectedResources have Project parents, and a binding's `metadata.namespace`
locates the IAM object, not the inventory it authorizes. Choosing `default` in a
portal request is a convention, not isolation from other namespaces in that
project. Require a separately supported and tested authorization boundary before
promising namespace-only access.

The manager contract is validated offline with
`go test ./internal/api/inventory/v1alpha1`. That checks manifests, not deployed
authorization. Before adding named members, an environment owner must validate
the deployed role and binding, and explicitly decide record-writer ownership.
IAM capability does not transfer ownership away from Flux or permit two writers
for the same records. Existing GitOps-owned records remain GitOps-owned until a
separate reviewed transition; this role does not perform that transition.

The ProtectedResources use `serviceRef: fleet.datumapis.com`. The authorization
provider looks resources up by `{apiGroup}/{plural}`, so the service name must
equal the API group. No `fleet.datumapis.com` Service or ServiceConfiguration
Expand Down Expand Up @@ -274,9 +300,12 @@ explain why imports cannot delete/recreate or relabel legacy records to bypass t
## Applying the records

`config/milo` installs the CRDs, ProtectedResources, and roles into Milo. Apply
operator-reviewed records through the provider project's established GitOps
source after those are established, claims before the Devices that name them.
Do not apply directly to staging; Flux remains its only writer. Keep records with real serials,
operator-reviewed records through their approved writer after those are established,
claims before the Devices that name them. New or imported records may be created
directly through the provider API with authorization and ownership safeguards.
Existing Flux-owned records remain with Flux until a reviewed transition stops
reconciliation for those exact records. Do not overwrite or adopt them implicitly.
Keep records with real serials,
UUIDs, MACs, endpoints, or cabling in the environment's private configuration,
not in this repository.

Expand Down
51 changes: 37 additions & 14 deletions internal/api/inventory/v1alpha1/iam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,45 @@ func TestInventoryRolesSplitReadFromWrite(t *testing.T) {
for _, r := range decodeDir[role](t, filepath.Join(inventoryRoot, "roles")) {
roles[r.Metadata.Name] = r
}
viewer, editor := roles["fleet.datumapis.com-inventory-viewer"], roles["fleet.datumapis.com-inventory-editor"]
if len(roles) != 2 || len(viewer.Spec.Included) == 0 || len(editor.Spec.Included) == 0 {
t.Fatalf("want exactly the inventory viewer and editor roles, got %v", roles)
wantVerbs := map[string][]string{
"fleet.datumapis.com-inventory-viewer": {"get", "list", "watch"},
"fleet.datumapis.com-inventory-editor": {"create", "update", "patch", "delete"},
"fleet.datumapis.com-inventory-manager": {"create", "update", "patch"},
}
for _, permission := range append(slices.Clone(viewer.Spec.Included), editor.Spec.Included...) {
if !declared[permission] {
t.Fatalf("role permission %s has no ProtectedResource", permission)
}
}
for _, permission := range viewer.Spec.Included {
if verb := permission[strings.LastIndex(permission, ".")+1:]; verb != "get" && verb != "list" && verb != "watch" {
t.Fatalf("viewer grants %s", permission)
}
if len(roles) != len(wantVerbs) {
t.Fatalf("want exactly viewer, editor and manager roles, got %v", roles)
}
if len(editor.Spec.Inherited) != 1 || editor.Spec.Inherited[0].Name != viewer.Metadata.Name {
t.Fatal("editor must inherit the viewer role")
for name, verbs := range wantVerbs {
t.Run(name, func(t *testing.T) {
current, ok := roles[name]
if !ok {
t.Fatalf("missing role %s", name)
}
var expected []string
for _, resource := range []string{"deviceclaims", "devices", "facilities", "racks", "cables", "powerfeeds"} {
for _, verb := range verbs {
expected = append(expected, GroupVersion.Group+"/"+resource+"."+verb)
}
}
actual := slices.Clone(current.Spec.Included)
slices.Sort(expected)
slices.Sort(actual)
if !slices.Equal(actual, expected) {
t.Fatalf("%s permissions = %v, want %v", name, actual, expected)
}
for _, permission := range actual {
if !declared[permission] {
t.Fatalf("role permission %s has no ProtectedResource", permission)
}
}
if name == "fleet.datumapis.com-inventory-viewer" {
if len(current.Spec.Inherited) != 0 {
t.Fatal("viewer must not inherit additional permissions")
}
} else if len(current.Spec.Inherited) != 1 || current.Spec.Inherited[0].Name != "fleet.datumapis.com-inventory-viewer" {
t.Fatal("editor and manager must inherit only the viewer role")
}
})
}
}

Expand Down
53 changes: 33 additions & 20 deletions ui/provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A [staff-portal](https://github.com/datum-cloud/staff-portal) plugin for the
provider project's Bare Metal resources (`metal.datumapis.com`). It is a Module Federation remote: the
portal fetches `plugin-manifest.json` and `remoteEntry.js` server-side and
mounts its pages under `/plugins/<slug>/`, with a **Bare Metal** item under
Operations in the navigation. The page has three tabs:
Operations in the navigation. The page has four tabs:

- **Capacity** (the mount root, where the nav item points) lists the
provider's MachineCapacities in every namespace and creates new ones. The
Expand All @@ -20,16 +20,17 @@ Operations in the navigation. The page has three tabs:
profiles a class allows, the namespace and capacity-pool label of the
MachineCapacities that serve it, and whether consumers get power control. Custom
profiles and console access stay off.
- **Inventory** (`inventory`) is read-only. It lists the provider project's
DeviceClaims (`fleet.datumapis.com`) in every namespace, with each claim's
placement, expected model, bound Device and serial. Devices that name a
missing claim are listed separately. `inventory/:namespace/:claim` shows one
claim's planned placement, expected ports and peers, and provenance. It also
shows every Device bound to it: model, serial, system UUID, BMC endpoint,
interfaces, typed components, separate asset tags/provider IDs, unmapped MACs
and provenance. Multiple historical Devices keep the active binding Unknown;
edit time does not establish current hardware. Operators write through GitOps; the
plugin never writes them.
- **Inventory** (`inventory`) is a read-only hardware directory, starting with
Devices rather than installation claims. Six searchable categories cover
Devices, Facilities, Racks, Claims, Cables, and Power feeds. Query-string detail
links retain the kind, namespace, and record name without adding host routes.
Facilities lead to racks and installation plans; claims lead to all registered
devices; cable endpoints lead to devices or feeds. Identity, typed components,
internal paths, external service references, legacy peers, and provenance remain
visible. Missing claims do not hide hardware, and historical registrations do
not establish an active device. The original `inventory/:namespace/:claim`
route remains available for existing links. The plugin never writes inventory;
this is a UI limitation, not a requirement to manage inventory through Git.

The portal proxy forwards the staff member's own token, so creating capacity,
profiles and classes needs a Bare Metal role with `machinecapacities.create`,
Expand Down Expand Up @@ -87,15 +88,27 @@ to that array instead.

## Differences from the consumer plugin

The read-only Inventory tab now loads all six physical inventory collections
with pagination. It retains unknown placement and ambiguous historical bindings,
shows Facility/Rack/Cable/PowerFeed relationships and typed asset components,
and supports optional local-only review of source-comparison reports. Manual
inventory needs no NetBox or report; operators review the private Git source and
Flux is the sole staging writer. The portal never writes or synchronizes records. These reads require the
provider-scoped inventory viewer role, not a consumer Metal role. See the
[optional source-comparison guide](../../docs/operations/netbox-physical-import.md)
for the offline Flux handoff and the distinction between records and readiness.
The Inventory tab loads all six physical inventory collections with API pagination.
Counts describe loaded records, not capacity or verified equipment. Unknown
occupancy, power budgets, and ambiguous bindings stay unknown. Contextual help
explains these boundaries; there is no report picker, automatic import, sync, or
hardware action. Reads require the provider-scoped inventory viewer role, not a
consumer Metal role. Management separately checks backend create/patch permission
in the provider project: Facility/Rack creation and portal-owned display-name
editing only. The proposed `fleet.datumapis.com-inventory-manager` role and
`physical-inventory-managers` group binding are separate IAM work, not deployed
by this UI. Group names/staff membership never enable controls. Flux/imported
records remain read-only pending ownership review. Namespace choice is not an
authorization boundary. Denied collections and detail links show access guidance,
not empty inventory; readable sections remain available.
See [hardware directory scope and design gaps](../../docs/development/staff-inventory-ui.md).

The standalone harness imports `src/preview.css`, compiling the installed Datum UI
theme with Tailwind. That stylesheet is not imported by federated pages; the host
still supplies its design system. Inventory-specific CSS is scoped under
`.fleet-inventory` and shipped with the existing remote. No second app or host
navigation is introduced. Fixture mode includes all six inventory kinds with
explicitly synthetic identities and no verified state.

- staff-portal runs react-router 7, so this plugin pins it for types and
shares it with `requiredVersion: false`.
Expand Down
Loading
Loading