From 8c30a7e853e2796cc938e6ce90e1aa7647edc7b9 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 16:31:04 -0600 Subject: [PATCH 01/13] docs: Propose device custody and operations Every physical action on a server, from a customer install to a staff power cycle, goes through one custody record for that server. The record names the holder, the active operation, and a fence that advances on every change, so two pieces of work never act on one BMC at once. Operations are typed (installation, power, wipe, preparation) and share one envelope and outcome contract. Metal stays the only customer API; Fleet fulfills it by creating these operations as a Metal provider. Staff can prepare and power only servers no customer holds, and an Unknown outcome keeps the holder until a recovery settles it. Coordination uses single-object conditional updates on the Kubernetes API, replacing the relational ledger that #60 and #62 assume. #173's power operation becomes one kind of this design. Co-Authored-By: Claude Opus 5.5 --- docs/README.md | 1 + docs/architecture/README.md | 1 + docs/enhancements/device-operations/README.md | 705 ++++++++++++++++++ .../diagrams/custody-states.svg | 36 + .../device-operations/diagrams/layers.svg | 51 ++ .../diagrams/operation-sequence.svg | 40 + 6 files changed, 834 insertions(+) create mode 100644 docs/enhancements/device-operations/README.md create mode 100644 docs/enhancements/device-operations/diagrams/custody-states.svg create mode 100644 docs/enhancements/device-operations/diagrams/layers.svg create mode 100644 docs/enhancements/device-operations/diagrams/operation-sequence.svg diff --git a/docs/README.md b/docs/README.md index 2faee964..bf31f1c5 100644 --- a/docs/README.md +++ b/docs/README.md @@ -72,6 +72,7 @@ Each topic folder has a `README.md` entry point: | [Troubleshooting](troubleshooting/README.md) | Common problems and safe recovery | | [Development](development/README.md) | Implementation status, local commands, and roadmap | | [Enhancements](enhancements/machine-lifecycle/README.md) | Focused machine lifecycle contracts and acceptance requirements | +| [Device operations](enhancements/device-operations/README.md) | Proposed custody and operations for every physical action on a server | | [Proposals](proposals/fleet-management/README.md) | Broader service proposals, examples, diagrams, and provenance | ## Read implementation and design separately diff --git a/docs/architecture/README.md b/docs/architecture/README.md index 51688d90..3533efb6 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -36,6 +36,7 @@ Key principles to carry into the detailed design: | How is Bare Metal registered and renamed safely? | [Service registration and rollout](#service-registration-and-rollout) | | What are the machine resources and project boundaries? | [Machine lifecycle API design](../enhancements/machine-lifecycle/README.md#api-design) | | How are reservations and concurrent operations coordinated? | [Durable coordination](../enhancements/machine-lifecycle/README.md#durable-coordination) | +| How are physical actions on one server serialized? | [Device custody and operations](../enhancements/device-operations/README.md) | | How are provider effects recovered safely? | [Provider execution and recovery](../enhancements/machine-lifecycle/README.md#provider-execution-and-recovery) | | What happens on release or project deletion? | [Release and project lifecycle](../enhancements/machine-lifecycle/README.md#release-and-project-lifecycle) | | Which internal interfaces and guarantees exist? | [Implementation status](../development/README.md) | diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md new file mode 100644 index 00000000..baca319f --- /dev/null +++ b/docs/enhancements/device-operations/README.md @@ -0,0 +1,705 @@ +--- +status: provisional +stage: alpha +--- + +# Device custody and operations + +[Documentation overview](../../README.md) ยท [Functionality guide](../../functionality/README.md) + +- [Summary](#summary) +- [Motivation](#motivation) +- [Proposal](#proposal) + - [How work reaches a server](#how-work-reaches-a-server) + - [Who holds a server](#who-holds-a-server) + - [Customer inputs and secrets](#customer-inputs-and-secrets) +- [Design details](#design-details) + - [API design](#api-design) + - [DeviceCustody](#devicecustody) + - [Operation envelope](#operation-envelope) + - [DeviceInstallation](#deviceinstallation) + - [DevicePowerOperation](#devicepoweroperation) + - [DeviceWipe](#devicewipe) + - [DevicePreparation](#devicepreparation) + - [Status contract](#status-contract) + - [Admission](#admission) + - [Custody transitions](#custody-transitions) + - [Site execution](#site-execution) + - [Unknown outcomes and recovery](#unknown-outcomes-and-recovery) + - [Coordination without a separate database](#coordination-without-a-separate-database) + - [Fleet as a Metal provider](#fleet-as-a-metal-provider) + - [Capacity status](#capacity-status) + - [Authorization](#authorization) + - [Implementation decisions](#implementation-decisions) + - [Acceptance tests](#acceptance-tests) +- [Production readiness review questionnaire](#production-readiness-review-questionnaire) +- [Implementation history](#implementation-history) +- [Drawbacks](#drawbacks) +- [Alternatives](#alternatives) +- [Infrastructure needed](#infrastructure-needed) + +## Summary + +Every physical action on a server, whether a customer install or a staff power +cycle, goes through one record for that server. That record, `DeviceCustody`, +names who holds the server, which operation is running on it, and a fence that +advances every time custody changes. Fleet admits an operation only by updating +that record, so two pieces of work can never act on the same server at once. + +Operations are typed: `DeviceInstallation`, `DevicePowerOperation`, +`DeviceWipe`, and `DevicePreparation`. They share one envelope, one set of +outcomes, and one executor contract. Customers never see them. The Metal API +stays the only customer contract, and Fleet fulfills it by creating these +operations as a Metal provider. Staff create preparation and power operations +directly, but only for servers that no customer holds. + +Coordination uses single-object conditional updates on the Kubernetes API. It +needs no separate database. + +Nothing in this enhancement is implemented. The +[machine lifecycle](../machine-lifecycle/README.md) contract remains the +customer-facing design; this enhancement describes the physical layer beneath +it. + +## Motivation + +Several kinds of work act on the same server, its BMC, its disks, and its boot +path: + +- installing and reinstalling a customer's operating system; +- changing power for a customer; +- cleaning a server between customers; +- commissioning, burn-in, and firmware work before a server is offered; and +- staff power actions on servers that nobody has allocated. + +Each of these has been designed separately. The allocator keeps its own record +of who occupies a server, installation execution serializes work per +allocation, and the staff power proposal ([#173][power-pr]) adds its own check +for running work. Three locks reconciled by checks leave windows where two +actions reach one BMC. A per-allocation lock also cannot cover staff work, +because staff work has no allocation. + +Some inputs have no home at all. Nothing produces the preparation and health +evidence that makes capacity available, cleaning policy has no resource, and +executors find their targets through static configuration rather than the +Device record. + +### Goals + +- Keep one authoritative record of who holds each server and what is running + on it. +- Serialize installation, power, cleaning, preparation, and maintenance on a + server through that record. +- Keep the Metal API as the only customer contract, and let Fleet fulfill it + through the same operations staff use. +- Let staff prepare and power servers without any path to an allocated server. +- Keep a server out of use while any operation on it has an unproven outcome. +- Resolve the executor's target, BMC credential, and trust from inventory. +- Keep customer secrets out of every record staff can read. +- Coordinate without adding a database. + +### Non-goals + +This enhancement excludes the image catalog and bootstrap configuration APIs, +which belong to Metal; network attachment and IPAM; the content and assurance +levels of cleaning policies; BMC console sessions for customers; firmware +qualification; and how other Metal providers run their hardware. Managed +clusters reuse the same Metal contracts and add nothing here. + +## Proposal + +Fleet will record custody for every Device and admit every physical operation +through that record. Customers keep using Machines and Installations. Staff +gain typed operations for preparation and power on servers that no customer +holds. + +### User stories + +- A customer installs an operating system on an allocated Machine and later + reinstalls it. Staff cannot start any operation on that server meanwhile. +- A staff member commissions a newly racked server. The results mark its + capacity prepared and healthy, and the server becomes allocatable once + policy allows. +- A staff member power-cycles an unallocated server that stopped responding. +- A customer deletes a Machine. Fleet wipes the server under the retained + cleaning policy, and the server returns to the pool only after the wipe is + verified. +- An operator finds a server whose last power command has an unknown outcome, + checks fresh discovery evidence, and records a recovery decision before any + other work runs. + +### How work reaches a server + +Customers act through Metal resources in their own project. The Fleet provider +turns those requests into Device operations in the provider project. Staff +create their operations there too. The Fleet coordinator admits each operation +by updating the Device's custody record, then delivers it to the site that can +reach the server: + +![Every effect on a server passes through its custody record](diagrams/layers.svg) + +The site executor holds the BMC credential for one operation at a time. It +returns results to management, which validates them and updates status. Sites +hold no credentials for project APIs. + +### Who holds a server + +Each Device has exactly one custody record, and that record has at most one +holder: + +| Holder | Meaning | Who may start operations | +| --- | --- | --- | +| `None` | Nobody holds the server. | Only the allocator, to claim it, or staff, to start a service operation. | +| `Allocation` | A customer Machine holds the server through its MachineAllocation. | The Fleet provider, for that allocation's installation and power work. | +| `Release` | The allocation has ended and release obligations remain. | The release controller, for wipes under the retained cleaning policy. | +| `Service` | A staff operation holds the server for its duration. | Nobody else until it finishes. | +| `Retired` | The server is permanently out of service. | Nobody. | + +![Device custody holders and transitions](diagrams/custody-states.svg) + +The holder decides which operations Fleet can admit. Permissions decide who may +ask. An operation needs both: a staff member allowed to create power +operations still cannot power off a server that a customer holds. + +### Customer inputs and secrets + +Operations carry the customer inputs that staff need to diagnose a server, +such as which Machine holds it, the image digest, and the requested power +action. They never carry secret content: + +| Input | On an operation | +| --- | --- | +| Consumer project and Machine name | Yes | +| Image name and digest, boot interface, target disks | Yes | +| Power action and reason | Yes | +| Bootstrap data, user data, and SSH keys | A reference and a digest only | +| Credentials for a customer-supplied boot endpoint | A reference and a digest only | +| BMC credentials | Never; the site resolves them | + +Fleet treats a bootstrap payload as secret as a whole, because customers place +passwords and tokens in user data and Fleet cannot tell which parts are +sensitive. Only the worker running the operation reads the content, and it +verifies the digest before use. + +### Notes, constraints, and caveats + +This enhancement replaces the per-allocation serialization in the machine +lifecycle contract with per-Device custody. MachineAllocation remains the +allocation record; custody refers to it. The staff power proposal +([#173][power-pr]) becomes one operation kind here. The execution and admission +proposals ([#62][execution-pr], [#60][admission-pr]) rely on a relational +ledger; this design replaces that ledger with the custody record. API names are +provisional. + +### Risks and mitigations + +- **Two actions on one server:** [Admission](#admission) commits through one + conditional update on the custody record, so a second writer gets a conflict. +- **Bypassing customer admission:** Customer-held servers accept operations + only from the Fleet provider and only for the holding allocation. +- **Reusing a server after an uncertain wipe:** [Unknown + outcomes](#unknown-outcomes-and-recovery) keep the holder in place until a + verified recovery. +- **Stale workers:** Executors reject any operation or result whose fence + differs from the current custody fence. +- **Customer secret exposure:** Operations carry references and digests, never + secret content. + +Fleet, Metal, Milo IAM, and site operations maintainers must review custody, +admission, and recovery before implementation. + +## Design details + +### API design + +All kinds belong to `fleet.datumapis.com` and live in the provider project, +in the same namespace as their Device. Operation specs are immutable. The Fleet +coordinator alone writes custody and operation status. + +Examples show selected fields. Identifiers, names, and timestamps are synthetic. + +#### DeviceCustody + +```yaml +apiVersion: fleet.datumapis.com/v1alpha1 +kind: DeviceCustody +# One record per Device, named after it. The coordinator creates it with the +# Device and is its only writer. Staff can read it; nobody else can change it. +metadata: + name: server-example-001 + namespace: default +spec: + deviceRef: {name: server-example-001} + + # The holder decides which operations can be admitted. + holder: + type: Allocation # None | Allocation | Release | Service | Retired + allocationRef: {name: alloc-7f3c2} + + # Advances on every change of holder or active operation. Executors reject + # work and results that carry any other value. + fence: 42 + + # At most one operation runs on a server at a time. + activeOperation: + kind: DeviceInstallation + name: alloc-7f3c2-install-01 + inputDigest: "sha256:5d1e9c4a7b2f..." + + # Present only after an Unknown outcome. Only an operation that can settle + # it is admitted, and the server cannot return to None while it remains. + recoveryHold: null + +status: + conditions: + - {type: Held, status: "True", reason: Allocation} + - {type: Busy, status: "True", reason: OperationActive} +``` + +The record keeps its fields in `spec` because it is a coordination record, like +a Kubernetes `Lease`, rather than desired state. The coordinator writes it with +a conditional update that names the version it read. + +#### Operation envelope + +Every operation kind shares these fields: + +```yaml +spec: + deviceRef: {name: server-example-001} + + # Exactly one source of authority. Admission checks it against the holder. + authority: + allocationRef: {name: alloc-7f3c2} # Fleet provider and release controller + # serviceRequest: {reason: "..."} # staff operations + + # Each kind adds its own immutable inputs below. + +status: + # Set by the coordinator at admission. Executors act only under this fence. + admission: + fence: 43 + admittedAt: "2026-11-24T18:02:11Z" + phase: Executing # Pending | Admitted | Executing | Succeeded | Failed | Unknown + result: + reason: "" + message: "" + conditions: [] +``` + +A requester cannot set the fence, the phase, or the result. The coordinator +refuses an operation by setting `phase: Failed` with a reason, and sends nothing +to the server. + +#### DeviceInstallation + +The Fleet provider creates one for each admitted Metal Installation. Staff +cannot create it. + +```yaml +apiVersion: fleet.datumapis.com/v1alpha1 +kind: DeviceInstallation +metadata: + name: alloc-7f3c2-install-01 + namespace: default +spec: + deviceRef: {name: server-example-001} + authority: + allocationRef: {name: alloc-7f3c2} + + # Names the customer request it fulfills, for diagnosis. It grants nothing. + installationRef: {project: consumer-a, namespace: default, name: debian-12} + + # Exact inputs resolved at Metal admission. Retries reuse them unchanged. + image: + name: debian-12 + digest: "sha256:9f4ad8d8b8a6..." + bootstrap: + secretRef: {project: consumer-a, namespace: default, name: debian-12-bootstrap} + digest: "sha256:0c2b77e1d9a4..." + bootInterface: primary + targetDisks: [disk-0] +``` + +#### DevicePowerOperation + +The Fleet provider creates one when a Machine's `powerState` changes. Staff +create one for a server with no holder. + +```yaml +apiVersion: fleet.datumapis.com/v1alpha1 +kind: DevicePowerOperation +metadata: + name: server-example-001-power-7 + namespace: default +spec: + deviceRef: {name: server-example-001} + authority: + serviceRequest: {reason: "BMC reports the host hung during inspection"} + action: PowerCycle # On | ForceOff | ForceRestart | PowerCycle +``` + +Each action has a success test that the executor checks against the BMC, such +as observing the requested power state within a time limit. An action the +executor cannot confirm ends as `Unknown`, never as success. + +#### DeviceWipe + +The release controller creates wipes from the cleaning policy retained with the +allocation. Staff never create wipes; they own the policy, not the effect. + +```yaml +apiVersion: fleet.datumapis.com/v1alpha1 +kind: DeviceWipe +metadata: + name: alloc-7f3c2-wipe-01 + namespace: default +spec: + deviceRef: {name: server-example-001} + authority: + allocationRef: {name: alloc-7f3c2} + # The policy and digest pinned when the allocation was made, not the + # current policy. + cleaningPolicy: + name: tenant-reuse-v1 + digest: "sha256:3a7c0f9e2b18..." + targets: [disk-0, disk-1] +``` + +#### DevicePreparation + +Staff create preparation operations to commission a server before it is +offered: inspection, burn-in, and a firmware baseline. A preparation runs a +pinned plan; it never accepts arbitrary commands. + +```yaml +apiVersion: fleet.datumapis.com/v1alpha1 +kind: DevicePreparation +metadata: + name: server-example-001-prepare-1 + namespace: default +spec: + deviceRef: {name: server-example-001} + authority: + serviceRequest: {reason: "Commission after racking"} + plan: + name: standard-commissioning-v2 + digest: "sha256:b81f4d0a6c93..." +``` + +A succeeded preparation produces the evidence that the capacity projector uses +for `Prepared` and `Healthy`. It does not make the server allocatable by itself. + +#### Status contract + +Operation conditions follow the [machine lifecycle status +contract](../machine-lifecycle/README.md#status-contract). An absent condition +means `Unknown`, and nothing infers success from absence. + +| Phase | Meaning | +| --- | --- | +| `Pending` | Created and not yet admitted. | +| `Admitted` | Custody names this operation under a new fence. Nothing has been sent. | +| `Executing` | The site has started the operation. | +| `Succeeded` | The kind's success test passed. | +| `Failed` | Fleet knows the operation sent nothing, or the server refused it and its state did not change. | +| `Unknown` | A command may have reached the server and Fleet cannot prove the result. | + +`Succeeded`, `Failed`, and `Unknown` are final for the operation. They are not +final for custody: `Unknown` places a [recovery +hold](#unknown-outcomes-and-recovery). + +Refusal reasons include `HolderMismatch`, `CreatorNotPermitted`, +`OperationInProgress`, `RecoveryHold`, `DeviceRetired`, `DeviceIdentityMismatch`, +`DiscoveryNotCurrent`, and `Expired`. + +### Admission + +The coordinator admits an operation in one conditional update to the custody +record: + +![One Device operation from request to outcome](diagrams/operation-sequence.svg) + +Admission requires all of the following: + +1. The operation's authority matches the holder. An `allocationRef` must name + the current `Allocation` or `Release` holder. A `serviceRequest` requires + holder `None`. +2. The creator's identity is allowed for that kind and holder: the Fleet + provider for installation and allocation power, the release controller for + wipes, and staff for service operations. +3. No operation is active. Under a recovery hold, only an operation that can + settle the hold is admitted. +4. The Device is not retired, and its identity matches current discovery + evidence. + +The update sets the active operation, advances the fence, and, for a staff +operation, moves the holder from `None` to `Service`. If another writer changed +custody first, the update fails with a conflict and the coordinator evaluates +again from the new state. + +Operations for the current holder wait in `Pending` while another operation +runs, so a reinstall can follow a power change. Staff operations are refused +rather than queued, because a queued staff request could run long after its +reason has passed. Pending operations expire after a limit set per kind. + +### Custody transitions + +| From | To | Trigger | Written by | +| --- | --- | --- | --- | +| `None` | `Allocation` | The allocator selects the server for a Machine after Metal admission and quota. | Allocator, through the coordinator | +| `Allocation` | `Release` | The Machine is deleted or its allocation ends. | Coordinator | +| `Release` | `None` | Every release gate is verified, including the wipes the cleaning policy requires. | Coordinator | +| `None` | `Service` | A staff operation is admitted. | Coordinator | +| `Service` | `None` | That operation ends as `Succeeded` or `Failed`. | Coordinator | +| `None` | `Retired` | The Device is retired. | Coordinator | + +Allocation is the same conditional update as admission. Two allocators racing +for one server cannot both win; the loser selects another server or stays +pending. Release follows the [machine lifecycle release +gates](../machine-lifecycle/README.md#release-and-project-lifecycle). The server +returns to `None` only when all of them close. + +### Site execution + +The coordinator delivers each admitted operation to the site that serves its +Device. The site runs one short-lived worker per operation: + +- The worker resolves its target from the inputs captured at admission: BMC + endpoint, system UUID, boot MAC address, and the digest of the approved BMC + TLS key. +- It reads only that Device's BMC credential, which the site stores, and + checks the live TLS key and system identity before sending the credential. + A mismatch ends the operation as `Failed` with nothing sent. +- It records every step before sending it. After a crash or a lost response it + queries the server; it never resends a step whose result it cannot prove. +- It returns a local result that carries the admission fence. Management + rejects a result with any other fence. + +Sites write only local results. Management validates them and writes operation +status and custody. Sites hold no credentials for the provider or consumer +project APIs. + +### Unknown outcomes and recovery + +An `Unknown` outcome keeps the current holder and places a recovery hold on +custody. While the hold exists, Fleet admits only an operation that can settle +it, and the server cannot return to `None`. A held allocation can still move to +`Release`; the hold moves with it. + +Recovery depends on the kind: + +- **Power:** Fresh discovery evidence that shows the server's power state, + plus a recovery record from staff, settles the hold. +- **Installation:** A new installation, or a wipe during release, must succeed. + Evidence alone cannot prove what a partial installation left on disk. +- **Wipe:** Only a new wipe that succeeds settles the hold. An acknowledgment + never stands in for verified cleaning. +- **Preparation:** A new preparation that succeeds, or retirement. + +Each recovery is its own audited record that names the held operation, the +evidence, and the decision. Fleet never clears a hold by retrying the original +operation automatically. + +### Coordination without a separate database + +Fleet keeps every value that must change together on one Kubernetes object. +A conditional update on a single object is atomic, so the design needs no +transactions across objects: + +| Need | How Fleet meets it | +| --- | --- | +| Allocation and execution never overlap | Holder and active operation share the custody record. | +| An admitted operation is never lost | The custody update is the commit point. After a crash the coordinator rebuilds delivery from custody. | +| A request is never admitted twice | Operations have deterministic names, and custody names the admitted one. | +| Release state survives Machine deletion | The `Release` holder and its remaining obligations live on custody, in the provider project. | +| Quota stays consistent | Milo holds quota. Metal obtains the quota claim, named from the Machine, before allocation and releases it if no server can be claimed. | +| Long-term history | Fleet keeps finished operations for a bounded period, then relies on the platform audit and activity records. | + +Each server gets one write per change. The allocator tries candidate servers +one at a time instead of choosing among them in one transaction. + +### Fleet as a Metal provider + +Metal defines what customers ask for. Fleet is one provider that fulfills it: + +| Metal request | Fleet effect | +| --- | --- | +| Machine admitted | The allocator moves a server from `None` to `Allocation`. | +| Installation created | The Fleet provider creates a `DeviceInstallation`. | +| `Machine.spec.powerState` changed | The Fleet provider creates a `DevicePowerOperation`. | +| Machine deleted | Custody moves to `Release`, and the release controller creates `DeviceWipe` operations. | +| Status | The Metal projector reports results from the Fleet operations, without operation names or inventory details. | + +Other providers implement the Metal contract their own way and need none of +these resources. + +### Capacity status + +The capacity projector derives MachineCapacity conditions from custody and +operation evidence: + +- `Prepared` requires a succeeded preparation under the current plan. +- `Healthy` requires current health evidence from preparation and discovery. +- `Available` also requires holder `None`, no recovery hold, and an enabled + allocation policy. + +Nobody can make capacity available by editing its status. + +### Authorization + +| Identity | Create | Read | +| --- | --- | --- | +| Staff power operator | `DevicePowerOperation` | Custody and operations | +| Staff preparation operator | `DevicePreparation` | Custody and operations | +| Staff viewer | None | Custody and operations | +| Fleet provider for Metal | `DeviceInstallation`, `DevicePowerOperation` | Custody and operations | +| Release controller | `DeviceWipe` | Custody and operations | +| Fleet coordinator | Custody records | Everything it admits | + +Only the coordinator writes custody and operation status. Admission checks +each operation's creator in addition to these grants, so a grant alone never +authorizes work on a held server. No staff role can read bootstrap secrets. + +### Implementation decisions + +Before this enhancement becomes implementable, Fleet and integration owners +must record these decisions: + +- **Custody placement:** Confirm that the provider project API supports the + conditional updates custody needs, with the availability the allocator + requires. +- **Preparation plans:** Decide what makes a plan qualified, who approves it, + and which evidence sets `Prepared` and `Healthy`. +- **Recovery evidence:** Define, for each kind, the evidence a recovery needs + and whether a second person must confirm it. +- **Retention:** Decide how long finished operations stay before collection. +- **Customer identity for staff:** Decide whether every staff role can see + which customer holds a server, or only support roles. + +### Acceptance tests + +These tests are required and not yet implemented: + +- Two allocators race for one server; exactly one wins. +- A staff operation races an allocation; exactly one is admitted. +- A staff operation targets an allocated server, a releasing server, and a + server under a recovery hold; each is refused with nothing sent. +- A BMC response is lost during each operation kind; the operation ends as + `Unknown` and custody holds. +- A worker restarts with a stale fence; the site and management reject its + result. +- The coordinator restarts between admission and delivery; the operation is + delivered once. +- A BMC credential or TLS key rotates; workers use the new values, and a key + mismatch sends nothing. +- A Machine is deleted during installation; release waits for the installation + outcome before wiping. +- No staff role can read a bootstrap secret through any operation. + +## Production readiness review questionnaire + +These controls and tests are proposed, not implemented or qualified. + +### Feature enablement and rollback + +#### How do operators enable or disable the feature in a live cluster? + +Register the kinds and their IAM resources, and deploy the coordinator and site +executors. Pausing admission stops new operations while running operations +finish and recoveries continue. + +#### Does enabling the feature change any default behavior? + +No. Custody starts at `None` for every Device. Creating custody records causes +no effect on any server. + +#### Can operators disable the feature after enabling it? + +Yes, by pausing admission. Custody records, holds, and site executors must stay +available while any server has a holder other than `None` or `Retired`. + +### Monitoring requirements + +#### What must operators monitor? + +Servers under a recovery hold, operations in `Unknown`, servers in `Release` +for longer than expected, pending operations near expiry, rejected stale +fences, and site executors that stop reporting. + +#### How are failures recovered? + +An `Unknown` outcome needs a recovery record with evidence. Nothing retries +automatically. + +### Dependencies + +#### Does the feature depend on specific services? + +Milo for project APIs, IAM, and quota; the federation layer that delivers +operations to sites; inventory and BMC discovery for Device facts; and the Metal +service for customer requests. + +### Scalability + +#### Does the feature add API calls? + +One conditional update per custody change and a few status writes per +operation. + +#### Does the feature introduce API types? + +Yes: `DeviceCustody` and four operation kinds. + +## Implementation history + +- 2026-11-24: Proposed. + +## Drawbacks + +Every effect on a server now depends on the custody record and the coordinator +that writes it. Typed kinds add more resources to register and grant. A +recovery hold can keep a server out of use for a long time when evidence is +hard to get. Allocation picks servers one at a time, which rules out choosing +several servers atomically. + +## Alternatives + +- **One generic operation kind with a `type` field:** IAM grants permissions + per kind, not per field value. Staff allowed to request power could also + request an installation, and one large schema would have to cover every + type. +- **Declarative desired state per Device:** Steady-state power fits, but wipes + and resets do not. Reapplying desired state can repeat a destructive action, + and recovery needs the exact admitted operation rather than the current + desired state. +- **No Fleet operation kinds for customer work:** Customer work could stay in + private records while staff get separate resources. That keeps two + admission paths and two locks, the problem this design removes. +- **A relational ledger:** A database would allow transactions across many + records, but it adds a stateful dependency the platform does not otherwise + need. One record per server gives the same guarantee for the conflicts that + matter. +- **Lock per allocation:** Staff work has no allocation, so a per-allocation + lock cannot serialize it with customer work. + +Other systems use similar boundaries. OpenStack keeps tenant instances separate +from Ironic's hardware nodes. Ironic records the holding instance on the node +and runs manual cleaning only in a state that no tenant can hold. Metal3 records +the holder on its `BareMetalHost`, and moved firmware work into typed resources +after one-shot actions proved awkward in desired state. Kubernetes binds a +`PersistentVolumeClaim` to a `PersistentVolume` with one conditional update and +applies a reclaim policy on release. + +## Infrastructure needed + +The test environment needs one provider project, two consumer projects, one +site, and BMC emulators that can drop responses and rotate TLS keys. Physical +qualification needs servers whose BMCs the site can reach and a boot network. + +Fleet owns the design records in this repository. Environment configuration +lives outside this repository. + +[power-pr]: https://github.com/datum-cloud/fleet/pull/173 +[execution-pr]: https://github.com/datum-cloud/fleet/pull/62 +[admission-pr]: https://github.com/datum-cloud/fleet/pull/60 diff --git a/docs/enhancements/device-operations/diagrams/custody-states.svg b/docs/enhancements/device-operations/diagrams/custody-states.svg new file mode 100644 index 00000000..c12fcc48 --- /dev/null +++ b/docs/enhancements/device-operations/diagrams/custody-states.svg @@ -0,0 +1,36 @@ + +Device custody holders and transitionsA Device with no holder can be claimed by the allocator for a customer allocation, by an admitted staff operation, or retired. An allocation moves to release when its Machine is deleted. Release returns the Device to no holder only after cleaning and the other release gates are verified. A staff holder returns to no holder when its operation succeeds or fails. An unknown outcome keeps the current holder under a recovery hold. Only an operation that can settle the hold runs, and the server cannot return to no holder until it is settled. + + + + +Allocation +Customer holds it + +Release +Cleaning runs + +None +No holder + +Retired +Terminal + +Service +Staff operation runs + +Allocator claims it + +Machine deleted + +Release gates verified + +Retired + +Staff operation admitted + +Succeeded or Failed + +An Unknown outcome keeps the holder under a recovery hold. +Only a settling operation runs, and the server cannot return to None. + diff --git a/docs/enhancements/device-operations/diagrams/layers.svg b/docs/enhancements/device-operations/diagrams/layers.svg new file mode 100644 index 00000000..b5d40185 --- /dev/null +++ b/docs/enhancements/device-operations/diagrams/layers.svg @@ -0,0 +1,51 @@ + +Every effect on a server passes through its custody recordThe consumer project holds the Machine and Installation. The Fleet provider for Metal turns them into typed Device operations in the provider project, and staff create preparation and power operations there too. The Fleet coordinator admits each operation by updating the Device's custody record, which names the holder, the fence, and the active operation. The coordinator delivers admitted operations to the site that serves the Device. The site executor reads the Device's BMC credential, checks the key pin, acts on the BMC and boot network, and returns local results. Only the coordinator writes custody and operation status. + + + + +Consumer project + +Provider project + +Site + +Machine +Allocation and power + +Installation +Image and bootstrap + +Staff +Preparation and power + +Device operations +Install, power, wipe, prepare + +DeviceCustody +Holder, fence, active operation + +Device +Identity, BMC endpoint, NICs + +Executor +One worker each + +BMC and +boot network + +Provider + + + +Conditional update + + +Fenced + +Results + + +Only the Fleet coordinator writes custody and operation status. +Sites hold no project credentials; they return local results that management validates. + diff --git a/docs/enhancements/device-operations/diagrams/operation-sequence.svg b/docs/enhancements/device-operations/diagrams/operation-sequence.svg new file mode 100644 index 00000000..c7721040 --- /dev/null +++ b/docs/enhancements/device-operations/diagrams/operation-sequence.svg @@ -0,0 +1,40 @@ + +One Device operation from request to outcomeA requester, either the Fleet provider for Metal or a staff member, creates an operation with an immutable spec. The Fleet coordinator checks the holder and the creator, then claims the custody slot with one conditional update that names the operation and advances the fence. A conflict means another writer changed custody first, and the coordinator reevaluates. The coordinator delivers the admitted operation to its site. The site executor checks the BMC key pin and server identity, acts, and returns a local result carrying the fence. The coordinator records the outcome on custody, releasing the slot or placing a recovery hold, and reports Succeeded, Failed, or Unknown. + + + + +Requester + + +Fleet coordinator + + +DeviceCustody +One per Device + + +Site executor + +Create operation +with immutable spec + +Check holder and creator; +claim slot, advance fence + +Committed, or conflict + +Deliver the admitted operation to its site + +Check key pin and identity, act once +Local result with the matching fence + +Record outcome; +release slot, or hold + +Succeeded, Failed, +or Unknown + + +A lost response is queried, never resent. Unknown keeps custody until recovery. + From 221e9185b64b2236ab861f763cecdebb53e5d2c7 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 16:33:40 -0600 Subject: [PATCH 02/13] docs: Tighten the device custody proposal Rewrite the enhancement to state each fact once, in short, direct sentences. Merge the holder, kind, and creator details into one table each, keep one operation example, and drop sections that restated the design. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 750 ++++++------------ 1 file changed, 229 insertions(+), 521 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index baca319f..557b5ba4 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -10,23 +10,12 @@ stage: alpha - [Summary](#summary) - [Motivation](#motivation) - [Proposal](#proposal) - - [How work reaches a server](#how-work-reaches-a-server) - - [Who holds a server](#who-holds-a-server) - - [Customer inputs and secrets](#customer-inputs-and-secrets) - [Design details](#design-details) - [API design](#api-design) - - [DeviceCustody](#devicecustody) - - [Operation envelope](#operation-envelope) - - [DeviceInstallation](#deviceinstallation) - - [DevicePowerOperation](#devicepoweroperation) - - [DeviceWipe](#devicewipe) - - [DevicePreparation](#devicepreparation) - - [Status contract](#status-contract) - [Admission](#admission) - - [Custody transitions](#custody-transitions) - [Site execution](#site-execution) - - [Unknown outcomes and recovery](#unknown-outcomes-and-recovery) - - [Coordination without a separate database](#coordination-without-a-separate-database) + - [Unknown outcomes](#unknown-outcomes) + - [Consistency without a database](#consistency-without-a-database) - [Fleet as a Metal provider](#fleet-as-a-metal-provider) - [Capacity status](#capacity-status) - [Authorization](#authorization) @@ -40,261 +29,154 @@ stage: alpha ## Summary -Every physical action on a server, whether a customer install or a staff power -cycle, goes through one record for that server. That record, `DeviceCustody`, -names who holds the server, which operation is running on it, and a fence that -advances every time custody changes. Fleet admits an operation only by updating -that record, so two pieces of work can never act on the same server at once. +Fleet records custody for each server in one `DeviceCustody` object. Custody +names who holds the server and the one operation running on it. Fleet starts +every physical action, such as an install, a power change, or a wipe, by +updating that object. -Operations are typed: `DeviceInstallation`, `DevicePowerOperation`, -`DeviceWipe`, and `DevicePreparation`. They share one envelope, one set of -outcomes, and one executor contract. Customers never see them. The Metal API -stays the only customer contract, and Fleet fulfills it by creating these -operations as a Metal provider. Staff create preparation and power operations -directly, but only for servers that no customer holds. +Customers keep using the Metal API. Fleet fulfills Metal requests with typed +Device operations, and staff use the same operations for servers that no +customer holds. -Coordination uses single-object conditional updates on the Kubernetes API. It -needs no separate database. - -Nothing in this enhancement is implemented. The -[machine lifecycle](../machine-lifecycle/README.md) contract remains the -customer-facing design; this enhancement describes the physical layer beneath -it. +This enhancement is a proposal. Nothing in it is implemented. ## Motivation -Several kinds of work act on the same server, its BMC, its disks, and its boot -path: - -- installing and reinstalling a customer's operating system; -- changing power for a customer; -- cleaning a server between customers; -- commissioning, burn-in, and firmware work before a server is offered; and -- staff power actions on servers that nobody has allocated. +Five kinds of work act on the same server: -Each of these has been designed separately. The allocator keeps its own record -of who occupies a server, installation execution serializes work per -allocation, and the staff power proposal ([#173][power-pr]) adds its own check -for running work. Three locks reconciled by checks leave windows where two -actions reach one BMC. A per-allocation lock also cannot cover staff work, -because staff work has no allocation. +- customer installation and reinstallation; +- customer power changes; +- cleaning between customers; +- preparation before a server is offered, such as burn-in and firmware; and +- staff power changes on unallocated servers. -Some inputs have no home at all. Nothing produces the preparation and health -evidence that makes capacity available, cleaning policy has no resource, and -executors find their targets through static configuration rather than the -Device record. +Today each kind has its own lock, or none. Two actions can reach one BMC at the +same time. A lock per allocation cannot cover staff work, because staff work has +no allocation. ### Goals -- Keep one authoritative record of who holds each server and what is running - on it. -- Serialize installation, power, cleaning, preparation, and maintenance on a - server through that record. -- Keep the Metal API as the only customer contract, and let Fleet fulfill it - through the same operations staff use. -- Let staff prepare and power servers without any path to an allocated server. -- Keep a server out of use while any operation on it has an unproven outcome. -- Resolve the executor's target, BMC credential, and trust from inventory. -- Keep customer secrets out of every record staff can read. -- Coordinate without adding a database. +- One record per server says who holds it and what runs on it. +- Every physical action on a server goes through that record. +- Customer and staff work use the same operations and the same executor. +- Staff cannot act on a server that a customer holds. +- A server with an unproven operation outcome stays out of use. +- Staff cannot read customer secrets. +- No new database. ### Non-goals -This enhancement excludes the image catalog and bootstrap configuration APIs, -which belong to Metal; network attachment and IPAM; the content and assurance -levels of cleaning policies; BMC console sessions for customers; firmware -qualification; and how other Metal providers run their hardware. Managed -clusters reuse the same Metal contracts and add nothing here. +- Image catalog and bootstrap APIs. Metal owns them. +- Network attachment and address management. +- Cleaning policy content and assurance levels. +- Customer console access. +- How other Metal providers run their hardware. ## Proposal -Fleet will record custody for every Device and admit every physical operation -through that record. Customers keep using Machines and Installations. Staff -gain typed operations for preparation and power on servers that no customer -holds. - -### User stories - -- A customer installs an operating system on an allocated Machine and later - reinstalls it. Staff cannot start any operation on that server meanwhile. -- A staff member commissions a newly racked server. The results mark its - capacity prepared and healthy, and the server becomes allocatable once - policy allows. -- A staff member power-cycles an unallocated server that stopped responding. -- A customer deletes a Machine. Fleet wipes the server under the retained - cleaning policy, and the server returns to the pool only after the wipe is - verified. -- An operator finds a server whose last power command has an unknown outcome, - checks fresh discovery evidence, and records a recovery decision before any - other work runs. - -### How work reaches a server - -Customers act through Metal resources in their own project. The Fleet provider -turns those requests into Device operations in the provider project. Staff -create their operations there too. The Fleet coordinator admits each operation -by updating the Device's custody record, then delivers it to the site that can -reach the server: +Customers create Machines and Installations in their project. Fleet's Metal +provider turns those requests into Device operations in the provider project. +Staff create operations there too. The Fleet coordinator admits each operation +by updating the server's custody, then sends it to the site that can reach the +server. ![Every effect on a server passes through its custody record](diagrams/layers.svg) -The site executor holds the BMC credential for one operation at a time. It -returns results to management, which validates them and updates status. Sites -hold no credentials for project APIs. - -### Who holds a server - -Each Device has exactly one custody record, and that record has at most one -holder: - -| Holder | Meaning | Who may start operations | -| --- | --- | --- | -| `None` | Nobody holds the server. | Only the allocator, to claim it, or staff, to start a service operation. | -| `Allocation` | A customer Machine holds the server through its MachineAllocation. | The Fleet provider, for that allocation's installation and power work. | -| `Release` | The allocation has ended and release obligations remain. | The release controller, for wipes under the retained cleaning policy. | -| `Service` | A staff operation holds the server for its duration. | Nobody else until it finishes. | -| `Retired` | The server is permanently out of service. | Nobody. | - -![Device custody holders and transitions](diagrams/custody-states.svg) +### User stories -The holder decides which operations Fleet can admit. Permissions decide who may -ask. An operation needs both: a staff member allowed to create power -operations still cannot power off a server that a customer holds. +- A customer installs an operating system, then reinstalls it. +- A staff member commissions a new server so that it can be offered. +- A staff member power-cycles an unallocated server that stopped responding. +- A customer deletes a Machine, and Fleet wipes the server before reuse. +- An operator settles an operation whose outcome is unknown. -### Customer inputs and secrets +### Relationship to other proposals -Operations carry the customer inputs that staff need to diagnose a server, -such as which Machine holds it, the image digest, and the requested power -action. They never carry secret content: +This enhancement: -| Input | On an operation | -| --- | --- | -| Consumer project and Machine name | Yes | -| Image name and digest, boot interface, target disks | Yes | -| Power action and reason | Yes | -| Bootstrap data, user data, and SSH keys | A reference and a digest only | -| Credentials for a customer-supplied boot endpoint | A reference and a digest only | -| BMC credentials | Never; the site resolves them | - -Fleet treats a bootstrap payload as secret as a whole, because customers place -passwords and tokens in user data and Fleet cannot tell which parts are -sensitive. Only the worker running the operation reads the content, and it -verifies the digest before use. - -### Notes, constraints, and caveats - -This enhancement replaces the per-allocation serialization in the machine -lifecycle contract with per-Device custody. MachineAllocation remains the -allocation record; custody refers to it. The staff power proposal -([#173][power-pr]) becomes one operation kind here. The execution and admission -proposals ([#62][execution-pr], [#60][admission-pr]) rely on a relational -ledger; this design replaces that ledger with the custody record. API names are -provisional. - -### Risks and mitigations - -- **Two actions on one server:** [Admission](#admission) commits through one - conditional update on the custody record, so a second writer gets a conflict. -- **Bypassing customer admission:** Customer-held servers accept operations - only from the Fleet provider and only for the holding allocation. -- **Reusing a server after an uncertain wipe:** [Unknown - outcomes](#unknown-outcomes-and-recovery) keep the holder in place until a - verified recovery. -- **Stale workers:** Executors reject any operation or result whose fence - differs from the current custody fence. -- **Customer secret exposure:** Operations carry references and digests, never - secret content. - -Fleet, Metal, Milo IAM, and site operations maintainers must review custody, -admission, and recovery before implementation. +- replaces per-allocation serialization in the [machine + lifecycle](../machine-lifecycle/README.md#provider-execution-and-recovery) + with per-server custody; +- absorbs the staff power proposal in [#173][power-pr] as one operation kind; + and +- replaces the relational ledger in [#60][admission-pr] and [#62][execution-pr] + with the custody object. ## Design details ### API design -All kinds belong to `fleet.datumapis.com` and live in the provider project, -in the same namespace as their Device. Operation specs are immutable. The Fleet -coordinator alone writes custody and operation status. - -Examples show selected fields. Identifiers, names, and timestamps are synthetic. +All kinds are in `fleet.datumapis.com` and live in the provider project, in the +namespace of their Device. Names are provisional. Examples use synthetic data. #### DeviceCustody +Each Device has one `DeviceCustody` with the same name. Only the coordinator +writes it. + ```yaml apiVersion: fleet.datumapis.com/v1alpha1 kind: DeviceCustody -# One record per Device, named after it. The coordinator creates it with the -# Device and is its only writer. Staff can read it; nobody else can change it. metadata: name: server-example-001 namespace: default spec: deviceRef: {name: server-example-001} - - # The holder decides which operations can be admitted. holder: type: Allocation # None | Allocation | Release | Service | Retired allocationRef: {name: alloc-7f3c2} - - # Advances on every change of holder or active operation. Executors reject - # work and results that carry any other value. + # Increases on every change. Executors reject work with any other value. fence: 42 - - # At most one operation runs on a server at a time. activeOperation: kind: DeviceInstallation name: alloc-7f3c2-install-01 - inputDigest: "sha256:5d1e9c4a7b2f..." - - # Present only after an Unknown outcome. Only an operation that can settle - # it is admitted, and the server cannot return to None while it remains. + # Set after an Unknown outcome. recoveryHold: null - -status: - conditions: - - {type: Held, status: "True", reason: Allocation} - - {type: Busy, status: "True", reason: OperationActive} ``` -The record keeps its fields in `spec` because it is a coordination record, like -a Kubernetes `Lease`, rather than desired state. The coordinator writes it with -a conditional update that names the version it read. +The fields are in `spec` because custody is a coordination record, like a +Kubernetes `Lease`, not desired state. -#### Operation envelope +| Holder | Meaning | +| --- | --- | +| `None` | Nobody holds the server. | +| `Allocation` | A customer Machine holds the server. | +| `Release` | The allocation ended, and cleanup is not yet verified. | +| `Service` | A staff operation holds the server while it runs. | +| `Retired` | The server is out of service permanently. | -Every operation kind shares these fields: +![Device custody holders and transitions](diagrams/custody-states.svg) -```yaml -spec: - deviceRef: {name: server-example-001} +The allocator claims a server with the same conditional update that admits +operations. If two allocators race, one wins and the other picks another +server. A server leaves `Release` only after every [machine lifecycle release +gate](../machine-lifecycle/README.md#release-and-project-lifecycle) closes. - # Exactly one source of authority. Admission checks it against the holder. - authority: - allocationRef: {name: alloc-7f3c2} # Fleet provider and release controller - # serviceRequest: {reason: "..."} # staff operations +#### Operations - # Each kind adds its own immutable inputs below. +Every operation has these fields: +```yaml +spec: + deviceRef: {name: server-example-001} + authority: # exactly one + allocationRef: {name: alloc-7f3c2} + # serviceRequest: {reason: "Host hung during inspection"} status: - # Set by the coordinator at admission. Executors act only under this fence. - admission: - fence: 43 - admittedAt: "2026-11-24T18:02:11Z" - phase: Executing # Pending | Admitted | Executing | Succeeded | Failed | Unknown - result: - reason: "" - message: "" - conditions: [] + admission: {fence: 43} # set by the coordinator + phase: Executing ``` -A requester cannot set the fence, the phase, or the result. The coordinator -refuses an operation by setting `phase: Failed` with a reason, and sends nothing -to the server. +The spec is immutable. Only the coordinator writes status. -#### DeviceInstallation +| Kind | Required holder | Inputs | +| --- | --- | --- | +| `DeviceInstallation` | `Allocation` | Image digest, bootstrap reference and digest, boot interface, target disks | +| `DevicePowerOperation` | `Allocation` or `None` | `On`, `ForceOff`, `ForceRestart`, or `PowerCycle` | +| `DeviceWipe` | `Release` | Cleaning policy and digest pinned at allocation, target disks | +| `DevicePreparation` | `None` | Preparation plan and digest | -The Fleet provider creates one for each admitted Metal Installation. Staff -cannot create it. +For example, an installation: ```yaml apiVersion: fleet.datumapis.com/v1alpha1 @@ -306,14 +188,7 @@ spec: deviceRef: {name: server-example-001} authority: allocationRef: {name: alloc-7f3c2} - - # Names the customer request it fulfills, for diagnosis. It grants nothing. - installationRef: {project: consumer-a, namespace: default, name: debian-12} - - # Exact inputs resolved at Metal admission. Retries reuse them unchanged. - image: - name: debian-12 - digest: "sha256:9f4ad8d8b8a6..." + image: {name: debian-12, digest: "sha256:9f4ad8d8b8a6..."} bootstrap: secretRef: {project: consumer-a, namespace: default, name: debian-12-bootstrap} digest: "sha256:0c2b77e1d9a4..." @@ -321,335 +196,180 @@ spec: targetDisks: [disk-0] ``` -#### DevicePowerOperation - -The Fleet provider creates one when a Machine's `powerState` changes. Staff -create one for a server with no holder. - -```yaml -apiVersion: fleet.datumapis.com/v1alpha1 -kind: DevicePowerOperation -metadata: - name: server-example-001-power-7 - namespace: default -spec: - deviceRef: {name: server-example-001} - authority: - serviceRequest: {reason: "BMC reports the host hung during inspection"} - action: PowerCycle # On | ForceOff | ForceRestart | PowerCycle -``` - -Each action has a success test that the executor checks against the BMC, such -as observing the requested power state within a time limit. An action the -executor cannot confirm ends as `Unknown`, never as success. - -#### DeviceWipe - -The release controller creates wipes from the cleaning policy retained with the -allocation. Staff never create wipes; they own the policy, not the effect. - -```yaml -apiVersion: fleet.datumapis.com/v1alpha1 -kind: DeviceWipe -metadata: - name: alloc-7f3c2-wipe-01 - namespace: default -spec: - deviceRef: {name: server-example-001} - authority: - allocationRef: {name: alloc-7f3c2} - # The policy and digest pinned when the allocation was made, not the - # current policy. - cleaningPolicy: - name: tenant-reuse-v1 - digest: "sha256:3a7c0f9e2b18..." - targets: [disk-0, disk-1] -``` - -#### DevicePreparation - -Staff create preparation operations to commission a server before it is -offered: inspection, burn-in, and a firmware baseline. A preparation runs a -pinned plan; it never accepts arbitrary commands. - -```yaml -apiVersion: fleet.datumapis.com/v1alpha1 -kind: DevicePreparation -metadata: - name: server-example-001-prepare-1 - namespace: default -spec: - deviceRef: {name: server-example-001} - authority: - serviceRequest: {reason: "Commission after racking"} - plan: - name: standard-commissioning-v2 - digest: "sha256:b81f4d0a6c93..." -``` - -A succeeded preparation produces the evidence that the capacity projector uses -for `Prepared` and `Healthy`. It does not make the server allocatable by itself. - -#### Status contract - -Operation conditions follow the [machine lifecycle status -contract](../machine-lifecycle/README.md#status-contract). An absent condition -means `Unknown`, and nothing infers success from absence. +Operations carry references and digests for secrets, never their content. This +covers bootstrap data, user data, SSH keys, and customer boot endpoint +credentials. Fleet treats a bootstrap payload as secret as a whole. Only the +worker running the operation reads it. | Phase | Meaning | | --- | --- | -| `Pending` | Created and not yet admitted. | -| `Admitted` | Custody names this operation under a new fence. Nothing has been sent. | -| `Executing` | The site has started the operation. | +| `Pending` | Not yet admitted. | +| `Admitted` | Custody names the operation. Nothing has been sent. | +| `Executing` | The site started the operation. | | `Succeeded` | The kind's success test passed. | -| `Failed` | Fleet knows the operation sent nothing, or the server refused it and its state did not change. | -| `Unknown` | A command may have reached the server and Fleet cannot prove the result. | +| `Failed` | Nothing was sent, or the server refused and did not change. | +| `Unknown` | A command may have reached the server, and Fleet cannot prove the result. | -`Succeeded`, `Failed`, and `Unknown` are final for the operation. They are not -final for custody: `Unknown` places a [recovery -hold](#unknown-outcomes-and-recovery). - -Refusal reasons include `HolderMismatch`, `CreatorNotPermitted`, -`OperationInProgress`, `RecoveryHold`, `DeviceRetired`, `DeviceIdentityMismatch`, -`DiscoveryNotCurrent`, and `Expired`. +Conditions follow the [machine lifecycle status +contract](../machine-lifecycle/README.md#status-contract). ### Admission -The coordinator admits an operation in one conditional update to the custody -record: +The coordinator admits an operation with one conditional update to custody: ![One Device operation from request to outcome](diagrams/operation-sequence.svg) -Admission requires all of the following: +The coordinator admits an operation only if all of these hold: -1. The operation's authority matches the holder. An `allocationRef` must name - the current `Allocation` or `Release` holder. A `serviceRequest` requires +1. An `allocationRef` names the current holder, or a `serviceRequest` finds holder `None`. -2. The creator's identity is allowed for that kind and holder: the Fleet - provider for installation and allocation power, the release controller for - wipes, and staff for service operations. -3. No operation is active. Under a recovery hold, only an operation that can - settle the hold is admitted. -4. The Device is not retired, and its identity matches current discovery - evidence. - -The update sets the active operation, advances the fence, and, for a staff -operation, moves the holder from `None` to `Service`. If another writer changed -custody first, the update fails with a conflict and the coordinator evaluates -again from the new state. - -Operations for the current holder wait in `Pending` while another operation -runs, so a reinstall can follow a power change. Staff operations are refused -rather than queued, because a queued staff request could run long after its -reason has passed. Pending operations expire after a limit set per kind. - -### Custody transitions - -| From | To | Trigger | Written by | -| --- | --- | --- | --- | -| `None` | `Allocation` | The allocator selects the server for a Machine after Metal admission and quota. | Allocator, through the coordinator | -| `Allocation` | `Release` | The Machine is deleted or its allocation ends. | Coordinator | -| `Release` | `None` | Every release gate is verified, including the wipes the cleaning policy requires. | Coordinator | -| `None` | `Service` | A staff operation is admitted. | Coordinator | -| `Service` | `None` | That operation ends as `Succeeded` or `Failed`. | Coordinator | -| `None` | `Retired` | The Device is retired. | Coordinator | - -Allocation is the same conditional update as admission. Two allocators racing -for one server cannot both win; the loser selects another server or stays -pending. Release follows the [machine lifecycle release -gates](../machine-lifecycle/README.md#release-and-project-lifecycle). The server -returns to `None` only when all of them close. +2. The creator may create that kind. See [Authorization](#authorization). +3. No operation is active. +4. The Device is not retired, and its identity matches current discovery. + +The update sets the active operation and raises the fence. A staff operation +also sets the holder to `Service`. If another writer changed custody first, the +update fails, and the coordinator evaluates again. + +Operations for the current holder wait in `Pending`. Staff operations are +refused instead, because a queued staff request can run after its reason is +gone. Pending operations expire after a limit set per kind. ### Site execution -The coordinator delivers each admitted operation to the site that serves its -Device. The site runs one short-lived worker per operation: - -- The worker resolves its target from the inputs captured at admission: BMC - endpoint, system UUID, boot MAC address, and the digest of the approved BMC - TLS key. -- It reads only that Device's BMC credential, which the site stores, and - checks the live TLS key and system identity before sending the credential. - A mismatch ends the operation as `Failed` with nothing sent. -- It records every step before sending it. After a crash or a lost response it - queries the server; it never resends a step whose result it cannot prove. -- It returns a local result that carries the admission fence. Management - rejects a result with any other fence. - -Sites write only local results. Management validates them and writes operation -status and custody. Sites hold no credentials for the provider or consumer -project APIs. +The site runs one short-lived worker per operation. The worker: -### Unknown outcomes and recovery +1. reads the BMC endpoint, system UUID, boot MAC, and BMC key digest captured + at admission; +2. reads that Device's BMC credential from the site; +3. checks the BMC's TLS key and the system identity, and fails without sending + anything on a mismatch; +4. records each step before sending it, and after a crash queries the server + instead of sending again; and +5. returns a result with the admission fence. -An `Unknown` outcome keeps the current holder and places a recovery hold on -custody. While the hold exists, Fleet admits only an operation that can settle -it, and the server cannot return to `None`. A held allocation can still move to -`Release`; the hold moves with it. +Management rejects a result with a stale fence. Sites have no credentials for +project APIs. -Recovery depends on the kind: +### Unknown outcomes -- **Power:** Fresh discovery evidence that shows the server's power state, - plus a recovery record from staff, settles the hold. -- **Installation:** A new installation, or a wipe during release, must succeed. - Evidence alone cannot prove what a partial installation left on disk. -- **Wipe:** Only a new wipe that succeeds settles the hold. An acknowledgment - never stands in for verified cleaning. -- **Preparation:** A new preparation that succeeds, or retirement. +An `Unknown` outcome sets a recovery hold on custody. The holder stays in place. +While the hold exists, the coordinator admits only an operation that can settle +it, and the server cannot return to `None`. A held allocation can still move to +`Release`. -Each recovery is its own audited record that names the held operation, the -evidence, and the decision. Fleet never clears a hold by retrying the original -operation automatically. +| Kind | What settles the hold | +| --- | --- | +| Power | Fresh discovery evidence of the power state and a staff recovery record | +| Installation | A later installation or wipe that succeeds | +| Wipe | A later wipe that succeeds | +| Preparation | A later preparation that succeeds, or retirement | -### Coordination without a separate database +Each recovery record names the held operation, its evidence, and the decision. +Fleet never retries an operation automatically. -Fleet keeps every value that must change together on one Kubernetes object. -A conditional update on a single object is atomic, so the design needs no -transactions across objects: +### Consistency without a database -| Need | How Fleet meets it | -| --- | --- | -| Allocation and execution never overlap | Holder and active operation share the custody record. | -| An admitted operation is never lost | The custody update is the commit point. After a crash the coordinator rebuilds delivery from custody. | -| A request is never admitted twice | Operations have deterministic names, and custody names the admitted one. | -| Release state survives Machine deletion | The `Release` holder and its remaining obligations live on custody, in the provider project. | -| Quota stays consistent | Milo holds quota. Metal obtains the quota claim, named from the Machine, before allocation and releases it if no server can be claimed. | -| Long-term history | Fleet keeps finished operations for a bounded period, then relies on the platform audit and activity records. | +A conditional update on one Kubernetes object is atomic. Fleet keeps every value +that must change together on the custody object: -Each server gets one write per change. The allocator tries candidate servers -one at a time instead of choosing among them in one transaction. +- **Commit point:** The custody update admits an operation. After a crash, the + coordinator resumes delivery from custody. +- **Duplicates:** Operation names are deterministic, and custody names the one + admitted. +- **Quota:** Milo holds quota. Metal claims quota before allocation and releases + the claim if no server is free. +- **History:** Fleet keeps finished operations for a set period. Platform audit + and activity records keep history after that. ### Fleet as a Metal provider -Metal defines what customers ask for. Fleet is one provider that fulfills it: - -| Metal request | Fleet effect | +| Metal request | Fleet action | | --- | --- | -| Machine admitted | The allocator moves a server from `None` to `Allocation`. | -| Installation created | The Fleet provider creates a `DeviceInstallation`. | -| `Machine.spec.powerState` changed | The Fleet provider creates a `DevicePowerOperation`. | +| Machine admitted | The allocator sets the holder to `Allocation`. | +| Installation created | The provider creates a `DeviceInstallation`. | +| `powerState` changed | The provider creates a `DevicePowerOperation`. | | Machine deleted | Custody moves to `Release`, and the release controller creates `DeviceWipe` operations. | -| Status | The Metal projector reports results from the Fleet operations, without operation names or inventory details. | -Other providers implement the Metal contract their own way and need none of -these resources. +The Metal projector reports results without operation names or inventory +details. Other Metal providers do not use these resources. ### Capacity status -The capacity projector derives MachineCapacity conditions from custody and -operation evidence: +The capacity projector derives MachineCapacity conditions: -- `Prepared` requires a succeeded preparation under the current plan. -- `Healthy` requires current health evidence from preparation and discovery. -- `Available` also requires holder `None`, no recovery hold, and an enabled +- `Prepared` needs a succeeded preparation under the current plan. +- `Healthy` needs current evidence from preparation and discovery. +- `Available` also needs holder `None`, no recovery hold, and an enabled allocation policy. -Nobody can make capacity available by editing its status. - ### Authorization -| Identity | Create | Read | -| --- | --- | --- | -| Staff power operator | `DevicePowerOperation` | Custody and operations | -| Staff preparation operator | `DevicePreparation` | Custody and operations | -| Staff viewer | None | Custody and operations | -| Fleet provider for Metal | `DeviceInstallation`, `DevicePowerOperation` | Custody and operations | -| Release controller | `DeviceWipe` | Custody and operations | -| Fleet coordinator | Custody records | Everything it admits | +| Identity | May create | +| --- | --- | +| Fleet provider for Metal | `DeviceInstallation`, `DevicePowerOperation` | +| Release controller | `DeviceWipe` | +| Staff power operator | `DevicePowerOperation` | +| Staff preparation operator | `DevicePreparation` | +| Fleet coordinator | `DeviceCustody` and all operation status | -Only the coordinator writes custody and operation status. Admission checks -each operation's creator in addition to these grants, so a grant alone never -authorizes work on a held server. No staff role can read bootstrap secrets. +Staff roles can read custody and operations. No staff role can read bootstrap +secrets. ### Implementation decisions -Before this enhancement becomes implementable, Fleet and integration owners -must record these decisions: +Record these decisions before implementation: -- **Custody placement:** Confirm that the provider project API supports the - conditional updates custody needs, with the availability the allocator - requires. -- **Preparation plans:** Decide what makes a plan qualified, who approves it, - and which evidence sets `Prepared` and `Healthy`. -- **Recovery evidence:** Define, for each kind, the evidence a recovery needs - and whether a second person must confirm it. -- **Retention:** Decide how long finished operations stay before collection. -- **Customer identity for staff:** Decide whether every staff role can see - which customer holds a server, or only support roles. +- Whether the provider project API supports the needed conditional updates with + allocator-level availability. +- What makes a preparation plan qualified, and who approves it. +- What evidence each recovery needs, and whether a second person confirms it. +- How long Fleet keeps finished operations. +- Which staff roles can see the customer that holds a server. ### Acceptance tests -These tests are required and not yet implemented: - -- Two allocators race for one server; exactly one wins. -- A staff operation races an allocation; exactly one is admitted. -- A staff operation targets an allocated server, a releasing server, and a - server under a recovery hold; each is refused with nothing sent. -- A BMC response is lost during each operation kind; the operation ends as - `Unknown` and custody holds. -- A worker restarts with a stale fence; the site and management reject its - result. -- The coordinator restarts between admission and delivery; the operation is - delivered once. -- A BMC credential or TLS key rotates; workers use the new values, and a key - mismatch sends nothing. -- A Machine is deleted during installation; release waits for the installation - outcome before wiping. -- No staff role can read a bootstrap secret through any operation. +These tests are required and not implemented: -## Production readiness review questionnaire - -These controls and tests are proposed, not implemented or qualified. - -### Feature enablement and rollback - -#### How do operators enable or disable the feature in a live cluster? - -Register the kinds and their IAM resources, and deploy the coordinator and site -executors. Pausing admission stops new operations while running operations -finish and recoveries continue. - -#### Does enabling the feature change any default behavior? +- Two allocators race for one server, and one wins. +- A staff operation races an allocation, and one is admitted. +- A staff operation targets an allocated, releasing, or held server, and Fleet + refuses it without sending anything. +- A lost BMC response ends each kind as `Unknown` and sets a hold. +- A worker with a stale fence is rejected. +- A coordinator restart between admission and delivery delivers once. +- A rotated BMC key or credential is used, and a key mismatch sends nothing. +- A Machine deleted during installation waits for the installation outcome + before wiping. -No. Custody starts at `None` for every Device. Creating custody records causes -no effect on any server. - -#### Can operators disable the feature after enabling it? - -Yes, by pausing admission. Custody records, holds, and site executors must stay -available while any server has a holder other than `None` or `Retired`. - -### Monitoring requirements - -#### What must operators monitor? +## Production readiness review questionnaire -Servers under a recovery hold, operations in `Unknown`, servers in `Release` -for longer than expected, pending operations near expiry, rejected stale -fences, and site executors that stop reporting. +These controls are proposed, not implemented. -#### How are failures recovered? +### How do operators enable or disable the feature? -An `Unknown` outcome needs a recovery record with evidence. Nothing retries -automatically. +Register the kinds and IAM resources, then deploy the coordinator and site +executors. To disable it, pause admission. Running operations and recoveries +continue. -### Dependencies +### Does enabling the feature change any default behavior? -#### Does the feature depend on specific services? +No. Custody starts at `None`, and creating it has no effect on a server. -Milo for project APIs, IAM, and quota; the federation layer that delivers -operations to sites; inventory and BMC discovery for Device facts; and the Metal -service for customer requests. +### What must operators monitor? -### Scalability +Recovery holds, `Unknown` operations, long `Release` periods, rejected fences, +and sites that stop reporting. -#### Does the feature add API calls? +### What does the feature depend on? -One conditional update per custody change and a few status writes per -operation. +Milo for project APIs, IAM, and quota. Federation to reach sites. Inventory and +BMC discovery for Device facts. -#### Does the feature introduce API types? +### Does the feature add API types or calls? -Yes: `DeviceCustody` and four operation kinds. +It adds `DeviceCustody` and four operation kinds. Each custody change is one +write. ## Implementation history @@ -657,48 +377,36 @@ Yes: `DeviceCustody` and four operation kinds. ## Drawbacks -Every effect on a server now depends on the custody record and the coordinator -that writes it. Typed kinds add more resources to register and grant. A -recovery hold can keep a server out of use for a long time when evidence is -hard to get. Allocation picks servers one at a time, which rules out choosing -several servers atomically. +- Every action depends on the coordinator and the custody object. +- Four operation kinds add resources to register and grant. +- A recovery hold can keep a server out of use while evidence is missing. +- The allocator claims one server at a time, so it cannot claim several servers + atomically. ## Alternatives -- **One generic operation kind with a `type` field:** IAM grants permissions - per kind, not per field value. Staff allowed to request power could also - request an installation, and one large schema would have to cover every - type. -- **Declarative desired state per Device:** Steady-state power fits, but wipes - and resets do not. Reapplying desired state can repeat a destructive action, - and recovery needs the exact admitted operation rather than the current - desired state. -- **No Fleet operation kinds for customer work:** Customer work could stay in - private records while staff get separate resources. That keeps two - admission paths and two locks, the problem this design removes. -- **A relational ledger:** A database would allow transactions across many - records, but it adds a stateful dependency the platform does not otherwise - need. One record per server gives the same guarantee for the conflicts that - matter. -- **Lock per allocation:** Staff work has no allocation, so a per-allocation - lock cannot serialize it with customer work. - -Other systems use similar boundaries. OpenStack keeps tenant instances separate -from Ironic's hardware nodes. Ironic records the holding instance on the node -and runs manual cleaning only in a state that no tenant can hold. Metal3 records -the holder on its `BareMetalHost`, and moved firmware work into typed resources -after one-shot actions proved awkward in desired state. Kubernetes binds a -`PersistentVolumeClaim` to a `PersistentVolume` with one conditional update and -applies a reclaim policy on release. +- **One operation kind with a `type` field:** IAM grants permissions per kind, + not per field. A staff role that can request power could also request an + installation. +- **Desired state per Device:** Wipes and resets are one-time actions. + Reapplying desired state can repeat them, and recovery needs the exact + admitted operation. +- **Private records for customer work:** Customer and staff work would keep two + admission paths and two locks. +- **A relational ledger:** It adds a database. One object per server gives the + same guarantee for conflicts on that server. +- **A lock per allocation:** Staff work has no allocation. + +Other systems draw similar lines. OpenStack separates tenant instances from +Ironic hardware nodes and runs manual cleaning only in a state no tenant holds. +Metal3 records the holder on each `BareMetalHost`. Kubernetes binds a +`PersistentVolumeClaim` to a `PersistentVolume` with one conditional update. ## Infrastructure needed -The test environment needs one provider project, two consumer projects, one -site, and BMC emulators that can drop responses and rotate TLS keys. Physical -qualification needs servers whose BMCs the site can reach and a boot network. - -Fleet owns the design records in this repository. Environment configuration -lives outside this repository. +Testing needs one provider project, two consumer projects, one site, and BMC +emulators that can drop responses and rotate TLS keys. Hardware qualification +needs reachable BMCs and a boot network. [power-pr]: https://github.com/datum-cloud/fleet/pull/173 [execution-pr]: https://github.com/datum-cloud/fleet/pull/62 From 3ca48b7074cc4ef8eb625e6bbfad07eeb945a1b5 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 16:59:36 -0600 Subject: [PATCH 03/13] docs: Close gaps in the device custody proposal Address the adversarial review of the custody design: - Sites store the highest fence per Device, stop older workers, and refuse journal steps below it. Workers have deadlines, and a hold settles only after the site confirms the held worker stopped. - Rebuilt custody starts Unverified behind a finalizer and is reconciled from allocations, unfinished operations, and site fences. - An admission webhook records each operation's creator, and only listed creator, authority, and holder pairs are admitted. - Custody is the only record of operation phase and result. Changes that span two objects follow a fixed write order with a recovery rule, and allocations are named from the Machine UID. - Release keeps its allocation and tracks open release gates. - DeviceRecovery settles holds and can retire held servers. - Operations carry sealed bootstrap references and no consumer project. Federation delivers inputs to sites. - Rename preparation to commissioning, adopt the machine lifecycle phases, and list the lifecycle sections this changes. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 426 ++++++++++-------- .../diagrams/custody-states.svg | 38 +- .../device-operations/diagrams/layers.svg | 28 +- .../diagrams/operation-sequence.svg | 55 ++- 4 files changed, 299 insertions(+), 248 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index 557b5ba4..c059c1fa 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -15,10 +15,10 @@ stage: alpha - [Admission](#admission) - [Site execution](#site-execution) - [Unknown outcomes](#unknown-outcomes) - - [Consistency without a database](#consistency-without-a-database) - - [Fleet as a Metal provider](#fleet-as-a-metal-provider) + - [Write order and crash recovery](#write-order-and-crash-recovery) + - [Rebuilding custody](#rebuilding-custody) + - [Customer data](#customer-data) - [Capacity status](#capacity-status) - - [Authorization](#authorization) - [Implementation decisions](#implementation-decisions) - [Acceptance tests](#acceptance-tests) - [Production readiness review questionnaire](#production-readiness-review-questionnaire) @@ -30,35 +30,28 @@ stage: alpha ## Summary Fleet records custody for each server in one `DeviceCustody` object. Custody -names who holds the server and the one operation running on it. Fleet starts -every physical action, such as an install, a power change, or a wipe, by -updating that object. +names who holds the server, the one operation running on it, and a fence. +Fleet admits every physical action on the server by updating that object. Customers keep using the Metal API. Fleet fulfills Metal requests with typed -Device operations, and staff use the same operations for servers that no -customer holds. +Device operations. Staff use the same operations for servers that no customer +holds. This enhancement is a proposal. Nothing in it is implemented. ## Motivation -Five kinds of work act on the same server: - -- customer installation and reinstallation; -- customer power changes; -- cleaning between customers; -- preparation before a server is offered, such as burn-in and firmware; and -- staff power changes on unallocated servers. - -Today each kind has its own lock, or none. Two actions can reach one BMC at the -same time. A lock per allocation cannot cover staff work, because staff work has -no allocation. +Customer installs, customer power changes, cleaning between customers, +commissioning, and staff power changes all act on the same BMC, disks, and boot +path. Today each has its own lock, or none, so two actions can reach one BMC at +once. A lock per allocation cannot cover staff work, because staff work has no +allocation. ### Goals - One record per server says who holds it and what runs on it. - Every physical action on a server goes through that record. -- Customer and staff work use the same operations and the same executor. +- Customer and staff work share one operation contract and one executor. - Staff cannot act on a server that a customer holds. - A server with an unproven operation outcome stays out of use. - Staff cannot read customer secrets. @@ -74,11 +67,14 @@ no allocation. ## Proposal -Customers create Machines and Installations in their project. Fleet's Metal -provider turns those requests into Device operations in the provider project. -Staff create operations there too. The Fleet coordinator admits each operation -by updating the server's custody, then sends it to the site that can reach the -server. +Three requesters create Device operations in the provider project: + +- the Fleet provider for Metal, from Machines and Installations; +- the release controller, from deleted Machines; and +- staff. + +The Fleet coordinator admits each operation by updating the server's custody, +then delivers it to the site that can reach the server. ![Every effect on a server passes through its custody record](diagrams/layers.svg) @@ -92,27 +88,35 @@ server. ### Relationship to other proposals -This enhancement: +This enhancement changes these parts of the [machine +lifecycle](../machine-lifecycle/README.md): -- replaces per-allocation serialization in the [machine - lifecycle](../machine-lifecycle/README.md#provider-execution-and-recovery) - with per-server custody; -- absorbs the staff power proposal in [#173][power-pr] as one operation kind; - and -- replaces the relational ledger in [#60][admission-pr] and [#62][execution-pr] - with the custody object. +- **[Provider execution and + recovery](../machine-lifecycle/README.md#provider-execution-and-recovery):** + per-Device custody and fencing replace per-allocation serialization and + fencing. Operations add a `Pending` phase before `Admitted`. +- **[MachineAllocation + record](../machine-lifecycle/README.md#machineallocation-record):** each + allocation is named from its Machine's UID instead of a generated name. + +The machine lifecycle's admission ordering, release gates, and status contract +are unchanged. + +This enhancement also absorbs the staff power proposal in [#173][power-pr] as +one operation kind, and replaces the relational ledger in [#60][admission-pr] +and [#62][execution-pr]. ## Design details ### API design All kinds are in `fleet.datumapis.com` and live in the provider project, in the -namespace of their Device. Names are provisional. Examples use synthetic data. +namespace of their Device. The Fleet coordinator is the only writer of custody +and of operation status. Names are provisional. Examples use synthetic data. #### DeviceCustody -Each Device has one `DeviceCustody` with the same name. Only the coordinator -writes it. +Each Device has one `DeviceCustody` with the same name. ```yaml apiVersion: fleet.datumapis.com/v1alpha1 @@ -120,61 +124,66 @@ kind: DeviceCustody metadata: name: server-example-001 namespace: default + finalizers: [fleet.datumapis.com/custody] spec: - deviceRef: {name: server-example-001} + deviceRef: {name: server-example-001, uid: 6f1c0b52-1d7e-4a35-9e0b-2c41f7a0d9e3} + state: Verified # Verified | Unverified holder: - type: Allocation # None | Allocation | Release | Service | Retired - allocationRef: {name: alloc-7f3c2} - # Increases on every change. Executors reject work with any other value. - fence: 42 + type: Release # None | Allocation | Release | Service | Retired + allocationRef: {name: alloc-3b9d61c2} + # Release only. Each entry is a machine lifecycle release gate. + openGates: [Cleaning, Quota] + fence: 43 activeOperation: - kind: DeviceInstallation - name: alloc-7f3c2-install-01 - # Set after an Unknown outcome. + kind: DeviceWipe + name: alloc-3b9d61c2-wipe-1 + fence: 43 + phase: Dispatched + deadline: "2026-11-24T19:10:00Z" + lastResult: {name: alloc-3b9d61c2-install-1, result: Succeeded} recoveryHold: null ``` -The fields are in `spec` because custody is a coordination record, like a -Kubernetes `Lease`, not desired state. +Custody keeps its fields in `spec` because it is a coordination record, like a +Kubernetes `Lease`, not desired state. The coordinator removes the finalizer +only after the holder is `Retired`. | Holder | Meaning | | --- | --- | | `None` | Nobody holds the server. | | `Allocation` | A customer Machine holds the server. | -| `Release` | The allocation ended, and cleanup is not yet verified. | -| `Service` | A staff operation holds the server while it runs. | +| `Release` | The allocation ended, and release gates are still open. | +| `Service` | A staff operation holds the server. | | `Retired` | The server is out of service permanently. | ![Device custody holders and transitions](diagrams/custody-states.svg) -The allocator claims a server with the same conditional update that admits -operations. If two allocators race, one wins and the other picks another -server. A server leaves `Release` only after every [machine lifecycle release -gate](../machine-lifecycle/README.md#release-and-project-lifecycle) closes. +`Allocation` and `Release` name the same allocation. The server leaves +`Release` only when `openGates` is empty. The release controller removes each +gate after it verifies that gate's evidence. -#### Operations +The fence rises only when an operation is admitted and when custody is +[rebuilt](#rebuilding-custody). A holder change does not raise it, so an +operation that is running when its Machine is deleted can still report its +result. -Every operation has these fields: +#### Operations -```yaml -spec: - deviceRef: {name: server-example-001} - authority: # exactly one - allocationRef: {name: alloc-7f3c2} - # serviceRequest: {reason: "Host hung during inspection"} -status: - admission: {fence: 43} # set by the coordinator - phase: Executing -``` +Every operation has a device, an authority, and inputs. A Fleet admission +webhook records the authenticated creator on each operation when it is +created. Clients cannot set or change that field. -The spec is immutable. Only the coordinator writes status. +| Kind | Creator | Authority | Required holder | Inputs | +| --- | --- | --- | --- | --- | +| `DeviceInstallation` | Fleet provider for Metal | `allocationRef` | `Allocation` | Image digest, bootstrap reference and digest, boot interface, target disks | +| `DevicePowerOperation` | Fleet provider for Metal | `allocationRef` | `Allocation` | Power action | +| `DevicePowerOperation` | Staff power operator | `serviceRequest` | `None` | Power action, reason, expected system UUID | +| `DeviceWipe` | Release controller | `allocationRef` | `Release` | Cleaning policy digest pinned at allocation, target disks | +| `DeviceCommissioning` | Staff commissioning operator | `serviceRequest` | `None` | Commissioning plan and digest | +| `DeviceRecovery` | Staff recovery operator | `serviceRequest` | Any, with a recovery hold | Held operation, evidence, decision | -| Kind | Required holder | Inputs | -| --- | --- | --- | -| `DeviceInstallation` | `Allocation` | Image digest, bootstrap reference and digest, boot interface, target disks | -| `DevicePowerOperation` | `Allocation` or `None` | `On`, `ForceOff`, `ForceRestart`, or `PowerCycle` | -| `DeviceWipe` | `Release` | Cleaning policy and digest pinned at allocation, target disks | -| `DevicePreparation` | `None` | Preparation plan and digest | +No other creator and authority pairs are valid. Staff roles can read custody, +operations, and MachineAllocations. For example, an installation: @@ -182,165 +191,208 @@ For example, an installation: apiVersion: fleet.datumapis.com/v1alpha1 kind: DeviceInstallation metadata: - name: alloc-7f3c2-install-01 + name: alloc-3b9d61c2-install-1 namespace: default spec: + creator: system:serviceaccount:fleet-system:metal-provider # set by the webhook deviceRef: {name: server-example-001} authority: - allocationRef: {name: alloc-7f3c2} + allocationRef: {name: alloc-3b9d61c2} image: {name: debian-12, digest: "sha256:9f4ad8d8b8a6..."} - bootstrap: - secretRef: {project: consumer-a, namespace: default, name: debian-12-bootstrap} - digest: "sha256:0c2b77e1d9a4..." + bootstrap: {ref: sealed-5e0a7d, digest: "sha256:0c2b77e1d9a4..."} bootInterface: primary targetDisks: [disk-0] ``` -Operations carry references and digests for secrets, never their content. This -covers bootstrap data, user data, SSH keys, and customer boot endpoint -credentials. Fleet treats a bootstrap payload as secret as a whole. Only the -worker running the operation reads it. +Provider and release operations get names from the allocation and the request: +the Installation for installs, the Machine generation for power, and the step +number for wipes. Staff operations get generated names, because each one is a +new request. + +The operation phases are those of the [machine lifecycle +operation](../machine-lifecycle/README.md#provider-execution-and-recovery), +plus `Pending`: | Phase | Meaning | | --- | --- | | `Pending` | Not yet admitted. | | `Admitted` | Custody names the operation. Nothing has been sent. | -| `Executing` | The site started the operation. | -| `Succeeded` | The kind's success test passed. | +| `Dispatched` | The site accepted the operation. | +| `Verifying` | The site is checking the success test. | +| `Succeeded` | The success test passed. | | `Failed` | Nothing was sent, or the server refused and did not change. | -| `Unknown` | A command may have reached the server, and Fleet cannot prove the result. | +| `Cancelled` | A newer request replaced the operation before admission. | +| `OutcomeUnknown` | A command may have reached the server, and Fleet cannot prove the result. | -Conditions follow the [machine lifecycle status -contract](../machine-lifecycle/README.md#status-contract). +Custody holds the phase and result of the active operation. Operation status is +a copy of custody. ### Admission -The coordinator admits an operation with one conditional update to custody: - ![One Device operation from request to outcome](diagrams/operation-sequence.svg) -The coordinator admits an operation only if all of these hold: +The coordinator admits an operation with one conditional update to custody, +only if all of these hold: + +1. Custody is `Verified`. +2. The creator, authority, and holder match a row of the operations table. +3. An `allocationRef` names the holder's allocation. +4. No operation is active. +5. The Device UID matches `deviceRef.uid`, and its identity matches current + discovery. -1. An `allocationRef` names the current holder, or a `serviceRequest` finds - holder `None`. -2. The creator may create that kind. See [Authorization](#authorization). -3. No operation is active. -4. The Device is not retired, and its identity matches current discovery. +Under a recovery hold, only the operations in [Unknown +outcomes](#unknown-outcomes) are admitted. -The update sets the active operation and raises the fence. A staff operation -also sets the holder to `Service`. If another writer changed custody first, the -update fails, and the coordinator evaluates again. +The update sets the active operation, raises the fence, and sets a deadline. A +staff operation also sets the holder to `Service`. If another writer changed +custody first, the update fails, and the coordinator evaluates again. -Operations for the current holder wait in `Pending`. Staff operations are -refused instead, because a queued staff request can run after its reason is -gone. Pending operations expire after a limit set per kind. +Provider and release operations wait in `Pending`, oldest first. A newer power +operation for the same allocation cancels an older pending one. Staff +operations are refused instead of queued, and a pending staff operation expires +after five minutes. A queued staff request could otherwise run after its reason +is gone. + +Metal admission, including IAM, entitlement, and quota, still follows the +[machine lifecycle admission +ordering](../machine-lifecycle/README.md#admission-ordering). Custody orders +only physical work. ### Site execution -The site runs one short-lived worker per operation. The worker: +The federation layer delivers each admitted operation, its device snapshot, +and its sealed inputs to the site. The snapshot holds the BMC endpoint, system +UUID, boot MAC address, and BMC key digest that the coordinator captured at +admission. Sites never read project APIs. + +Each site stores the highest fence it has seen for each Device. When an +operation arrives with a higher fence, the site raises its stored fence and +stops every older worker for that Device before it starts the new one. + +The site runs one worker per operation. The worker: -1. reads the BMC endpoint, system UUID, boot MAC, and BMC key digest captured - at admission; -2. reads that Device's BMC credential from the site; -3. checks the BMC's TLS key and the system identity, and fails without sending +1. reads that Device's BMC credential from the site; +2. checks the BMC's TLS key and the system identity, and fails without sending anything on a mismatch; -4. records each step before sending it, and after a crash queries the server - instead of sending again; and -5. returns a result with the admission fence. +3. records each step in the site journal before sending it, and the journal + refuses a step whose fence is below the stored fence; +4. after a crash or lost response, queries the server instead of sending again; + and +5. stops at its deadline. -Management rejects a result with a stale fence. Sites have no credentials for -project APIs. +The site returns results with the operation's fence. The coordinator accepts a +result only if its fence matches the active operation's fence. ### Unknown outcomes -An `Unknown` outcome sets a recovery hold on custody. The holder stays in place. -While the hold exists, the coordinator admits only an operation that can settle -it, and the server cannot return to `None`. A held allocation can still move to -`Release`. +An operation ends as `OutcomeUnknown` when its deadline passes without a +proven result, or when the site cannot prove what the server did. The +coordinator then sets a recovery hold on custody, and the holder stays. -| Kind | What settles the hold | +While a hold exists: + +- the server cannot return to `None`; +- a held `Allocation` can still move to `Release`, and the hold moves with it; + and +- the coordinator admits only the settling operations in this table, and only + after the site confirms that the held operation's worker has stopped. + +| Held operation | Settled by | | --- | --- | -| Power | Fresh discovery evidence of the power state and a staff recovery record | -| Installation | A later installation or wipe that succeeds | -| Wipe | A later wipe that succeeds | -| Preparation | A later preparation that succeeds, or retirement | +| Power | A `DeviceRecovery` with fresh discovery evidence of the power state | +| Installation | A later `DeviceInstallation` that succeeds, or a `DeviceWipe` that succeeds after release | +| Wipe | A later `DeviceWipe` that succeeds | +| Commissioning | A later `DeviceCommissioning` that succeeds | -Each recovery record names the held operation, its evidence, and the decision. -Fleet never retries an operation automatically. +A `DeviceRecovery` can also retire a held server from `Service` or `Release`. +Retiring from `Release` records how the disks were disposed of. Fleet never +retries an operation automatically. -### Consistency without a database +### Write order and crash recovery -A conditional update on one Kubernetes object is atomic. Fleet keeps every value -that must change together on the custody object: +A conditional update on one object is atomic. Where one change spans two +objects, Fleet writes them in a fixed order and recovers from any crash between +them: -- **Commit point:** The custody update admits an operation. After a crash, the - coordinator resumes delivery from custody. -- **Duplicates:** Operation names are deterministic, and custody names the one - admitted. -- **Quota:** Milo holds quota. Metal claims quota before allocation and releases - the claim if no server is free. -- **History:** Fleet keeps finished operations for a set period. Platform audit - and activity records keep history after that. +| Change | Order | After a crash between the writes | +| --- | --- | --- | +| Reserve quota and allocate | Quota claim, then MachineAllocation, both named from the Machine UID | The coordinator finds both by name. A claim for a deleted Machine is released. | +| Allocate a server | MachineAllocation, then custody | Creating the allocation fails if the name exists, so each Machine gets one allocation. An allocation without custody claims custody again. If another holder took the server, the coordinator deletes the allocation and selects again. No effect ran. | +| Admit or finish an operation | Custody, then operation status | Operation status is copied from custody again. | +| Deliver an operation | Custody, then site delivery | The coordinator delivers again from custody. The site ignores a fence it has already seen. | +| End a release | Custody to `None`, then MachineAllocation to `Released` | The coordinator marks the allocation `Released`. | -### Fleet as a Metal provider +Fleet keeps finished operations for 30 days. Platform audit records keep the +history after that. -| Metal request | Fleet action | -| --- | --- | -| Machine admitted | The allocator sets the holder to `Allocation`. | -| Installation created | The provider creates a `DeviceInstallation`. | -| `powerState` changed | The provider creates a `DevicePowerOperation`. | -| Machine deleted | Custody moves to `Release`, and the release controller creates `DeviceWipe` operations. | +### Rebuilding custody -The Metal projector reports results without operation names or inventory -details. Other Metal providers do not use these resources. +If custody is missing for an existing Device, for example after a restore, the +coordinator creates it as `Unverified`. An `Unverified` server admits no +operation and cannot be allocated. The coordinator rebuilds custody from: -### Capacity status +- live MachineAllocations for the Device, which set `Allocation` or `Release`; +- unfinished operations, which set a recovery hold; and +- each site's stored fence, which sets the new fence above every fence already + used. -The capacity projector derives MachineCapacity conditions: +The coordinator then marks custody `Verified`. If the Device UID differs from +`deviceRef.uid`, custody stays `Unverified` until an operator retires the old +record. -- `Prepared` needs a succeeded preparation under the current plan. -- `Healthy` needs current evidence from preparation and discovery. -- `Available` also needs holder `None`, no recovery hold, and an enabled - allocation policy. +### Customer data -### Authorization +Operations carry no customer secrets and no consumer project names. The Fleet +provider copies each bootstrap payload into a sealed store in the provider +project. Only the coordinator and the federation layer can read that store. +The operation carries an opaque reference and a digest. -| Identity | May create | -| --- | --- | -| Fleet provider for Metal | `DeviceInstallation`, `DevicePowerOperation` | -| Release controller | `DeviceWipe` | -| Staff power operator | `DevicePowerOperation` | -| Staff preparation operator | `DevicePreparation` | -| Fleet coordinator | `DeviceCustody` and all operation status | +Federation delivers the payload to the site with the operation. Only that +operation's worker can read it, and the site deletes it when the operation +ends. Fleet treats a bootstrap payload as secret as a whole, because customers +put passwords and tokens in user data. + +Staff identify the customer through the MachineAllocation, which names the +consumer project and Machine. + +### Capacity status + +The capacity projector derives MachineCapacity conditions: -Staff roles can read custody and operations. No staff role can read bootstrap -secrets. +- `Prepared` needs a succeeded commissioning under the current plan. +- `Healthy` needs current evidence from commissioning and discovery. +- `Available` also needs `Verified` custody, holder `None`, no recovery hold, + and an enabled allocation policy. ### Implementation decisions Record these decisions before implementation: -- Whether the provider project API supports the needed conditional updates with - allocator-level availability. -- What makes a preparation plan qualified, and who approves it. -- What evidence each recovery needs, and whether a second person confirms it. -- How long Fleet keeps finished operations. -- Which staff roles can see the customer that holds a server. +- What makes a commissioning plan qualified, and who approves it. +- Whether a second person must confirm a `DeviceRecovery`. +- Which staff roles can read MachineAllocations, and so see customer identity. +- Where each site stores its fences and journal. ### Acceptance tests These tests are required and not implemented: - Two allocators race for one server, and one wins. -- A staff operation races an allocation, and one is admitted. -- A staff operation targets an allocated, releasing, or held server, and Fleet - refuses it without sending anything. -- A lost BMC response ends each kind as `Unknown` and sets a hold. -- A worker with a stale fence is rejected. -- A coordinator restart between admission and delivery delivers once. -- A rotated BMC key or credential is used, and a key mismatch sends nothing. -- A Machine deleted during installation waits for the installation outcome - before wiping. +- An allocator retries after a lost response and does not claim a second + server for the same Machine. +- A staff operation names a customer allocation, and admission refuses it. +- A staff operation targets an allocated, releasing, or held server, and + admission refuses it without sending anything. +- A worker passes its deadline, the operation ends as `OutcomeUnknown`, and a + settling operation waits until the site stops that worker. +- A delayed worker tries a step after a newer operation is admitted, and the + site journal refuses it. +- Custody is deleted and restored, and the server stays unallocatable until + rebuilt with a higher fence. +- A Machine is deleted during installation. Release waits for the installation + outcome or its deadline, and a wipe settles any hold. +- No staff role can read a bootstrap payload. ## Production readiness review questionnaire @@ -348,18 +400,19 @@ These controls are proposed, not implemented. ### How do operators enable or disable the feature? -Register the kinds and IAM resources, then deploy the coordinator and site -executors. To disable it, pause admission. Running operations and recoveries -continue. +Register the kinds, webhook, and IAM resources, then deploy the coordinator and +site executors. To disable it, pause admission of new requests. Running +operations, settling operations, and recoveries continue. ### Does enabling the feature change any default behavior? -No. Custody starts at `None`, and creating it has no effect on a server. +No. Each Device's custody is rebuilt as described above before any operation is +admitted. ### What must operators monitor? -Recovery holds, `Unknown` operations, long `Release` periods, rejected fences, -and sites that stop reporting. +Recovery holds, `OutcomeUnknown` operations, `Unverified` custody, long-running +releases, rejected fences, and sites that stop reporting. ### What does the feature depend on? @@ -368,8 +421,8 @@ BMC discovery for Device facts. ### Does the feature add API types or calls? -It adds `DeviceCustody` and four operation kinds. Each custody change is one -write. +It adds `DeviceCustody`, five operation kinds, and one admission webhook. Each +operation phase change is one custody write and one status copy. ## Implementation history @@ -378,7 +431,7 @@ write. ## Drawbacks - Every action depends on the coordinator and the custody object. -- Four operation kinds add resources to register and grant. +- Five operation kinds add resources to register and grant. - A recovery hold can keep a server out of use while evidence is missing. - The allocator claims one server at a time, so it cannot claim several servers atomically. @@ -393,20 +446,15 @@ write. admitted operation. - **Private records for customer work:** Customer and staff work would keep two admission paths and two locks. -- **A relational ledger:** It adds a database. One object per server gives the - same guarantee for conflicts on that server. +- **A relational ledger:** It adds a database. Fixed write order and + deterministic names give the same guarantees without one. - **A lock per allocation:** Staff work has no allocation. -Other systems draw similar lines. OpenStack separates tenant instances from -Ironic hardware nodes and runs manual cleaning only in a state no tenant holds. -Metal3 records the holder on each `BareMetalHost`. Kubernetes binds a -`PersistentVolumeClaim` to a `PersistentVolume` with one conditional update. - ## Infrastructure needed Testing needs one provider project, two consumer projects, one site, and BMC -emulators that can drop responses and rotate TLS keys. Hardware qualification -needs reachable BMCs and a boot network. +emulators that can drop responses, stall, and rotate TLS keys. Hardware +qualification needs reachable BMCs and a boot network. [power-pr]: https://github.com/datum-cloud/fleet/pull/173 [execution-pr]: https://github.com/datum-cloud/fleet/pull/62 diff --git a/docs/enhancements/device-operations/diagrams/custody-states.svg b/docs/enhancements/device-operations/diagrams/custody-states.svg index c12fcc48..287b5a5c 100644 --- a/docs/enhancements/device-operations/diagrams/custody-states.svg +++ b/docs/enhancements/device-operations/diagrams/custody-states.svg @@ -1,36 +1,44 @@ - -Device custody holders and transitionsA Device with no holder can be claimed by the allocator for a customer allocation, by an admitted staff operation, or retired. An allocation moves to release when its Machine is deleted. Release returns the Device to no holder only after cleaning and the other release gates are verified. A staff holder returns to no holder when its operation succeeds or fails. An unknown outcome keeps the current holder under a recovery hold. Only an operation that can settle the hold runs, and the server cannot return to no holder until it is settled. + +Device custody holders and transitionsRebuilt custody starts Unverified and becomes Verified with its true holder. A Device with no holder can be claimed by the allocator for a customer allocation, or by an admitted staff operation, or retired. An allocation moves to release when its Machine is deleted. Release returns the Device to no holder when every release gate closes. A staff holder returns to no holder when its operation ends. A recovery record can retire a server from service or release. - + + +Unverified +Rebuilt custody Allocation Customer holds it Release -Cleaning runs +Gates open None No holder - -Retired -Terminal Service Staff operation runs + +Retired +Terminal + +Verified with +its true holder Allocator claims it Machine deleted - -Release gates verified - -Retired + +Gates closed + +Recovery Staff operation admitted -Succeeded or Failed - -An Unknown outcome keeps the holder under a recovery hold. -Only a settling operation runs, and the server cannot return to None. +Operation +ends + +Retired + +Recovery diff --git a/docs/enhancements/device-operations/diagrams/layers.svg b/docs/enhancements/device-operations/diagrams/layers.svg index b5d40185..c2551e49 100644 --- a/docs/enhancements/device-operations/diagrams/layers.svg +++ b/docs/enhancements/device-operations/diagrams/layers.svg @@ -1,26 +1,26 @@ - -Every effect on a server passes through its custody recordThe consumer project holds the Machine and Installation. The Fleet provider for Metal turns them into typed Device operations in the provider project, and staff create preparation and power operations there too. The Fleet coordinator admits each operation by updating the Device's custody record, which names the holder, the fence, and the active operation. The coordinator delivers admitted operations to the site that serves the Device. The site executor reads the Device's BMC credential, checks the key pin, acts on the BMC and boot network, and returns local results. Only the coordinator writes custody and operation status. + +Every effect on a server passes through its custody recordThree requesters create Device operations in the provider project: the Fleet provider for Metal, from Machines and Installations; the release controller, from deleted Machines; and staff. The Fleet coordinator admits each operation by updating the server's DeviceCustody, which names the holder, the fence, and the active operation, and refers to the Device. The coordinator delivers the admitted operation with its fence to the site executor, which acts on the BMC and boot network and returns results. - + -Consumer project +Requesters Provider project Site -Machine -Allocation and power - -Installation -Image and bootstrap +Fleet provider +Metal requests + +Release controller +Deleted Machines Staff -Preparation and power +Commission, power Device operations -Install, power, wipe, prepare +Install, power, wipe, commission DeviceCustody Holder, fence, active operation @@ -34,8 +34,7 @@ BMC and boot network -Provider - + Conditional update @@ -45,7 +44,4 @@ Results - -Only the Fleet coordinator writes custody and operation status. -Sites hold no project credentials; they return local results that management validates. diff --git a/docs/enhancements/device-operations/diagrams/operation-sequence.svg b/docs/enhancements/device-operations/diagrams/operation-sequence.svg index c7721040..3ffc0f6c 100644 --- a/docs/enhancements/device-operations/diagrams/operation-sequence.svg +++ b/docs/enhancements/device-operations/diagrams/operation-sequence.svg @@ -1,40 +1,39 @@ - -One Device operation from request to outcomeA requester, either the Fleet provider for Metal or a staff member, creates an operation with an immutable spec. The Fleet coordinator checks the holder and the creator, then claims the custody slot with one conditional update that names the operation and advances the fence. A conflict means another writer changed custody first, and the coordinator reevaluates. The coordinator delivers the admitted operation to its site. The site executor checks the BMC key pin and server identity, acts, and returns a local result carrying the fence. The coordinator records the outcome on custody, releasing the slot or placing a recovery hold, and reports Succeeded, Failed, or Unknown. + +One Device operation from request to outcomeA requester creates an operation, and the admission webhook records its creator. The operation waits in Pending until the Fleet coordinator checks the holder, creator, and authority, then claims the custody slot with one conditional update that raises the fence. A conflict means another writer changed custody first. The coordinator delivers the operation and its sealed inputs to the site. The site raises its stored fence, stops older workers, and refuses any step below its fence. It returns a result with the operation's fence. The coordinator records the result on custody, releasing the slot or setting a recovery hold, and copies it to operation status. - + Requester - + Fleet coordinator - + DeviceCustody One per Device - + -Site executor - -Create operation -with immutable spec +Site + +Create; webhook +records creator -Check holder and creator; -claim slot, advance fence - -Committed, or conflict - -Deliver the admitted operation to its site - -Check key pin and identity, act once -Local result with the matching fence - -Record outcome; -release slot, or hold - -Succeeded, Failed, -or Unknown - - -A lost response is queried, never resent. Unknown keeps custody until recovery. +Pending while busy +Check holder and creator; +claim slot, raise fence + +Committed, or conflict + +Deliver operation and sealed inputs + +Raise site fence, stop older workers, act +Result with the operation's fence + +Record result; +release slot, or hold + +Status copied +from custody + From c901282c8cc71cfd973fa35b260ae26990706104 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:05:09 -0600 Subject: [PATCH 04/13] docs: Settle the custody re-review findings - A held commissioning is settled from holder Service, and a DeviceRecovery never changes the holder except to retire. - Staff operations never wait behind another operation; holder changes cancel pending operations that no longer match. - Rebuilt custody reads the inventory lifecycle, reopens release gates, and stays Unverified until every serving site reports. - The coordinator alone writes release gates from the release controller's evidence, and admits the next operation only after copying the previous result. - Drop Unverified from the holder diagram and show how inventory retires an idle server. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 47 ++++++++++++------- .../diagrams/custody-states.svg | 19 +++----- 2 files changed, 38 insertions(+), 28 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index c059c1fa..12229da9 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -158,9 +158,12 @@ only after the holder is `Retired`. ![Device custody holders and transitions](diagrams/custody-states.svg) -`Allocation` and `Release` name the same allocation. The server leaves -`Release` only when `openGates` is empty. The release controller removes each -gate after it verifies that gate's evidence. +`Allocation` and `Release` name the same allocation. The release controller +reports evidence for each release gate, and the coordinator removes the gate +from `openGates`. The server leaves `Release` only when `openGates` is empty. + +The coordinator sets holder `Retired` when inventory retires a Device whose +holder is `None`. The fence rises only when an operation is admitted and when custody is [rebuilt](#rebuilding-custody). A holder change does not raise it, so an @@ -179,8 +182,8 @@ created. Clients cannot set or change that field. | `DevicePowerOperation` | Fleet provider for Metal | `allocationRef` | `Allocation` | Power action | | `DevicePowerOperation` | Staff power operator | `serviceRequest` | `None` | Power action, reason, expected system UUID | | `DeviceWipe` | Release controller | `allocationRef` | `Release` | Cleaning policy digest pinned at allocation, target disks | -| `DeviceCommissioning` | Staff commissioning operator | `serviceRequest` | `None` | Commissioning plan and digest | -| `DeviceRecovery` | Staff recovery operator | `serviceRequest` | Any, with a recovery hold | Held operation, evidence, decision | +| `DeviceCommissioning` | Staff commissioning operator | `serviceRequest` | `None`, or `Service` under a commissioning hold | Commissioning plan and digest | +| `DeviceRecovery` | Staff recovery operator | `serviceRequest` | Any, with a recovery hold | Held operation, evidence, and a decision: `Settle` or `Retire` | No other creator and authority pairs are valid. Staff roles can read custody, operations, and MachineAllocations. @@ -225,7 +228,8 @@ plus `Pending`: | `OutcomeUnknown` | A command may have reached the server, and Fleet cannot prove the result. | Custody holds the phase and result of the active operation. Operation status is -a copy of custody. +a copy of custody. The coordinator admits the next operation only after it +copies the previous result to that operation's status. ### Admission @@ -245,14 +249,19 @@ Under a recovery hold, only the operations in [Unknown outcomes](#unknown-outcomes) are admitted. The update sets the active operation, raises the fence, and sets a deadline. A -staff operation also sets the holder to `Service`. If another writer changed +staff operation admitted from holder `None` also sets the holder to `Service`. +A `DeviceRecovery` never changes the holder, except to retire the server. If another writer changed custody first, the update fails, and the coordinator evaluates again. -Provider and release operations wait in `Pending`, oldest first. A newer power -operation for the same allocation cancels an older pending one. Staff -operations are refused instead of queued, and a pending staff operation expires -after five minutes. A queued staff request could otherwise run after its reason -is gone. +Provider and release operations wait in `Pending` while another operation +runs, and are admitted oldest first. A newer power operation for the same +allocation cancels an older pending one. When the holder changes, the +coordinator cancels every pending operation that no longer matches it. + +Staff operations never wait behind another operation. Admission refuses a staff +operation that cannot run now, because a queued request could run after its +reason is gone. A staff operation not admitted within five minutes, for +example because the coordinator is down, expires. Metal admission, including IAM, entitlement, and quota, still follows the [machine lifecycle admission @@ -332,12 +341,17 @@ If custody is missing for an existing Device, for example after a restore, the coordinator creates it as `Unverified`. An `Unverified` server admits no operation and cannot be allocated. The coordinator rebuilds custody from: -- live MachineAllocations for the Device, which set `Allocation` or `Release`; -- unfinished operations, which set a recovery hold; and +- the Device's inventory lifecycle, which sets `Retired`; +- live MachineAllocations for the Device, which set `Allocation` or `Release`. + A rebuilt `Release` reopens every release gate, and the release controller + verifies each again; +- unfinished operations, which set a recovery hold, and set `Service` for a + staff operation; and - each site's stored fence, which sets the new fence above every fence already used. -The coordinator then marks custody `Verified`. If the Device UID differs from +The coordinator marks custody `Verified` only after every site that serves the +Device reports its fence. Until then, custody stays `Unverified`. If the Device UID differs from `deviceRef.uid`, custody stays `Unverified` until an operator retires the old record. @@ -382,6 +396,7 @@ These tests are required and not implemented: - An allocator retries after a lost response and does not claim a second server for the same Machine. - A staff operation names a customer allocation, and admission refuses it. +- A commissioning times out, and a later commissioning settles the hold. - A staff operation targets an allocated, releasing, or held server, and admission refuses it without sending anything. - A worker passes its deadline, the operation ends as `OutcomeUnknown`, and a @@ -391,7 +406,7 @@ These tests are required and not implemented: - Custody is deleted and restored, and the server stays unallocatable until rebuilt with a higher fence. - A Machine is deleted during installation. Release waits for the installation - outcome or its deadline, and a wipe settles any hold. + outcome or its deadline, and a wipe settles an installation hold. - No staff role can read a bootstrap payload. ## Production readiness review questionnaire diff --git a/docs/enhancements/device-operations/diagrams/custody-states.svg b/docs/enhancements/device-operations/diagrams/custody-states.svg index 287b5a5c..4731fab5 100644 --- a/docs/enhancements/device-operations/diagrams/custody-states.svg +++ b/docs/enhancements/device-operations/diagrams/custody-states.svg @@ -1,11 +1,8 @@ - -Device custody holders and transitionsRebuilt custody starts Unverified and becomes Verified with its true holder. A Device with no holder can be claimed by the allocator for a customer allocation, or by an admitted staff operation, or retired. An allocation moves to release when its Machine is deleted. Release returns the Device to no holder when every release gate closes. A staff holder returns to no holder when its operation ends. A recovery record can retire a server from service or release. + +Device custody holders and transitionsA Device with no holder can be claimed by the allocator for a customer allocation, taken by an admitted staff operation, or retired when inventory retires it. An allocation moves to release when its Machine is deleted. Release returns the Device to no holder when every release gate closes. A staff holder returns to no holder when its operation ends. A recovery record can retire a server from service or release. - - -Unverified -Rebuilt custody + Allocation Customer holds it @@ -21,9 +18,6 @@ Retired Terminal - -Verified with -its true holder Allocator claims it @@ -38,7 +32,8 @@ Operation ends -Retired - -Recovery +Inventory +retires it + +Recovery From 9375a071b6fb3b4a13787cebf5e9e24f615591f4 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:06:27 -0600 Subject: [PATCH 05/13] docs: Define holder outcomes for settled custody holds - Settling a hold returns a Service holder to None and leaves an Allocation or Release holder in place; Retire sets Retired. - The coordinator skips the result copy when the previous operation no longer exists, so a deleted operation cannot block admission. - Cancelled covers replaced, expired, and mismatched operations. - Rebuilt custody stays Unverified while its sources disagree, and reads Retire recoveries. - Rewrap long lines and narrow the staff refusal test. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index 12229da9..51ee2614 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -224,12 +224,13 @@ plus `Pending`: | `Verifying` | The site is checking the success test. | | `Succeeded` | The success test passed. | | `Failed` | Nothing was sent, or the server refused and did not change. | -| `Cancelled` | A newer request replaced the operation before admission. | +| `Cancelled` | Ended before admission: replaced, expired, or no longer matching the holder. | | `OutcomeUnknown` | A command may have reached the server, and Fleet cannot prove the result. | Custody holds the phase and result of the active operation. Operation status is a copy of custody. The coordinator admits the next operation only after it -copies the previous result to that operation's status. +copies the previous result to the previous operation's status. If that +operation no longer exists, the coordinator skips the copy. ### Admission @@ -250,8 +251,8 @@ outcomes](#unknown-outcomes) are admitted. The update sets the active operation, raises the fence, and sets a deadline. A staff operation admitted from holder `None` also sets the holder to `Service`. -A `DeviceRecovery` never changes the holder, except to retire the server. If another writer changed -custody first, the update fails, and the coordinator evaluates again. +If another writer changed custody first, the update fails, and the coordinator +evaluates again. Provider and release operations wait in `Pending` while another operation runs, and are admitted oldest first. A newer power operation for the same @@ -314,9 +315,11 @@ While a hold exists: | Wipe | A later `DeviceWipe` that succeeds | | Commissioning | A later `DeviceCommissioning` that succeeds | -A `DeviceRecovery` can also retire a held server from `Service` or `Release`. -Retiring from `Release` records how the disks were disposed of. Fleet never -retries an operation automatically. +Settling a hold returns a `Service` holder to `None` and leaves an +`Allocation` or `Release` holder in place. A `DeviceRecovery` with decision +`Retire` sets a `Service` or `Release` holder to `Retired`. Retiring from +`Release` records how the disks were disposed of. Fleet never retries an +operation automatically. ### Write order and crash recovery @@ -341,7 +344,8 @@ If custody is missing for an existing Device, for example after a restore, the coordinator creates it as `Unverified`. An `Unverified` server admits no operation and cannot be allocated. The coordinator rebuilds custody from: -- the Device's inventory lifecycle, which sets `Retired`; +- the Device's inventory lifecycle and `Retire` recoveries, which set + `Retired`; - live MachineAllocations for the Device, which set `Allocation` or `Release`. A rebuilt `Release` reopens every release gate, and the release controller verifies each again; @@ -351,9 +355,9 @@ operation and cannot be allocated. The coordinator rebuilds custody from: used. The coordinator marks custody `Verified` only after every site that serves the -Device reports its fence. Until then, custody stays `Unverified`. If the Device UID differs from -`deviceRef.uid`, custody stays `Unverified` until an operator retires the old -record. +Device reports its fence. Custody stays `Unverified` until an operator resolves +the conflict if these sources disagree, or if the Device UID differs from +`deviceRef.uid`. ### Customer data @@ -397,8 +401,8 @@ These tests are required and not implemented: server for the same Machine. - A staff operation names a customer allocation, and admission refuses it. - A commissioning times out, and a later commissioning settles the hold. -- A staff operation targets an allocated, releasing, or held server, and - admission refuses it without sending anything. +- A staff operation targets an allocated or releasing server, or a held + server it cannot settle, and admission refuses it without sending anything. - A worker passes its deadline, the operation ends as `OutcomeUnknown`, and a settling operation waits until the site stops that worker. - A delayed worker tries a step after a newer operation is admitted, and the From f306b818db3009a70924f2f84e0cb0f4acae222d Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:07:30 -0600 Subject: [PATCH 06/13] docs: Name the sources that conflict when rebuilding custody List the combinations that keep rebuilt custody Unverified until an operator resolves them: a live allocation with retirement, with an unfinished staff operation, or with a second live allocation. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index 51ee2614..c3a561ef 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -356,8 +356,12 @@ operation and cannot be allocated. The coordinator rebuilds custody from: The coordinator marks custody `Verified` only after every site that serves the Device reports its fence. Custody stays `Unverified` until an operator resolves -the conflict if these sources disagree, or if the Device UID differs from -`deviceRef.uid`. +the conflict if the Device UID differs from `deviceRef.uid`, or if a live +MachineAllocation exists alongside any of these: + +- `Retired` in inventory or a `Retire` recovery; +- an unfinished staff operation; or +- a second live MachineAllocation. ### Customer data From 8edf18b8eba4636fe0586d5407ed862e226a0023 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:08:07 -0600 Subject: [PATCH 07/13] docs: Resolve custody conflicts raised by the power spec - Milo calls the creator webhook from its root API server, because it does not apply admission policies stored in a project. - Sites hold no credentials that can change custody, operations, or allocations; BMC discovery may write only Device status. - Workers refuse a BMC whose TLS key another Device's BMC also uses. - Each kind defines its result evidence, which the coordinator copies to operation status from the site's retained result. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index c3a561ef..da4e2f81 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -174,7 +174,10 @@ result. Every operation has a device, an authority, and inputs. A Fleet admission webhook records the authenticated creator on each operation when it is -created. Clients cannot set or change that field. +created. Clients cannot set or change that field. Milo calls the webhook from +its root API server for project resources, the same way it calls capacity +registration, because Milo does not apply admission policies stored in a +project. | Kind | Creator | Authority | Required holder | Inputs | | --- | --- | --- | --- | --- | @@ -227,8 +230,8 @@ plus `Pending`: | `Cancelled` | Ended before admission: replaced, expired, or no longer matching the holder. | | `OutcomeUnknown` | A command may have reached the server, and Fleet cannot prove the result. | -Custody holds the phase and result of the active operation. Operation status is -a copy of custody. The coordinator admits the next operation only after it +Custody holds the phase and result of the active operation, and operation +status copies them. The coordinator admits the next operation only after it copies the previous result to the previous operation's status. If that operation no longer exists, the coordinator skips the copy. @@ -274,7 +277,8 @@ only physical work. The federation layer delivers each admitted operation, its device snapshot, and its sealed inputs to the site. The snapshot holds the BMC endpoint, system UUID, boot MAC address, and BMC key digest that the coordinator captured at -admission. Sites never read project APIs. +admission. Sites hold no credentials that can change custody, operations, or +allocations. BMC discovery runs in the site and can write only Device status. Each site stores the highest fence it has seen for each Device. When an operation arrives with a higher fence, the site raises its stored fence and @@ -284,7 +288,7 @@ The site runs one worker per operation. The worker: 1. reads that Device's BMC credential from the site; 2. checks the BMC's TLS key and the system identity, and fails without sending - anything on a mismatch; + anything on a mismatch or if another Device's BMC uses the same key; 3. records each step in the site journal before sending it, and the journal refuses a step whose fence is below the stored fence; 4. after a crash or lost response, queries the server instead of sending again; @@ -294,6 +298,11 @@ The site runs one worker per operation. The worker: The site returns results with the operation's fence. The coordinator accepts a result only if its fence matches the active operation's fence. +Each kind defines the evidence its result carries, such as the power state +before and after a reset. The coordinator copies that evidence to the +operation's status, and the site keeps each result until the coordinator has +copied it. + ### Unknown outcomes An operation ends as `OutcomeUnknown` when its deadline passes without a From 9281c31fb89ee963f703791de8fc5e76d9282de1 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:09:11 -0600 Subject: [PATCH 08/13] docs: Close rebuild, key, and evidence gaps in custody - Rebuilt custody stays Unverified when any two sources set different holders, not only when an allocation is involved. - Admission refuses a Device whose BMC key digest another Device records, since one site cannot see other sites' keys. - BMC discovery writes status only for the Devices its site serves. - Custody records result evidence with the result, and the site deletes its copy once the coordinator accepts the result. - Drop the undefined capacity registration reference. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index da4e2f81..139ec146 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -175,9 +175,8 @@ result. Every operation has a device, an authority, and inputs. A Fleet admission webhook records the authenticated creator on each operation when it is created. Clients cannot set or change that field. Milo calls the webhook from -its root API server for project resources, the same way it calls capacity -registration, because Milo does not apply admission policies stored in a -project. +its root API server, because Milo does not apply admission policies stored in +a project. | Kind | Creator | Authority | Required holder | Inputs | | --- | --- | --- | --- | --- | @@ -230,8 +229,8 @@ plus `Pending`: | `Cancelled` | Ended before admission: replaced, expired, or no longer matching the holder. | | `OutcomeUnknown` | A command may have reached the server, and Fleet cannot prove the result. | -Custody holds the phase and result of the active operation, and operation -status copies them. The coordinator admits the next operation only after it +Custody holds the phase, result, and result evidence of the active operation, +and operation status copies them. The coordinator admits the next operation only after it copies the previous result to the previous operation's status. If that operation no longer exists, the coordinator skips the copy. @@ -248,6 +247,7 @@ only if all of these hold: 4. No operation is active. 5. The Device UID matches `deviceRef.uid`, and its identity matches current discovery. +6. No other Device records the same BMC key digest. Under a recovery hold, only the operations in [Unknown outcomes](#unknown-outcomes) are admitted. @@ -278,7 +278,8 @@ The federation layer delivers each admitted operation, its device snapshot, and its sealed inputs to the site. The snapshot holds the BMC endpoint, system UUID, boot MAC address, and BMC key digest that the coordinator captured at admission. Sites hold no credentials that can change custody, operations, or -allocations. BMC discovery runs in the site and can write only Device status. +allocations. BMC discovery runs in the site and can write only the status of +the Devices that site serves. Each site stores the highest fence it has seen for each Device. When an operation arrives with a higher fence, the site raises its stored fence and @@ -288,7 +289,7 @@ The site runs one worker per operation. The worker: 1. reads that Device's BMC credential from the site; 2. checks the BMC's TLS key and the system identity, and fails without sending - anything on a mismatch or if another Device's BMC uses the same key; + anything on a mismatch; 3. records each step in the site journal before sending it, and the journal refuses a step whose fence is below the stored fence; 4. after a crash or lost response, queries the server instead of sending again; @@ -299,9 +300,9 @@ The site returns results with the operation's fence. The coordinator accepts a result only if its fence matches the active operation's fence. Each kind defines the evidence its result carries, such as the power state -before and after a reset. The coordinator copies that evidence to the -operation's status, and the site keeps each result until the coordinator has -copied it. +before and after a reset. The coordinator records the evidence in custody with +the result. The site deletes its copy after the coordinator accepts the +result. ### Unknown outcomes @@ -365,12 +366,9 @@ operation and cannot be allocated. The coordinator rebuilds custody from: The coordinator marks custody `Verified` only after every site that serves the Device reports its fence. Custody stays `Unverified` until an operator resolves -the conflict if the Device UID differs from `deviceRef.uid`, or if a live -MachineAllocation exists alongside any of these: - -- `Retired` in inventory or a `Retire` recovery; -- an unfinished staff operation; or -- a second live MachineAllocation. +the conflict if two sources set different holders, if two live +MachineAllocations name the Device, or if the Device UID differs from +`deviceRef.uid`. ### Customer data From f4777cb987fe6b0e037a0e487dc8e43cf9739965 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:10:01 -0600 Subject: [PATCH 09/13] docs: Release rejected site results and skip retired key matches - The site deletes a result once the coordinator accepts or rejects it, so a stale result from a superseded operation is not kept. - The duplicate BMC key check ignores retired Devices, so a retired server's digest cannot block admission or recovery. - Rewrap the operation status paragraph. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index 139ec146..e2b64738 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -230,9 +230,9 @@ plus `Pending`: | `OutcomeUnknown` | A command may have reached the server, and Fleet cannot prove the result. | Custody holds the phase, result, and result evidence of the active operation, -and operation status copies them. The coordinator admits the next operation only after it -copies the previous result to the previous operation's status. If that -operation no longer exists, the coordinator skips the copy. +and operation status copies them. The coordinator admits the next operation +only after it copies the previous result to the previous operation's status. +If that operation no longer exists, the coordinator skips the copy. ### Admission @@ -247,7 +247,7 @@ only if all of these hold: 4. No operation is active. 5. The Device UID matches `deviceRef.uid`, and its identity matches current discovery. -6. No other Device records the same BMC key digest. +6. No other Device that is not retired records the same BMC key digest. Under a recovery hold, only the operations in [Unknown outcomes](#unknown-outcomes) are admitted. @@ -301,8 +301,8 @@ result only if its fence matches the active operation's fence. Each kind defines the evidence its result carries, such as the power state before and after a reset. The coordinator records the evidence in custody with -the result. The site deletes its copy after the coordinator accepts the -result. +the result. The site deletes its copy after the coordinator accepts or rejects +the result. ### Unknown outcomes From 3907eec183616cfc6f08580d32447cd2887442a8 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:22:17 -0600 Subject: [PATCH 10/13] docs: Settle custody gaps found while planning implementation - The client sets the creator to itself, and a validating webhook rejects any other value, since mutating webhooks at Milo's root are unproven. - OutcomeUnknown moves the operation from activeOperation into the recovery hold. - Settling raises the fence, so the site stops the held worker before newer work; a DeviceRecovery applies after the site reports it. - DeviceRecovery decisions are Settle, Retry, Retire, and Resolve. Retry authorizes one settling operation such as a new wipe, and Resolve names the holder of Unverified custody. - Refusals end as Failed; rebuild treats any operation that has not ended as held; a lost site is removed from the Device in inventory. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 57 +++++++++++-------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index e2b64738..00dbf406 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -172,11 +172,10 @@ result. #### Operations -Every operation has a device, an authority, and inputs. A Fleet admission -webhook records the authenticated creator on each operation when it is -created. Clients cannot set or change that field. Milo calls the webhook from -its root API server, because Milo does not apply admission policies stored in -a project. +Every operation has a device, an authority, inputs, and a creator. The creator +must equal the authenticated caller. A Fleet validating webhook rejects any +other value and any change to it. Milo calls the webhook from its root API +server, because Milo does not apply admission policies stored in a project. | Kind | Creator | Authority | Required holder | Inputs | | --- | --- | --- | --- | --- | @@ -185,7 +184,7 @@ a project. | `DevicePowerOperation` | Staff power operator | `serviceRequest` | `None` | Power action, reason, expected system UUID | | `DeviceWipe` | Release controller | `allocationRef` | `Release` | Cleaning policy digest pinned at allocation, target disks | | `DeviceCommissioning` | Staff commissioning operator | `serviceRequest` | `None`, or `Service` under a commissioning hold | Commissioning plan and digest | -| `DeviceRecovery` | Staff recovery operator | `serviceRequest` | Any, with a recovery hold | Held operation, evidence, and a decision: `Settle` or `Retire` | +| `DeviceRecovery` | Staff recovery operator | `serviceRequest` | Any with a recovery hold, or `Unverified` custody | Evidence and a decision: `Settle`, `Retry`, `Retire`, or `Resolve` | No other creator and authority pairs are valid. Staff roles can read custody, operations, and MachineAllocations. @@ -199,7 +198,7 @@ metadata: name: alloc-3b9d61c2-install-1 namespace: default spec: - creator: system:serviceaccount:fleet-system:metal-provider # set by the webhook + creator: system:serviceaccount:fleet-system:metal-provider # must be the caller deviceRef: {name: server-example-001} authority: allocationRef: {name: alloc-3b9d61c2} @@ -225,7 +224,7 @@ plus `Pending`: | `Dispatched` | The site accepted the operation. | | `Verifying` | The site is checking the success test. | | `Succeeded` | The success test passed. | -| `Failed` | Nothing was sent, or the server refused and did not change. | +| `Failed` | Admission refused it, nothing was sent, or the server refused and did not change. | | `Cancelled` | Ended before admission: replaced, expired, or no longer matching the holder. | | `OutcomeUnknown` | A command may have reached the server, and Fleet cannot prove the result. | @@ -241,7 +240,8 @@ If that operation no longer exists, the coordinator skips the copy. The coordinator admits an operation with one conditional update to custody, only if all of these hold: -1. Custody is `Verified`. +1. Custody is `Verified`, or the operation is a `DeviceRecovery` with + `Resolve`. 2. The creator, authority, and holder match a row of the operations table. 3. An `allocationRef` names the holder's allocation. 4. No operation is active. @@ -308,28 +308,38 @@ the result. An operation ends as `OutcomeUnknown` when its deadline passes without a proven result, or when the site cannot prove what the server did. The -coordinator then sets a recovery hold on custody, and the holder stays. +coordinator then moves it from `activeOperation` to `recoveryHold`. The holder +stays. While a hold exists: - the server cannot return to `None`; - a held `Allocation` can still move to `Release`, and the hold moves with it; and -- the coordinator admits only the settling operations in this table, and only - after the site confirms that the held operation's worker has stopped. +- the coordinator admits only the settling operations in this table. + +Admitting a settling operation raises the fence, so the site stops the held +worker before it starts newer work. A `DeviceRecovery` sends nothing to the +server, but it is delivered the same way. The coordinator applies it only after +the site reports the raised fence. | Held operation | Settled by | | --- | --- | | Power | A `DeviceRecovery` with fresh discovery evidence of the power state | | Installation | A later `DeviceInstallation` that succeeds, or a `DeviceWipe` that succeeds after release | -| Wipe | A later `DeviceWipe` that succeeds | +| Wipe | A `DeviceRecovery` with `Retry`, then a later `DeviceWipe` that succeeds | | Commissioning | A later `DeviceCommissioning` that succeeds | -Settling a hold returns a `Service` holder to `None` and leaves an -`Allocation` or `Release` holder in place. A `DeviceRecovery` with decision -`Retire` sets a `Service` or `Release` holder to `Retired`. Retiring from -`Release` records how the disks were disposed of. Fleet never retries an -operation automatically. +`DeviceRecovery` decisions: + +- `Settle` clears the hold. It returns a `Service` holder to `None` and leaves + an `Allocation` or `Release` holder in place. +- `Retry` lets the held operation's requester create one settling operation. + Fleet never retries an operation automatically. +- `Retire` sets a `Service` or `Release` holder to `Retired`. Retiring from + `Release` records how the disks were disposed of. +- `Resolve` names the holder of `Unverified` custody. See [Rebuilding + custody](#rebuilding-custody). ### Write order and crash recovery @@ -351,16 +361,16 @@ history after that. ### Rebuilding custody If custody is missing for an existing Device, for example after a restore, the -coordinator creates it as `Unverified`. An `Unverified` server admits no -operation and cannot be allocated. The coordinator rebuilds custody from: +coordinator creates it as `Unverified`. An `Unverified` server cannot be +allocated and admits only a `DeviceRecovery` with `Resolve`. The coordinator rebuilds custody from: - the Device's inventory lifecycle and `Retire` recoveries, which set `Retired`; - live MachineAllocations for the Device, which set `Allocation` or `Release`. A rebuilt `Release` reopens every release gate, and the release controller verifies each again; -- unfinished operations, which set a recovery hold, and set `Service` for a - staff operation; and +- operations that have not ended, even if their status still says `Pending`, + which set a recovery hold, and set `Service` for a staff operation; and - each site's stored fence, which sets the new fence above every fence already used. @@ -368,7 +378,8 @@ The coordinator marks custody `Verified` only after every site that serves the Device reports its fence. Custody stays `Unverified` until an operator resolves the conflict if two sources set different holders, if two live MachineAllocations name the Device, or if the Device UID differs from -`deviceRef.uid`. +`deviceRef.uid`. If a site is lost, an operator removes it from the Device's +sites in inventory, and the rebuild continues without it. ### Customer data From abb1f880e46660690a405ab15ff627916d103812 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 20:32:09 -0600 Subject: [PATCH 11/13] docs: Let kinds add admission checks and retry power holds - Kinds can add checks of their own inputs, with their own refusal reasons. #174 defines the shared reasons, including SharedPublicKey and Expired, so every kind reports the same names. - A power hold can also be settled with Retry and a later power operation. Provider power operations are named from the Machine generation and its Retry count, so a retry gets a new name. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index 00dbf406..8aade953 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -209,9 +209,9 @@ spec: ``` Provider and release operations get names from the allocation and the request: -the Installation for installs, the Machine generation for power, and the step -number for wipes. Staff operations get generated names, because each one is a -new request. +the Installation for installs, the Machine generation and its `Retry` count for +power, and the step number for wipes. Staff operations get generated names, +because each one is a new request. The operation phases are those of the [machine lifecycle operation](../machine-lifecycle/README.md#provider-execution-and-recovery), @@ -248,6 +248,21 @@ only if all of these hold: 5. The Device UID matches `deviceRef.uid`, and its identity matches current discovery. 6. No other Device that is not retired records the same BMC key digest. +7. Every check that the operation's kind defines for its own inputs passes. + +A kind can add checks of its own inputs, such as the expected system UUID, and +its own refusal reasons. Every kind uses these shared reasons: + +| Reason | Rule | +| --- | --- | +| `CustodyUnverified` | 1 | +| `CreatorNotPermitted` | 2 | +| `HolderMismatch` | 2 or 3 | +| `OperationInProgress` | 4 | +| `RecoveryHold` | A hold admits only its settling operations | +| `DeviceIdentityMismatch` | 5 | +| `SharedPublicKey` | 6 | +| `Expired` | Not admitted in time; the operation ends as `Cancelled` | Under a recovery hold, only the operations in [Unknown outcomes](#unknown-outcomes) are admitted. @@ -325,7 +340,7 @@ the site reports the raised fence. | Held operation | Settled by | | --- | --- | -| Power | A `DeviceRecovery` with fresh discovery evidence of the power state | +| Power | A `DeviceRecovery` with `Settle` and fresh discovery evidence of the power state, or with `Retry`, then a later `DevicePowerOperation` that succeeds | | Installation | A later `DeviceInstallation` that succeeds, or a `DeviceWipe` that succeeds after release | | Wipe | A `DeviceRecovery` with `Retry`, then a later `DeviceWipe` that succeeds | | Commissioning | A later `DeviceCommissioning` that succeeds | From 23c583fb0d542a79f4b0abcfe14c03a7b374e225 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 20:33:27 -0600 Subject: [PATCH 12/13] docs: Define how Retry names and admits settling operations - Staff power can settle its own hold from Service, like commissioning. - Any operation created after a Retry takes the held operation's name plus a retry count that custody records with the hold, so retries never collide with the held name, for power and wipes alike. - Pending replacement never cancels a settling operation, and other operations wait until the hold is settled. A Retry is used when its operation is admitted, and applies only where the table requires it. - Expired moves out of the refusal table into the staff expiry rule, and the duplicated hold sentence is gone. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 46 ++++++++++--------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index 8aade953..4e986496 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -181,7 +181,7 @@ server, because Milo does not apply admission policies stored in a project. | --- | --- | --- | --- | --- | | `DeviceInstallation` | Fleet provider for Metal | `allocationRef` | `Allocation` | Image digest, bootstrap reference and digest, boot interface, target disks | | `DevicePowerOperation` | Fleet provider for Metal | `allocationRef` | `Allocation` | Power action | -| `DevicePowerOperation` | Staff power operator | `serviceRequest` | `None` | Power action, reason, expected system UUID | +| `DevicePowerOperation` | Staff power operator | `serviceRequest` | `None`, or `Service` under a power hold | Power action, reason, expected system UUID | | `DeviceWipe` | Release controller | `allocationRef` | `Release` | Cleaning policy digest pinned at allocation, target disks | | `DeviceCommissioning` | Staff commissioning operator | `serviceRequest` | `None`, or `Service` under a commissioning hold | Commissioning plan and digest | | `DeviceRecovery` | Staff recovery operator | `serviceRequest` | Any with a recovery hold, or `Unverified` custody | Evidence and a decision: `Settle`, `Retry`, `Retire`, or `Resolve` | @@ -209,9 +209,11 @@ spec: ``` Provider and release operations get names from the allocation and the request: -the Installation for installs, the Machine generation and its `Retry` count for -power, and the step number for wipes. Staff operations get generated names, -because each one is a new request. +the Installation for installs, the Machine generation for power, and the step +number for wipes. Staff operations get generated names, because each one is a +new request. An operation created after a `Retry` takes the held operation's +name plus `-retry-` and the number of `Retry` decisions for that operation, +which custody records with the hold. The operation phases are those of the [machine lifecycle operation](../machine-lifecycle/README.md#provider-execution-and-recovery), @@ -253,19 +255,15 @@ only if all of these hold: A kind can add checks of its own inputs, such as the expected system UUID, and its own refusal reasons. Every kind uses these shared reasons: -| Reason | Rule | +| Reason | Refused by | | --- | --- | -| `CustodyUnverified` | 1 | -| `CreatorNotPermitted` | 2 | -| `HolderMismatch` | 2 or 3 | -| `OperationInProgress` | 4 | -| `RecoveryHold` | A hold admits only its settling operations | -| `DeviceIdentityMismatch` | 5 | -| `SharedPublicKey` | 6 | -| `Expired` | Not admitted in time; the operation ends as `Cancelled` | - -Under a recovery hold, only the operations in [Unknown -outcomes](#unknown-outcomes) are admitted. +| `CustodyUnverified` | Rule 1 | +| `CreatorNotPermitted` | Rule 2 | +| `HolderMismatch` | Rule 2 or 3 | +| `OperationInProgress` | Rule 4 | +| `DeviceIdentityMismatch` | Rule 5 | +| `SharedPublicKey` | Rule 6 | +| `RecoveryHold` | A [recovery hold](#unknown-outcomes) | The update sets the active operation, raises the fence, and sets a deadline. A staff operation admitted from holder `None` also sets the holder to `Service`. @@ -274,13 +272,16 @@ evaluates again. Provider and release operations wait in `Pending` while another operation runs, and are admitted oldest first. A newer power operation for the same -allocation cancels an older pending one. When the holder changes, the -coordinator cancels every pending operation that no longer matches it. +allocation cancels an older pending one, except an operation that settles a +hold. Other operations wait in `Pending` until the hold is settled. When the +holder changes, the coordinator cancels every pending operation that no longer +matches it. Staff operations never wait behind another operation. Admission refuses a staff operation that cannot run now, because a queued request could run after its reason is gone. A staff operation not admitted within five minutes, for -example because the coordinator is down, expires. +example because the coordinator is down, ends as `Cancelled` with reason +`Expired`. Metal admission, including IAM, entitlement, and quota, still follows the [machine lifecycle admission @@ -349,7 +350,9 @@ the site reports the raised fence. - `Settle` clears the hold. It returns a `Service` holder to `None` and leaves an `Allocation` or `Release` holder in place. -- `Retry` lets the held operation's requester create one settling operation. +- `Retry` lets the held operation's requester create one settling operation, + where the settlement table requires it. The `Retry` is used when that + operation is admitted. Fleet never retries an operation automatically. - `Retire` sets a `Service` or `Release` holder to `Retired`. Retiring from `Release` records how the disks were disposed of. @@ -377,7 +380,8 @@ history after that. If custody is missing for an existing Device, for example after a restore, the coordinator creates it as `Unverified`. An `Unverified` server cannot be -allocated and admits only a `DeviceRecovery` with `Resolve`. The coordinator rebuilds custody from: +allocated and admits only a `DeviceRecovery` with `Resolve`. The coordinator +rebuilds custody from: - the Device's inventory lifecycle and `Retire` recoveries, which set `Retired`; From d4d17f9b4a34307d190efb0cea59dde2f26662ee Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 20:34:24 -0600 Subject: [PATCH 13/13] docs: Name the retry count and refuse stray Retry decisions - The custody example names what the recovery hold carries: the held operation, its Retry count, and whether a Retry is unused. - Admission accepts a Retry only where the settlement table requires one and only when no earlier Retry for that hold is unused, so the retry name cannot change under an operation already created. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-operations/README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/enhancements/device-operations/README.md b/docs/enhancements/device-operations/README.md index 4e986496..2ad6ac02 100644 --- a/docs/enhancements/device-operations/README.md +++ b/docs/enhancements/device-operations/README.md @@ -141,6 +141,8 @@ spec: phase: Dispatched deadline: "2026-11-24T19:10:00Z" lastResult: {name: alloc-3b9d61c2-install-1, result: Succeeded} + # After an Unknown outcome: the held operation, its Retry count, and + # whether a Retry is unused. recoveryHold: null ``` @@ -350,10 +352,11 @@ the site reports the raised fence. - `Settle` clears the hold. It returns a `Service` holder to `None` and leaves an `Allocation` or `Release` holder in place. -- `Retry` lets the held operation's requester create one settling operation, - where the settlement table requires it. The `Retry` is used when that - operation is admitted. - Fleet never retries an operation automatically. +- `Retry` lets the held operation's requester create one settling operation. + Fleet never retries an operation automatically. Admission accepts a `Retry` + only for a hold whose row in the settlement table requires one, and only + when no earlier `Retry` for that hold is unused. The `Retry` raises the + hold's count and is used when its settling operation is admitted. - `Retire` sets a `Service` or `Release` holder to `Retired`. Retiring from `Release` records how the disks were disposed of. - `Resolve` names the holder of `Unverified` custody. See [Rebuilding