From 7dbd09af37b4356e5b0fc9a212b3d24face319f0 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 14:50:44 -0600 Subject: [PATCH 01/26] docs: Propose staff power operations on Devices Staff power-cycle newly racked or hung servers through each BMC's own interface today. Fleet keeps no record of who did it, the action uses credentials outside the pinned per-Device Secrets, and nothing stops a reset of a server that backs capacity. The proposal adds a one-shot DevicePowerOperation resource. A cell dispatcher accepts it after checking the Device's recorded system UUID, current discovery, offered reset types and capacity. It then starts one worker Job in discovery's credential namespace that mounts only that Device's credential, sends a single reset, and reports Succeeded, Failed or Unknown from observed power state. The dispatcher holds the Lease verbs it grants each worker, because Kubernetes RBAC refuses a Role its creator could not use itself. Cell admission policies pin the shape of every Job, Role and RoleBinding it creates, since its right to create Jobs otherwise reaches every credential Secret in that namespace. It refuses Devices that back a MachineCapacity rather than Devices with a DeviceClaim, because every Device binds a DeviceClaim. Links to integration-branch code pin a commit. Open questions that need a reviewer's decision are listed in the document. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 + docs/README.md | 2 +- docs/architecture/README.md | 1 + docs/enhancements/device-power/README.md | 703 +++++++++++++++++++++++ 4 files changed, 707 insertions(+), 1 deletion(-) create mode 100644 docs/enhancements/device-power/README.md diff --git a/README.md b/README.md index 778018b3..323b42ee 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,8 @@ today. Then choose a topic: The [Bare Metal CLI enhancement](docs/enhancements/metal-cli/README.md) proposes `datumctl metal` discovery, machine management, and safe recovery workflows. +The [Device power enhancement](docs/enhancements/device-power/README.md) +proposes staff power operations on unallocated physical Devices. Contributors should also read the [repository guidance](AGENTS.md) and [implementation roadmap](docs/development/roadmap.md). diff --git a/docs/README.md b/docs/README.md index 2faee964..13378048 100644 --- a/docs/README.md +++ b/docs/README.md @@ -71,7 +71,7 @@ Each topic folder has a `README.md` entry point: | [Operations](operations/README.md) | Deployment, validation, and local smoke tests | | [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 | +| [Enhancements](enhancements/machine-lifecycle/README.md) | Focused machine lifecycle contracts and acceptance requirements, plus [Device power operations](enhancements/device-power/README.md) | | [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..62805d49 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -38,6 +38,7 @@ Key principles to carry into the detailed design: | How are reservations and concurrent operations coordinated? | [Durable coordination](../enhancements/machine-lifecycle/README.md#durable-coordination) | | 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) | +| How do staff power-control an unallocated Device? | [Device power operations](../enhancements/device-power/README.md) | | Which internal interfaces and guarantees exist? | [Implementation status](../development/README.md) | | Which milestones must precede rollout? | [Implementation roadmap](../development/roadmap.md) | | Where did the design originate? | [Pinned source proposals](design.md#source-proposals), [migration record](../proposals/fleet-management/MIGRATION.md) | diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md new file mode 100644 index 00000000..e3fdd6a6 --- /dev/null +++ b/docs/enhancements/device-power/README.md @@ -0,0 +1,703 @@ +--- +status: provisional +stage: alpha +--- + +# Staff power operations on physical Devices + +[Documentation overview](../../README.md) · [Architecture guide](../../architecture/README.md) + +- [Summary](#summary) +- [Motivation](#motivation) + - [Goals](#goals) + - [Non-goals](#non-goals) +- [What exists today](#what-exists-today) +- [Proposal](#proposal) + - [User stories](#user-stories) + - [Why a separate resource](#why-a-separate-resource) +- [Design details](#design-details) + - [API](#api) + - [Admission](#admission) + - [Acceptance checks](#acceptance-checks) + - [Dispatch](#dispatch) + - [Worker](#worker) + - [Outcomes](#outcomes) + - [Failure handling](#failure-handling) + - [Identities and permissions](#identities-and-permissions) + - [Redfish client and discovery changes](#redfish-client-and-discovery-changes) + - [Relationship to Machine power](#relationship-to-machine-power) + - [Staff UI](#staff-ui) + - [Security boundaries](#security-boundaries) +- [Delivery phases](#delivery-phases) +- [Acceptance tests](#acceptance-tests) +- [Production readiness review questionnaire](#production-readiness-review-questionnaire) +- [Drawbacks](#drawbacks) +- [Alternatives](#alternatives) +- [Open design questions](#open-design-questions) +- [Infrastructure needed](#infrastructure-needed) + +## Summary + +Staff need to turn an unallocated physical server on or off, or reset it, +without logging in to its BMC by hand. This proposal adds a one-shot +`DevicePowerOperation` resource in `fleet.datumapis.com`. A staff member +creates one to request a single Redfish `ComputerSystem.Reset` on one Device. A +dispatcher in the cell that can reach the BMC checks the request and starts one +worker Job for it. The worker holds only that Device's BMC credential. It +re-checks the system identity, sends the reset once, watches the power state, +and reports a result: `Succeeded`, `Failed` or `Unknown`. + +Operations are refused while the Device backs capacity. Power on an allocated +machine stays with `Machine.spec.powerState` from the +[machine lifecycle enhancement](../machine-lifecycle/README.md). That path can +later reuse the same worker. + +Everything in this document is proposed. Nothing described under +[Design details](#design-details) is implemented. + +## Motivation + +Bringing up and maintaining hardware needs basic power control: power on a +newly racked server so discovery can read its inventory, power off a server +before moving it, or reset one that hangs during qualification. Today staff do +this in the BMC's own web interface or with ad hoc tools. That has four +problems: + +- Fleet has no record of who changed power on which asset, or when. +- Staff use BMC credentials directly, outside the per-Device credential + Secrets and TLS pins that discovery already relies on. +- Nothing stops a reset of a server that a customer is using. +- Nothing ties the action to the exact hardware staff looked at. A swapped or + renumbered system behind the same BMC address gets the reset instead. + +### Goals + +- Let authorized staff request `On`, `ForceOff`, `ForceRestart` and + `PowerCycle` on an unallocated Device, and see the result. +- Send at most one reset per request, to the exact Redfish system staff named. +- Report a lost or unprovable outcome as `Unknown`, never as success, and never + retry it automatically. +- Keep BMC credentials in the cell, readable only by discovery and by the one + worker of each operation. +- Record who asked, why, and the power state observed before and after. +- Build an executor that the Machine power path can reuse. + +### Non-goals + +- Power on allocated or capacity-backed Devices. That belongs to the Machine + and its allocation authority. +- Persistent power intent for Devices. A Device has no desired power state. +- Graceful shutdown or restart, `Nmi` and `PushPowerButton`. See + [open questions](#open-design-questions). +- Boot source overrides, virtual media, BMC settings or firmware. +- Power distribution units or `PowerFeed` control. +- A general BMC access broker for staff. + +## What exists today + +These pieces exist on the integration branch `feat/manual-inventory-records`, +which is ahead of `main`. They are not yet on `main`. Links below point to +that branch at commit +[`7b97c6b`](https://github.com/datum-cloud/fleet/tree/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb). + +| Piece | Where | What it does | +| --- | --- | --- | +| Redfish client | `internal/redfish/client.go` | `Discover` walks the Systems collection with `GET` only and requires `On`, `ForceOff` and the `Pxe` and `Hdd` boot targets. It takes an installation enrollment `Target`. `Reset` sends exactly one `ComputerSystem.Reset` `POST`, never retries, and does not treat HTTP success as proof of the effect. `Observe` re-reads the System and re-checks its Id and UUID. | +| TLS pinning | `internal/redfish/pin.go` | `NewPinnedClient` accepts a BMC only when its leaf public key hashes to the approved pin, on every connection, before any credential is sent. | +| Installation provider | `internal/redfish/provider.go` | Runs `ForceOff`, a one-time boot override, then `On`, with a journal. It observes after a lost `ForceOff`, because power off before a boot is idempotent. It repeats `On` only when the target is still off and still armed after a settle window, within a budget of three. It reads one shared credential and takes no TLS pin. | +| BMC discovery | `internal/bmcdiscovery`, [BMC discovery guide](https://github.com/datum-cloud/fleet/blob/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb/docs/operations/bmc-discovery.md) | A single cell-side replica. It reads one credential Secret per Device (username, password, TLS pin), reads the inventory with `GET` only, and writes `Device.status`. It never changes power, boot or BMC settings. | +| Device API | `internal/api/inventory/v1alpha1/types.go` | `Device.status.discovery.inventory.systems[]` records each `ObservedSystem`, including `powerState`. It does not record which `ResetType` values the BMC offers. Device status has one writer: discovery. | +| Site execution | [Site execution guide](https://github.com/datum-cloud/fleet/blob/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb/docs/operations/site-execution.md) | Per-operation worker Jobs in the cell, each with its own ServiceAccount and a Role scoped to one object. Workers never write status; a separate observer does. | +| Redfish lab | `hack/redfish-lab`, [Redfish lab guide](https://github.com/datum-cloud/fleet/blob/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb/docs/operations/redfish-lab.md) | The DMTF emulator with a lab adapter. It implements `On`, `ForceOff` and `ForceRestart` and can inject `reject-auth`, `hide-reset` and `drop-response` faults. It serves plain HTTP. | + +Two facts in the current code shape this design: + +- **`DeviceClaim` is not an allocation.** It records a planned installation, + and every Device binds one through the required `spec.claimRef`. Capacity + that consumers can allocate is a `MachineCapacity` whose `spec.deviceRef` + names the Device. This proposal therefore refuses operations on Devices that + back a `MachineCapacity`, not on Devices that have a claim. +- **Device has no `Ready` condition.** Discovery reports `Reachable`, + `Authenticated`, `Discovered`, `IdentityMatched` and `PublicKeyUnique`. The + [acceptance checks](#acceptance-checks) name the exact conditions required. + +The [bare-metal hardware proposal](../../proposals/fleet-management/bare-metal-hardware.md) +states the rule for allocated machines: "reconcile persistent On/Off intent. +Reboot/reset is a bounded, idempotent operation with MachineAllocation +preconditions." This proposal applies the bounded-operation half to +unallocated Devices, with Device preconditions in place of allocation ones. + +## Proposal + +### User stories + +- A technician racks a new server. Discovery reports it `Off`. The technician + powers it on from the Device page, and the page shows `On` a minute later. +- Staff qualifying hardware reset a server that hangs in firmware. The page + shows who reset it, when, and that the BMC reported `On` again afterwards. +- Staff power off a server before moving it to another rack. The Device keeps + its identity; only its power changes. +- A server's BMC is replaced and now answers with another system UUID. A power + request made against the old discovery is refused before any reset. +- A staff member tries to restart a server that backs capacity. The request is + refused with `CapacityBacked`, and nothing reaches the BMC. + +### Why a separate resource + +A reset is an event, not a state. `ForceRestart` has no end state to converge +on, and repeating it is a second restart. A field such as +`Device.spec.powerAction` would need a controller to tell an old value from a +new request, and a re-applied manifest would restart the server again. + +A separate resource also keeps one writer per surface: + +| Surface | Writer | +| --- | --- | +| `Device.spec` | The inventory source: an operator or an importer | +| `Device.status` | BMC discovery | +| `DevicePowerOperation.spec` | The staff member who creates it; immutable after creation | +| `DevicePowerOperation.status` | The cell dispatcher | + +Each operation is its own audit record. It keeps the requester, the reason, the +exact target and the observed result after the Device changes. + +## Design details + +### API + +`DevicePowerOperation` is a namespaced kind in `fleet.datumapis.com/v1alpha1`. +It lives in the provider project, in the same namespace as its Device. +The example uses synthetic values. + +```yaml +apiVersion: fleet.datumapis.com/v1alpha1 +kind: DevicePowerOperation +metadata: + name: device-a-restart-1 + namespace: default +spec: + # The Device in this namespace. The operation never follows a rename. + deviceRef: {name: device-a} + # One of On, ForceOff, ForceRestart, PowerCycle. + action: ForceRestart + # The SMBIOS system UUID staff expect behind the BMC, lowercase canonical. + # The operation fails if the Device or the BMC reports another. + expectedSystemUUID: 00000000-0000-4000-8000-0000000000a1 + # Admission requires this to equal the creating user's name. + requester: staff@example.com + reason: Hung in firmware during qualification +status: + conditions: + - {type: Accepted, status: "True", reason: Accepted} + - {type: Executing, status: "False", reason: Finished} + - {type: Finished, status: "True", reason: ResetObserved} + # Succeeded, Failed or Unknown. Absent until Finished is True. + result: Succeeded + # Pinned at acceptance from the Device and its discovery. + target: + deviceUID: 3f0c9a52-0000-4000-8000-000000000001 + endpoint: https://192.0.2.10:443 + systemID: "1" + acceptedAt: "2026-01-02T03:04:00Z" + dispatchedAt: "2026-01-02T03:04:01Z" + # When the worker sent the one reset request. Absent if none was sent. + requestSentAt: "2026-01-02T03:04:06Z" + # Accepted, Refused or Lost: the BMC's answer to the request, not the effect. + response: Accepted + power: + before: {state: "On", observedAt: "2026-01-02T03:04:05Z"} + after: {state: "On", observedAt: "2026-01-02T03:04:41Z"} + # The evidence for a restart: the BMC's LastResetTime, or an observed + # state other than On between the request and the deadline. + resetEvidence: LastResetTime + finishedAt: "2026-01-02T03:04:42Z" +``` + +The API has these rules: + +- **The spec is immutable.** A CRD validation rule `self == oldSelf` covers the + whole spec. A changed intent is a new operation. +- **Every field is required.** `reason` is 1 to 256 characters. There is no + default action. +- **`result` is set once.** After `Finished` is `True`, the status never + changes again. +- **Status never carries a credential, a pin, a URL path, a header or a + response body.** `endpoint` is the Device's `spec.bmc.endpoint`, which is + already in the Device record. + +### Admission + +A `ValidatingAdmissionPolicy` in the Milo project control plane checks what a +single request can show: + +- On create, `spec.requester` equals `request.userInfo.username`. Kubernetes + objects do not record their creator; this check makes the spec field + trustworthy. +- `action` is one of the four values, and `expectedSystemUUID` is lowercase + canonical. +- Only the dispatcher's identity can write status. IAM already enforces this; + the policy repeats it for defense in depth. + +An admission policy cannot read other objects. The checks that need the Device, +its capacity or other operations happen at [acceptance](#acceptance-checks), in +the dispatcher. Until the dispatcher accepts an operation, it has no effect. + +### Acceptance checks + +The dispatcher accepts or refuses each new operation for a Device it serves. It +processes one Device's operations in order of creation time. It sets +`Accepted=True` only when every check below passes. Otherwise it sets +`Accepted=False`, `Finished=True` and `result: Failed` with the reason shown. +A refused operation never reaches the BMC. + +| Check | Reason on failure | +| --- | --- | +| The Device exists in the operation's namespace. | `DeviceNotFound` | +| `spec.lifecycle` is `Active` or `Decommissioning`. | `DeviceRetired` | +| `Device.spec.identity.systemUUID` is set. A Device recorded by serial alone cannot be operated, because the worker selects the Redfish system by UUID. | `SystemUUIDNotRecorded` | +| `expectedSystemUUID` equals `Device.spec.identity.systemUUID`. | `SystemUUIDMismatch` | +| Discovery is current: `Authenticated`, `Discovered` and `IdentityMatched` are `True`; `status.observedGeneration` equals the Device's generation; the inventory endpoint equals `spec.bmc.endpoint`; the inventory is younger than twice the discovery `interval` (two hours at the default of one hour), so one missed pass does not block staff. | `DiscoveryNotCurrent` | +| `PublicKeyUnique` is not `False`. A shared TLS key cannot tell BMCs apart. | `SharedPublicKey` | +| The inventory has exactly one System with the expected UUID. | `SystemNotObserved` | +| That System's recorded `resetTypes` include the action. | `ResetTypeNotOffered` | +| No `MachineCapacity` in the namespace has `spec.deviceRef.name` equal to the Device. | `CapacityBacked` | +| No other operation on the Device is accepted and unfinished. | `OperationInProgress` | +| The operation was created less than five minutes ago. | `Expired` | + +Two decisions are built into this table: + +- **There is no override for capacity-backed Devices.** A Device that backs a + `MachineCapacity` may be allocated, mid-installation or mid-cleanup. The + [PXE installation enhancement](https://github.com/datum-cloud/fleet/blob/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb/docs/enhancements/pxe-installation/README.md#shared-bmc-and-installation-execution) + requires all power effects on an allocation to share one serialization and + fencing domain, with "no lock-free emergency reset path". A staff override + would be that path. Staff who must power-control such a Device first remove + its `MachineCapacity` through the release lifecycle. A future audited + maintenance transition can add a safer path; see + [open questions](#open-design-questions). +- **Operations are refused, not queued.** A second request while one runs is + refused with `OperationInProgress`. A queued request could run minutes later, + after the reason for it has changed. + +The capacity check has a gap. A `MachineCapacity` could be created after the +dispatcher checks and before the worker sends its reset. The dispatcher repeats +the capacity check immediately before it creates the Job. The worker refuses to +start more than two minutes after dispatch. Together these bound the window to +about two minutes. A new `MachineCapacity` defaults to +`allocationPolicy: Disabled`, so it cannot be allocated within that window +without a second operator action. Closing the window fully needs the allocator +to refuse a Device with an unfinished power operation. That change is listed in +[delivery phase 5](#delivery-phases). + +### Dispatch + +The dispatcher is a single-replica Deployment in the cell, next to discovery, +with no leader election and the `Recreate` strategy. It creates worker Jobs in +discovery's credential namespace, because a Pod can mount only Secrets in its +own namespace. Like discovery, it serves +the Device namespaces listed in its configuration. Two dispatchers must never +serve the same namespace. + +```text +staff ──create──▶ DevicePowerOperation (Milo project) + │ watch + ▼ + dispatcher (cell) ── Accepted, then Executing ──▶ operation status + │ create (only after Executing is stored) + ▼ + Job dpo- + ├─ mounts one credential Secret + └─ worker ── claim Lease dpo- (stage, result) + │ + ▼ + BMC (pinned TLS) +``` + +For each accepted operation, the dispatcher: + +1. Re-checks capacity, as described above. +2. Writes `Executing=True` and `dispatchedAt` to the operation status with an + optimistic lock. It never creates a Job for an operation whose status it did + not move to `Executing` itself. +3. Creates a per-operation ServiceAccount, Role and RoleBinding, and a Job named + `dpo-` plus the first 16 hex digits of the SHA-256 of the operation UID. The + deterministic name makes a repeated create fail with `AlreadyExists`. +4. Watches the Job and the worker's claim Lease, and publishes the result to the + operation status. + +The Job runs one Pod with `restartPolicy: Never`, `backoffLimit: 0`, +`podReplacementPolicy: Failed` and `activeDeadlineSeconds: 600`. A worker is +never retried. The dispatcher passes the operation UID, action, expected UUID, +system Id, endpoint and a start deadline two minutes after dispatch as +arguments. + +The Job mounts exactly one Secret: the credential Secret for the target Device. +Today discovery finds that Secret by its annotations, which the dispatcher could +read only with Secret read access. This proposal adds a name rule to the +credential Secret contract instead: the Secret's name is `bmc-` plus the first +20 hex digits of the SHA-256 of `//`. The dispatcher +computes the name and never reads Secrets. Discovery keeps selecting by +annotation, and it logs a warning when a +selected Secret does not have the derived name. + +The dispatcher keeps the Job and the claim Lease until the result is stored in +Milo. It then deletes the per-operation RBAC at once and the Job and Lease after +seven days. + +### Worker + +The worker is a mode of the Fleet image. It holds no Milo credential. Its +ServiceAccount can create Leases in its namespace and get or update only its +own Lease, by `resourceNames`. It runs these steps in order and stops at the +first failure: + +1. **Check the start deadline.** After the deadline it exits with reason + `Stale` and sends nothing. +2. **Claim the operation.** It creates the Lease `dpo-`. If the Lease + already exists, another worker ran or is running for this operation: it + exits with reason `Duplicate` and sends nothing. Kubernetes can start a + Job's Pod twice in rare cases, so the Job alone is not an at-most-once + guarantee. +3. **Load the credential.** It reads `username`, `password` and + `tlsPublicKeySHA256` from the mounted Secret. A missing pin is + `PinNotApproved`. The worker has no unpinned or plain HTTP path. +4. **Connect and re-check identity.** It connects with `NewPinnedClient` and + runs the power-only `DiscoverSystem` with the expected UUID. Exactly one + System must carry the UUID, its Id must equal the pinned system Id, and its + reset target must sit under that System. The worker issues `GET` requests + only in this step. +5. **Check the action.** The BMC must offer the action as a `ResetType` now, + not only at discovery time. +6. **Observe before.** It reads `PowerState`. Then: + - `On` when already `On`, or `ForceOff` when already `Off`, finishes as + `Succeeded` with reason `AlreadyInState`. Nothing is sent. + - `ForceRestart` or `PowerCycle` when not `On` fails with `NotPoweredOn`. + Vendors differ on what a restart of an off system does. + - Any other state, such as `PoweringOn` or an empty value, fails with + `PowerStateNotSettled`. +7. **Record the request.** It writes stage `Requesting` and the time to its + Lease. If that write fails, it exits without sending. From this point on, + a missing result means `Unknown`. +8. **Send once.** It calls `Reset` exactly once. +9. **Observe after.** It polls `Observe` every five seconds until the expected + evidence appears or three minutes pass. Each read re-checks the System Id + and UUID. +10. **Record the result.** It writes the result, reason and observations to its + Lease and exits 0. + +The installation provider repeats `On` when it can prove the first one had no +effect. The power worker does not repeat anything. A staff member who wants +another attempt creates a new operation, which leaves a second audit record and +passes the acceptance checks again. + +### Outcomes + +What counts as evidence depends on the action. HTTP success is never evidence. + +| Action | `Succeeded` requires | Otherwise | +| --- | --- | --- | +| `On` | `PowerState` reads `On` before the deadline | `Unknown`, reason `TargetStateNotObserved` | +| `ForceOff` | `PowerState` reads `Off` before the deadline | `Unknown`, reason `TargetStateNotObserved` | +| `ForceRestart`, `PowerCycle` | `PowerState` reads `On` at the end, and either the BMC's `LastResetTime` is later than `requestSentAt` or a state other than `On` was observed after the request | `Unknown`, reason `ResetNotObserved` | + +The BMC's answer to the request also matters: + +| BMC response | Result | +| --- | --- | +| 2xx | Judged by the evidence above. | +| 400, 401, 403, 404, 405 or 409 | `Failed`, reason `RefusedByBMC`. The worker still observes power once and records it as `after`. If that observation shows a change, the result is `Unknown` instead. | +| 412, any other status, a timeout or a transport error | `response: Lost`. The worker keeps observing. `On` and `ForceOff` can still reach `Succeeded` with reason `ObservedAfterLostResponse`. A restart is `Unknown` unless `LastResetTime` proves it. | + +For `On` and `ForceOff`, this refines the rule that a lost response ends as +`Unknown`. A lost response followed by the requested state, observed through +the pinned client on the exact system, is the same evidence the installation +provider already accepts for `ForceOff`. The result records the lost response +in `response` so staff can see it. Whether to accept it is listed as an +[open question](#open-design-questions). + +A short restart can finish between two polls. A BMC that reports neither +`LastResetTime` nor an intermediate state leaves every restart `Unknown`. +Phase 4 measures this on real hardware before `ForceRestart` and `PowerCycle` +are enabled there. + +### Failure handling + +The dispatcher derives the result from the Job and the Lease when the worker +cannot report: + +| Case | What happens | Result | +| --- | --- | --- | +| Pod or Job lost before the Lease exists | Nothing was sent. | `Failed`, reason `WorkerLost` | +| Pod or Job lost with the Lease at a stage before `Requesting` | Nothing was sent. | `Failed`, reason `WorkerLost` | +| Pod or Job lost with the Lease at `Requesting` and no result | The reset may have been sent. | `Unknown`, reason `WorkerLost` | +| Job missing while the operation is `Executing` | The dispatcher cannot tell whether a worker ran. It never creates a second Job. | `Unknown`, reason `DispatchLost` | +| Dispatcher restarts | It rebuilds its state from operation status, Jobs and Leases. It adopts existing Jobs by name and never re-dispatches an `Executing` operation. | Unchanged | +| Duplicate dispatch: a second Job or Pod for one operation | The second worker finds the Lease and exits with `Duplicate` before contacting the BMC. The second Job's exit does not change the operation. | Unchanged | +| Operation older than five minutes when first seen | Refused at acceptance. | `Failed`, reason `Expired` | +| Worker starts after its deadline, for example a Pod pending on an image pull | The worker exits before claiming. | `Failed`, reason `Stale` | +| Discovery not current | Refused at acceptance. | `Failed`, reason `DiscoveryNotCurrent` | +| TLS pin mismatch, rejected credential, identity mismatch, action no longer offered | The worker stops before sending. | `Failed` with `PinMismatch`, `CredentialRejected`, `IdentityMismatch` or `ResetTypeNotOffered` | +| BMC unreachable after the request | The worker observes until the deadline. | `Unknown`, reason `TargetStateNotObserved` | +| Operation deleted while executing | Deletion does not cancel the reset. The worker finishes. The result stays in the Lease and the worker log. | Not published | + +`Unknown` is a final result for the operation, not a state of the Device. The +next discovery pass reports the Device's power. Staff decide whether to create +another operation. + +### Identities and permissions + +Each component gets its own identity. None inherits another's role. + +| Identity | Milo project permissions | Cell permissions | BMC access | +| --- | --- | --- | --- | +| Staff, role `fleet.datumapis.com-device-power-operator` | `devicepoweroperations` create, get, list, watch; `devices` get, list, watch | None | None | +| Dispatcher, role `fleet.datumapis.com-device-power-dispatcher` | `devicepoweroperations` get, list, watch and status update; `devices` get, list, watch; `metal.datumapis.com/machinecapacities` get, list, watch | In the credential namespace: create, get, list, watch and delete Jobs, ServiceAccounts, Roles and RoleBindings; create, get, list, watch, update and delete Leases. No Secret access, and no `bind` or `escalate`. | None | +| Worker, one ServiceAccount per operation | None | Create Leases; get and update its own Lease | The one mounted credential | +| Discovery, role `fleet.datumapis.com-inventory-discoverer` | Unchanged | Unchanged | Read-only, unchanged | + +The staff role grants no update, patch or delete on operations. A finished +operation is the audit record. Retention is an +[open question](#open-design-questions). + +Kubernetes RBAC lets an identity create a Role only with permissions it +already holds. The dispatcher therefore holds the Lease verbs it grants to +workers, and needs neither `bind` nor `escalate`. Holding them lets the +dispatcher write a Lease itself. That adds no authority, because the dispatcher +already writes the operation's result. + +The workers run in the credential namespace, so the dispatcher's right to +create Jobs reaches every `bmc-*` Secret there. Its own RBAC grants no Secret +read. Two `ValidatingAdmissionPolicies` in the cell are the barrier: they limit +the dispatcher's writes to the worker shape, as the site execution composition +already does for kro. + +- A Job has a name `dpo-` and the Job's own ServiceAccount. +- It runs one container, from the image the dispatcher runs, with the worker + command. +- It mounts exactly one Secret volume, named `bmc-` and 20 hex digits. +- It has no privilege, added capability or host namespace. +- A Role grants only Lease create, and get and update on its own Lease by + `resourceNames`. +- A RoleBinding binds only its own Role to its own ServiceAccount. + +A dispatcher that is compromised could still point a worker at the wrong Device's +Secret or at another endpoint. The pin stops the second case: an endpoint +without that BMC's private key fails the TLS handshake before the credential is +sent. In the first case the worker's UUID check fails and nothing is sent, +unless both Devices share a TLS key. + +### Redfish client and discovery changes + +- **Power-only discovery.** Add `Client.DiscoverSystem(ctx, uuid)`. It reads + every Systems member with `GET` only, requires exactly one member with the + UUID, checks that the reset target and `ActionInfo` sit under that System, and + returns the System with its `ResetTypes`. It requires no boot target, no + `On` or `ForceOff`, and no installation `Target`. `Discover` becomes + `DiscoverSystem` plus the enrolled Id check and the installation checks it + makes today, so the installation provider behaves exactly as before. +- **Reset evidence.** `Observe` also returns `LastResetTime` when the BMC + reports it. +- **Offered reset types in discovery.** `Inventory` reads each System's + `#ComputerSystem.Reset` allowable values, and its `ActionInfo` with one more + `GET` when the values are not inline. `ObservedSystem` gains `resetTypes`. + An empty list means the BMC did not report any, and every operation on that + System is refused. Discovery stays read-only: it reads the action's + description and never invokes it. +- **No fault hooks** in `internal/redfish`. Faults stay in the lab adapter. + +### Relationship to Machine power + +`Machine.spec.powerState` is persistent On or Off intent on an allocated +Machine, owned by the consumer. `DevicePowerOperation` is a one-shot staff +action on an unallocated Device. They never act on the same hardware at the +same time: + +- A Device power operation is refused while any `MachineCapacity` names the + Device. A Machine exists only on allocated capacity. +- After phase 5, the allocator refuses to allocate capacity whose Device has an + unfinished power operation. + +The Machine path reuses the executor, not the resource. A location-side Machine +power reconciler receives intent through the coordination handoff and starts the +same worker, with these differences: + +| | Device power operation | Machine power | +| --- | --- | --- | +| Authority | Staff role and Device acceptance checks | MachineAllocation, its generation and the per-allocation fence | +| Intent | One action | Persistent On or Off, plus a bounded reset operation | +| Serialization | One unfinished operation per Device | Shared with installation and release for the allocation | +| Result | `DevicePowerOperation.status` | Machine `status.power`, through the projector | + +The shared parts are `DiscoverSystem`, the pinned client, the claim record, the +single-request rule and the outcome table. + +### Staff UI + +The Device page in the provider UI gets a power control next to the observed +power state: + +- A power button with a menu of the actions the Device's discovery reports as + offered. Disabled actions carry their refusal reason, such as + `CapacityBacked`, in a tooltip. +- A confirm dialog that shows the action, the Device name and the last four + characters of the system UUID, and a required reason field. Confirming + creates the operation with the UUID from discovery. +- While an operation runs, the control shows a spinner and its condition. When + it finishes, a colored badge shows the result, with the reason and times in + its tooltip. +- An **Operations** tab on the Device lists past operations as a dense table: + time, action, requester, result, before and after power. + +The page adds no explanatory prose. A user without the power operator role +does not see the control. + +### Security boundaries + +- BMC credentials stay in the cell. Only discovery and a per-operation worker + read them, and each worker reads one. +- Every BMC connection is pinned, and the worker re-checks identity before it + sends anything. +- No component writes `Device.spec` or `Device.status` for a power operation. +- Logs and status record outcome classes, never credentials, pins, request + bodies or response bodies. +- The operation's requester comes from admission, not from the client. + +## Delivery phases + +1. **Redfish and discovery.** `DiscoverSystem`, `LastResetTime`, and + `resetTypes` in `ObservedSystem`, with unit tests against `httptest` + Redfish services. No new effect path. +2. **API.** The CRD, admission policy, ProtectedResource and the two Milo + roles. With no dispatcher deployed, operations are inert: they stay + unaccepted. +3. **Dispatcher and worker.** Both binaries, the cell admission policies, + Kustomize packaging, the credential Secret name rule, and the lab acceptance + tests below. +4. **Staff UI and one real host.** The Device page control, and one staged test + on a single real server that backs no capacity: `On`, `ForceOff`, then + `ForceRestart`, recording whether the BMC reports `LastResetTime`. + `ForceRestart` and `PowerCycle` stay disabled on real hardware until this + test shows a restart can be proven. +5. **Allocator gate.** The allocator refuses capacity whose Device has an + unfinished operation, which closes the window described under + [acceptance checks](#acceptance-checks). + +## Acceptance tests + +Unit tests cover the acceptance table, the outcome table and the failure table +case by case, with a fake clock. Lab tests run against `hack/redfish-lab`. The +lab needs three additions first, all lab-only: + +- a TLS listener with a generated key in front of the adapter, because pinned + clients refuse plain HTTP; +- `LastResetTime` published on each reset; +- an identity-swap fault that reports another System's UUID at the enrolled Id. + +| Test | Expected | +| --- | --- | +| `On` and `ForceOff` on an idle lab target | `Succeeded`; the BMC audit shows one `POST` per operation. | +| `On` on a target that is already on | `Succeeded`, `AlreadyInState`; the audit shows no `POST`. | +| `drop-response` on `ForceOff` | `response: Lost`, `Succeeded`, `ObservedAfterLostResponse`; one `POST`. | +| `drop-response` on `ForceRestart` with `LastResetTime` withheld | `Unknown`, `ResetNotObserved`; one `POST`; no retry. | +| `ForceRestart` with `LastResetTime` | `Succeeded`, `resetEvidence: LastResetTime`. | +| Identity swap after acceptance | `Failed`, `IdentityMismatch`; the audit shows `GET` requests only. | +| `hide-reset ForceRestart` after discovery | `Failed`, `ResetTypeNotOffered`; no `POST`. | +| `PowerCycle`, which the lab never offers | Refused at acceptance with `ResetTypeNotOffered`. | +| Wrong TLS key | `Failed`, `PinMismatch`; the lab receives no request. | +| `reject-auth` | `Failed`, `CredentialRejected`; no `POST`. | +| A second Job created by hand for one operation | The second worker exits `Duplicate`; one `POST`. | +| Worker Pod deleted after the `POST` | `Unknown`, `WorkerLost`; no second Job. | +| Job deleted while `Executing`, then the dispatcher restarted | `Unknown`, `DispatchLost`; no second Job. | +| Two operations created together for one Device | One accepted, one `OperationInProgress`. | +| `MachineCapacity` naming the Device | `CapacityBacked`; no Job created. | +| `requester` set to another user | Denied at admission. | +| Staff role tries to write status, update spec or delete | Denied. | +| Discovery's audit during all tests | `GET` requests only. | + +## Production readiness review questionnaire + +### How is the feature enabled or disabled? + +Per cell, by deploying the dispatcher for a set of Device namespaces. Without a +dispatcher, operations stay unaccepted and have no effect. Removing the +dispatcher stops new work; a running worker finishes, and its result waits in +the Lease until a dispatcher publishes it. + +### What must operators monitor? + +Operations unaccepted for more than a minute, `Unknown` results, workers that +exit `Duplicate`, dispatcher restarts, and Leases at `Requesting` with no +result. + +### How are failures recovered? + +An `Unknown` operation needs a person. Read the next discovery pass and the BMC +audit, then create a new operation if one is still needed. Nothing retries +automatically. + +### What must upgrades preserve? + +The Job and Lease naming, the Lease stage values, and the rule that an +`Executing` operation is never dispatched again. Upgrade the dispatcher with no +operation executing. + +## Drawbacks + +- One more cell process and a Job per action add seconds of latency over a + direct BMC call. +- Restarts can end as `Unknown` on BMCs that do not report `LastResetTime`. +- The credential Secret gains a name rule that operators must follow. +- Staff cannot power-control a capacity-backed Device without first removing + its capacity. + +## Alternatives + +- **A Device spec field or annotation.** Rejected: a reset is not desired state, + and a second writer on `Device.spec` breaks single ownership. +- **Machine power intent for unallocated Devices.** Rejected: a Machine is a + consumer allocation, and creating one for staff would expose capacity. +- **Let discovery send resets.** Rejected: discovery would stop being read-only, + and a long-lived process would hold every BMC credential with write power. +- **The dispatcher sends resets itself.** Rejected for the same reason. The + per-operation worker limits each process to one credential. +- **Reuse the installation provider.** It needs an enrollment, a journal and + boot targets, and it uses one shared unpinned credential. +- **Queue operations per Device.** Rejected: a queued request can run after its + reason is gone. +- **A staff override for capacity-backed Devices.** Not proposed; see + [acceptance checks](#acceptance-checks). + +## Open design questions + +These need a decision from a reviewer: + +- **Override for capacity-backed Devices.** This proposal has none. A future + audited maintenance transition on the capacity is the alternative. Is that + acceptable for incident response? +- **Lost response, then the requested state observed.** This proposal reports + `Succeeded` for `On` and `ForceOff`, with `response: Lost`. The stricter + option is `Unknown` for every lost response. +- **Restart evidence.** Should `ForceRestart` and `PowerCycle` ship in phase 3 + for the lab only, or wait for the phase 4 hardware result? +- **Graceful actions.** `GracefulShutdown` and `GracefulRestart` depend on the + OS cooperating, and an unallocated Device often has no trusted OS. They are + excluded. Is there a need for them? +- **Retention.** How long finished operations stay, and who may delete them. +- **Unserved operations.** An operation for a Device that no dispatcher serves + is never accepted. Should a management-side controller expire it? +- **Credential Secret names.** The derived name changes the discovery Secret + contract. Alternatives are a dispatcher with Secret read access, or a + credential broker. +- **Installation enrollment overlap.** The installation provider's enrollment is + separate configuration. A lab Device can be enrolled there without a + `MachineCapacity`. Should enrollment derive from Devices so the capacity check + covers it? +- **Requester.** If Milo records the creating user in an audit stream the + dispatcher can read, the `requester` field could come from there instead. + +## Infrastructure needed + +The Redfish lab additions listed under [acceptance tests](#acceptance-tests), a +dispatcher deployed beside discovery, with workers in the credential namespace, +and for phase 4, one real server that backs no capacity, with an approved TLS +pin and a credential Secret. From b9e22c90fc10f748832ef0fb36430f1b0d98737d Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 15:08:26 -0600 Subject: [PATCH 02/26] docs: Rewrite the Device power proposal for review The first draft read as an implementation plan. It named files, functions, permission verbs and lab internals, so a product or API reviewer had to read 700 lines to evaluate the design. The rewrite keeps the same design at the level a reviewer decides on: who the feature is for, the resource and its fields, the lifecycle and its outcomes, who can do what, the main decisions with their reasons, the delivery phases and the open questions. Implementation detail moves to the delivery work that needs it. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- docs/enhancements/device-power/README.md | 874 ++++++----------------- 2 files changed, 237 insertions(+), 639 deletions(-) diff --git a/README.md b/README.md index 323b42ee..e41c70f7 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ today. Then choose a topic: The [Bare Metal CLI enhancement](docs/enhancements/metal-cli/README.md) proposes `datumctl metal` discovery, machine management, and safe recovery workflows. The [Device power enhancement](docs/enhancements/device-power/README.md) -proposes staff power operations on unallocated physical Devices. +proposes how staff power unallocated servers on, off, or reset them. Contributors should also read the [repository guidance](AGENTS.md) and [implementation roadmap](docs/development/roadmap.md). diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index e3fdd6a6..f141780c 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -7,167 +7,104 @@ stage: alpha [Documentation overview](../../README.md) · [Architecture guide](../../architecture/README.md) +This is a proposal. None of it is implemented. + - [Summary](#summary) -- [Motivation](#motivation) - - [Goals](#goals) - - [Non-goals](#non-goals) -- [What exists today](#what-exists-today) -- [Proposal](#proposal) - - [User stories](#user-stories) - - [Why a separate resource](#why-a-separate-resource) -- [Design details](#design-details) - - [API](#api) - - [Admission](#admission) - - [Acceptance checks](#acceptance-checks) - - [Dispatch](#dispatch) - - [Worker](#worker) - - [Outcomes](#outcomes) - - [Failure handling](#failure-handling) - - [Identities and permissions](#identities-and-permissions) - - [Redfish client and discovery changes](#redfish-client-and-discovery-changes) - - [Relationship to Machine power](#relationship-to-machine-power) - - [Staff UI](#staff-ui) - - [Security boundaries](#security-boundaries) +- [Who it is for](#who-it-is-for) +- [Goals and non-goals](#goals-and-non-goals) +- [How it works](#how-it-works) +- [API](#api) +- [Lifecycle and outcomes](#lifecycle-and-outcomes) +- [Who can do what](#who-can-do-what) +- [Design decisions](#design-decisions) +- [Relationship to Machine power](#relationship-to-machine-power) +- [Staff UI](#staff-ui) - [Delivery phases](#delivery-phases) -- [Acceptance tests](#acceptance-tests) -- [Production readiness review questionnaire](#production-readiness-review-questionnaire) -- [Drawbacks](#drawbacks) -- [Alternatives](#alternatives) - [Open design questions](#open-design-questions) -- [Infrastructure needed](#infrastructure-needed) ## Summary -Staff need to turn an unallocated physical server on or off, or reset it, -without logging in to its BMC by hand. This proposal adds a one-shot -`DevicePowerOperation` resource in `fleet.datumapis.com`. A staff member -creates one to request a single Redfish `ComputerSystem.Reset` on one Device. A -dispatcher in the cell that can reach the BMC checks the request and starts one -worker Job for it. The worker holds only that Device's BMC credential. It -re-checks the system identity, sends the reset once, watches the power state, -and reports a result: `Succeeded`, `Failed` or `Unknown`. - -Operations are refused while the Device backs capacity. Power on an allocated -machine stays with `Machine.spec.powerState` from the -[machine lifecycle enhancement](../machine-lifecycle/README.md). That path can -later reuse the same worker. - -Everything in this document is proposed. Nothing described under -[Design details](#design-details) is implemented. - -## Motivation - -Bringing up and maintaining hardware needs basic power control: power on a -newly racked server so discovery can read its inventory, power off a server -before moving it, or reset one that hangs during qualification. Today staff do -this in the BMC's own web interface or with ad hoc tools. That has four -problems: - -- Fleet has no record of who changed power on which asset, or when. -- Staff use BMC credentials directly, outside the per-Device credential - Secrets and TLS pins that discovery already relies on. -- Nothing stops a reset of a server that a customer is using. -- Nothing ties the action to the exact hardware staff looked at. A swapped or - renumbered system behind the same BMC address gets the reset instead. - -### Goals - -- Let authorized staff request `On`, `ForceOff`, `ForceRestart` and - `PowerCycle` on an unallocated Device, and see the result. -- Send at most one reset per request, to the exact Redfish system staff named. -- Report a lost or unprovable outcome as `Unknown`, never as success, and never - retry it automatically. -- Keep BMC credentials in the cell, readable only by discovery and by the one - worker of each operation. -- Record who asked, why, and the power state observed before and after. -- Build an executor that the Machine power path can reuse. - -### Non-goals - -- Power on allocated or capacity-backed Devices. That belongs to the Machine - and its allocation authority. -- Persistent power intent for Devices. A Device has no desired power state. -- Graceful shutdown or restart, `Nmi` and `PushPowerButton`. See - [open questions](#open-design-questions). -- Boot source overrides, virtual media, BMC settings or firmware. -- Power distribution units or `PowerFeed` control. -- A general BMC access broker for staff. - -## What exists today - -These pieces exist on the integration branch `feat/manual-inventory-records`, -which is ahead of `main`. They are not yet on `main`. Links below point to -that branch at commit -[`7b97c6b`](https://github.com/datum-cloud/fleet/tree/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb). - -| Piece | Where | What it does | -| --- | --- | --- | -| Redfish client | `internal/redfish/client.go` | `Discover` walks the Systems collection with `GET` only and requires `On`, `ForceOff` and the `Pxe` and `Hdd` boot targets. It takes an installation enrollment `Target`. `Reset` sends exactly one `ComputerSystem.Reset` `POST`, never retries, and does not treat HTTP success as proof of the effect. `Observe` re-reads the System and re-checks its Id and UUID. | -| TLS pinning | `internal/redfish/pin.go` | `NewPinnedClient` accepts a BMC only when its leaf public key hashes to the approved pin, on every connection, before any credential is sent. | -| Installation provider | `internal/redfish/provider.go` | Runs `ForceOff`, a one-time boot override, then `On`, with a journal. It observes after a lost `ForceOff`, because power off before a boot is idempotent. It repeats `On` only when the target is still off and still armed after a settle window, within a budget of three. It reads one shared credential and takes no TLS pin. | -| BMC discovery | `internal/bmcdiscovery`, [BMC discovery guide](https://github.com/datum-cloud/fleet/blob/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb/docs/operations/bmc-discovery.md) | A single cell-side replica. It reads one credential Secret per Device (username, password, TLS pin), reads the inventory with `GET` only, and writes `Device.status`. It never changes power, boot or BMC settings. | -| Device API | `internal/api/inventory/v1alpha1/types.go` | `Device.status.discovery.inventory.systems[]` records each `ObservedSystem`, including `powerState`. It does not record which `ResetType` values the BMC offers. Device status has one writer: discovery. | -| Site execution | [Site execution guide](https://github.com/datum-cloud/fleet/blob/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb/docs/operations/site-execution.md) | Per-operation worker Jobs in the cell, each with its own ServiceAccount and a Role scoped to one object. Workers never write status; a separate observer does. | -| Redfish lab | `hack/redfish-lab`, [Redfish lab guide](https://github.com/datum-cloud/fleet/blob/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb/docs/operations/redfish-lab.md) | The DMTF emulator with a lab adapter. It implements `On`, `ForceOff` and `ForceRestart` and can inject `reject-auth`, `hide-reset` and `drop-response` faults. It serves plain HTTP. | - -Two facts in the current code shape this design: - -- **`DeviceClaim` is not an allocation.** It records a planned installation, - and every Device binds one through the required `spec.claimRef`. Capacity - that consumers can allocate is a `MachineCapacity` whose `spec.deviceRef` - names the Device. This proposal therefore refuses operations on Devices that - back a `MachineCapacity`, not on Devices that have a claim. -- **Device has no `Ready` condition.** Discovery reports `Reachable`, - `Authenticated`, `Discovered`, `IdentityMatched` and `PublicKeyUnique`. The - [acceptance checks](#acceptance-checks) name the exact conditions required. - -The [bare-metal hardware proposal](../../proposals/fleet-management/bare-metal-hardware.md) -states the rule for allocated machines: "reconcile persistent On/Off intent. -Reboot/reset is a bounded, idempotent operation with MachineAllocation -preconditions." This proposal applies the bounded-operation half to -unallocated Devices, with Device preconditions in place of allocation ones. - -## Proposal - -### User stories - -- A technician racks a new server. Discovery reports it `Off`. The technician - powers it on from the Device page, and the page shows `On` a minute later. -- Staff qualifying hardware reset a server that hangs in firmware. The page - shows who reset it, when, and that the BMC reported `On` again afterwards. -- Staff power off a server before moving it to another rack. The Device keeps - its identity; only its power changes. -- A server's BMC is replaced and now answers with another system UUID. A power - request made against the old discovery is refused before any reset. -- A staff member tries to restart a server that backs capacity. The request is - refused with `CapacityBacked`, and nothing reaches the BMC. - -### Why a separate resource - -A reset is an event, not a state. `ForceRestart` has no end state to converge -on, and repeating it is a second restart. A field such as -`Device.spec.powerAction` would need a controller to tell an old value from a -new request, and a re-applied manifest would restart the server again. - -A separate resource also keeps one writer per surface: - -| Surface | Writer | -| --- | --- | -| `Device.spec` | The inventory source: an operator or an importer | -| `Device.status` | BMC discovery | -| `DevicePowerOperation.spec` | The staff member who creates it; immutable after creation | -| `DevicePowerOperation.status` | The cell dispatcher | +Staff who build and maintain hardware need to power servers on and off, and to +reset them. Today they do it by hand in each server's management controller +(BMC). Fleet keeps no record of who did it, the action uses credentials Fleet +does not manage, and nothing stops a reset of a server a customer is using. + +This proposal adds a `DevicePowerOperation` resource. A staff member creates one +to ask for a single power action on one unallocated Device. Fleet checks the +request, sends one command to the exact server named, and reports whether the +action succeeded, failed, or has an unknown outcome. + +## Who it is for + +Infrastructure staff who rack, qualify and move servers before those servers +offer capacity to customers. + +- A technician racks a new server and powers it on from the Device page, so + Fleet can read its hardware inventory. +- Staff reset a server that hangs during qualification. The Device page shows + who reset it, when, and the power state afterwards. +- Staff power off a server before moving it to another rack. +- A server's BMC is replaced and now reports a different system. A power + request made against the old record is refused before anything reaches the + server. +- Staff try to reset a server that backs customer capacity. Fleet refuses, and + nothing reaches the server. + +## Goals and non-goals + +Goals: + +- Staff can request power on, power off, restart and power cycle on an + unallocated Device, and see the result. +- Each request sends at most one command, to the exact server staff named. +- An outcome Fleet cannot prove is reported as unknown, never as success, and + is never retried automatically. +- Each request records who asked, why, and the power state before and after. + +Non-goals: + +- Power control of allocated servers. That stays with the customer's Machine. +- A desired power state for Devices. A Device has none. +- Graceful shutdown and graceful restart, which need the operating system to + cooperate. +- Boot settings, virtual media, BMC settings, firmware, or power distribution + units. + +## How it works + +```text +staff creates a DevicePowerOperation + │ + ▼ +dispatcher, in the site that can reach the BMC + checks the request, then starts one worker + │ + ▼ +worker, holding only this Device's BMC credential + re-checks the server's identity, sends one command, + watches the power state, reports the result +``` + +Three components take part: -Each operation is its own audit record. It keeps the requester, the reason, the -exact target and the observed result after the Device changes. +- **The dispatcher** runs in the site, next to the existing BMC discovery + process. It accepts or refuses each request and starts a worker. It is the + only writer of the operation's status. It holds no BMC credential. +- **The worker** is a short-lived process started for one operation. It can + read only the target Device's BMC credential. It has no access to the Fleet + control plane. +- **BMC discovery** already reads each BMC and records what it reports on the + Device. It stays read-only. This proposal adds one thing to what it records: + which power actions each server offers. -## Design details +Every connection to a BMC checks the BMC's approved TLS key before it sends a +credential, the same check discovery uses today. -### API +## API -`DevicePowerOperation` is a namespaced kind in `fleet.datumapis.com/v1alpha1`. -It lives in the provider project, in the same namespace as its Device. -The example uses synthetic values. +`DevicePowerOperation` belongs to `fleet.datumapis.com`. It lives in the +provider project, in the same namespace as its Device. The values below are +synthetic. ```yaml apiVersion: fleet.datumapis.com/v1alpha1 @@ -176,14 +113,9 @@ metadata: name: device-a-restart-1 namespace: default spec: - # The Device in this namespace. The operation never follows a rename. deviceRef: {name: device-a} - # One of On, ForceOff, ForceRestart, PowerCycle. action: ForceRestart - # The SMBIOS system UUID staff expect behind the BMC, lowercase canonical. - # The operation fails if the Device or the BMC reports another. expectedSystemUUID: 00000000-0000-4000-8000-0000000000a1 - # Admission requires this to equal the creating user's name. requester: staff@example.com reason: Hung in firmware during qualification status: @@ -191,513 +123,179 @@ status: - {type: Accepted, status: "True", reason: Accepted} - {type: Executing, status: "False", reason: Finished} - {type: Finished, status: "True", reason: ResetObserved} - # Succeeded, Failed or Unknown. Absent until Finished is True. result: Succeeded - # Pinned at acceptance from the Device and its discovery. - target: - deviceUID: 3f0c9a52-0000-4000-8000-000000000001 - endpoint: https://192.0.2.10:443 - systemID: "1" - acceptedAt: "2026-01-02T03:04:00Z" - dispatchedAt: "2026-01-02T03:04:01Z" - # When the worker sent the one reset request. Absent if none was sent. requestSentAt: "2026-01-02T03:04:06Z" - # Accepted, Refused or Lost: the BMC's answer to the request, not the effect. - response: Accepted power: before: {state: "On", observedAt: "2026-01-02T03:04:05Z"} after: {state: "On", observedAt: "2026-01-02T03:04:41Z"} - # The evidence for a restart: the BMC's LastResetTime, or an observed - # state other than On between the request and the deadline. - resetEvidence: LastResetTime finishedAt: "2026-01-02T03:04:42Z" ``` -The API has these rules: - -- **The spec is immutable.** A CRD validation rule `self == oldSelf` covers the - whole spec. A changed intent is a new operation. -- **Every field is required.** `reason` is 1 to 256 characters. There is no - default action. -- **`result` is set once.** After `Finished` is `True`, the status never - changes again. -- **Status never carries a credential, a pin, a URL path, a header or a - response body.** `endpoint` is the Device's `spec.bmc.endpoint`, which is - already in the Device record. - -### Admission - -A `ValidatingAdmissionPolicy` in the Milo project control plane checks what a -single request can show: +| Field | Meaning | +| --- | --- | +| `deviceRef` | The Device to act on, in the same namespace. | +| `action` | `On`, `ForceOff`, `ForceRestart` or `PowerCycle`. | +| `expectedSystemUUID` | The server staff expect behind the BMC. The operation fails if the Device record or the BMC reports another. | +| `requester` | Must equal the user who creates the operation. Admission enforces this. | +| `reason` | Required free text for the audit record. | +| `status.result` | `Succeeded`, `Failed` or `Unknown`. Set once and never changed. | +| `status.power` | The power state seen before and after the command. | -- On create, `spec.requester` equals `request.userInfo.username`. Kubernetes - objects do not record their creator; this check makes the spec field - trustworthy. -- `action` is one of the four values, and `expectedSystemUUID` is lowercase - canonical. -- Only the dispatcher's identity can write status. IAM already enforces this; - the policy repeats it for defense in depth. +The whole spec is fixed at creation. A changed request is a new operation. +Status never carries a credential or any BMC response content. -An admission policy cannot read other objects. The checks that need the Device, -its capacity or other operations happen at [acceptance](#acceptance-checks), in -the dispatcher. Until the dispatcher accepts an operation, it has no effect. +## Lifecycle and outcomes -### Acceptance checks +An operation moves through three conditions: `Accepted`, `Executing`, then +`Finished` with a result. -The dispatcher accepts or refuses each new operation for a Device it serves. It -processes one Device's operations in order of creation time. It sets -`Accepted=True` only when every check below passes. Otherwise it sets -`Accepted=False`, `Finished=True` and `result: Failed` with the reason shown. -A refused operation never reaches the BMC. +**Acceptance.** The dispatcher refuses an operation with `result: Failed`, and +sends nothing, when any of these holds: -| Check | Reason on failure | +| Reason | When | | --- | --- | -| The Device exists in the operation's namespace. | `DeviceNotFound` | -| `spec.lifecycle` is `Active` or `Decommissioning`. | `DeviceRetired` | -| `Device.spec.identity.systemUUID` is set. A Device recorded by serial alone cannot be operated, because the worker selects the Redfish system by UUID. | `SystemUUIDNotRecorded` | -| `expectedSystemUUID` equals `Device.spec.identity.systemUUID`. | `SystemUUIDMismatch` | -| Discovery is current: `Authenticated`, `Discovered` and `IdentityMatched` are `True`; `status.observedGeneration` equals the Device's generation; the inventory endpoint equals `spec.bmc.endpoint`; the inventory is younger than twice the discovery `interval` (two hours at the default of one hour), so one missed pass does not block staff. | `DiscoveryNotCurrent` | -| `PublicKeyUnique` is not `False`. A shared TLS key cannot tell BMCs apart. | `SharedPublicKey` | -| The inventory has exactly one System with the expected UUID. | `SystemNotObserved` | -| That System's recorded `resetTypes` include the action. | `ResetTypeNotOffered` | -| No `MachineCapacity` in the namespace has `spec.deviceRef.name` equal to the Device. | `CapacityBacked` | -| No other operation on the Device is accepted and unfinished. | `OperationInProgress` | -| The operation was created less than five minutes ago. | `Expired` | - -Two decisions are built into this table: - -- **There is no override for capacity-backed Devices.** A Device that backs a - `MachineCapacity` may be allocated, mid-installation or mid-cleanup. The - [PXE installation enhancement](https://github.com/datum-cloud/fleet/blob/7b97c6b2f5c61858a301de0ebb4e0cc165ab37cb/docs/enhancements/pxe-installation/README.md#shared-bmc-and-installation-execution) - requires all power effects on an allocation to share one serialization and - fencing domain, with "no lock-free emergency reset path". A staff override - would be that path. Staff who must power-control such a Device first remove - its `MachineCapacity` through the release lifecycle. A future audited - maintenance transition can add a safer path; see - [open questions](#open-design-questions). -- **Operations are refused, not queued.** A second request while one runs is - refused with `OperationInProgress`. A queued request could run minutes later, - after the reason for it has changed. - -The capacity check has a gap. A `MachineCapacity` could be created after the -dispatcher checks and before the worker sends its reset. The dispatcher repeats -the capacity check immediately before it creates the Job. The worker refuses to -start more than two minutes after dispatch. Together these bound the window to -about two minutes. A new `MachineCapacity` defaults to -`allocationPolicy: Disabled`, so it cannot be allocated within that window -without a second operator action. Closing the window fully needs the allocator -to refuse a Device with an unfinished power operation. That change is listed in -[delivery phase 5](#delivery-phases). - -### Dispatch - -The dispatcher is a single-replica Deployment in the cell, next to discovery, -with no leader election and the `Recreate` strategy. It creates worker Jobs in -discovery's credential namespace, because a Pod can mount only Secrets in its -own namespace. Like discovery, it serves -the Device namespaces listed in its configuration. Two dispatchers must never -serve the same namespace. - -```text -staff ──create──▶ DevicePowerOperation (Milo project) - │ watch - ▼ - dispatcher (cell) ── Accepted, then Executing ──▶ operation status - │ create (only after Executing is stored) - ▼ - Job dpo- - ├─ mounts one credential Secret - └─ worker ── claim Lease dpo- (stage, result) - │ - ▼ - BMC (pinned TLS) -``` - -For each accepted operation, the dispatcher: - -1. Re-checks capacity, as described above. -2. Writes `Executing=True` and `dispatchedAt` to the operation status with an - optimistic lock. It never creates a Job for an operation whose status it did - not move to `Executing` itself. -3. Creates a per-operation ServiceAccount, Role and RoleBinding, and a Job named - `dpo-` plus the first 16 hex digits of the SHA-256 of the operation UID. The - deterministic name makes a repeated create fail with `AlreadyExists`. -4. Watches the Job and the worker's claim Lease, and publishes the result to the - operation status. - -The Job runs one Pod with `restartPolicy: Never`, `backoffLimit: 0`, -`podReplacementPolicy: Failed` and `activeDeadlineSeconds: 600`. A worker is -never retried. The dispatcher passes the operation UID, action, expected UUID, -system Id, endpoint and a start deadline two minutes after dispatch as -arguments. - -The Job mounts exactly one Secret: the credential Secret for the target Device. -Today discovery finds that Secret by its annotations, which the dispatcher could -read only with Secret read access. This proposal adds a name rule to the -credential Secret contract instead: the Secret's name is `bmc-` plus the first -20 hex digits of the SHA-256 of `//`. The dispatcher -computes the name and never reads Secrets. Discovery keeps selecting by -annotation, and it logs a warning when a -selected Secret does not have the derived name. - -The dispatcher keeps the Job and the claim Lease until the result is stored in -Milo. It then deletes the per-operation RBAC at once and the Job and Lease after -seven days. - -### Worker - -The worker is a mode of the Fleet image. It holds no Milo credential. Its -ServiceAccount can create Leases in its namespace and get or update only its -own Lease, by `resourceNames`. It runs these steps in order and stops at the -first failure: - -1. **Check the start deadline.** After the deadline it exits with reason - `Stale` and sends nothing. -2. **Claim the operation.** It creates the Lease `dpo-`. If the Lease - already exists, another worker ran or is running for this operation: it - exits with reason `Duplicate` and sends nothing. Kubernetes can start a - Job's Pod twice in rare cases, so the Job alone is not an at-most-once - guarantee. -3. **Load the credential.** It reads `username`, `password` and - `tlsPublicKeySHA256` from the mounted Secret. A missing pin is - `PinNotApproved`. The worker has no unpinned or plain HTTP path. -4. **Connect and re-check identity.** It connects with `NewPinnedClient` and - runs the power-only `DiscoverSystem` with the expected UUID. Exactly one - System must carry the UUID, its Id must equal the pinned system Id, and its - reset target must sit under that System. The worker issues `GET` requests - only in this step. -5. **Check the action.** The BMC must offer the action as a `ResetType` now, - not only at discovery time. -6. **Observe before.** It reads `PowerState`. Then: - - `On` when already `On`, or `ForceOff` when already `Off`, finishes as - `Succeeded` with reason `AlreadyInState`. Nothing is sent. - - `ForceRestart` or `PowerCycle` when not `On` fails with `NotPoweredOn`. - Vendors differ on what a restart of an off system does. - - Any other state, such as `PoweringOn` or an empty value, fails with - `PowerStateNotSettled`. -7. **Record the request.** It writes stage `Requesting` and the time to its - Lease. If that write fails, it exits without sending. From this point on, - a missing result means `Unknown`. -8. **Send once.** It calls `Reset` exactly once. -9. **Observe after.** It polls `Observe` every five seconds until the expected - evidence appears or three minutes pass. Each read re-checks the System Id - and UUID. -10. **Record the result.** It writes the result, reason and observations to its - Lease and exits 0. - -The installation provider repeats `On` when it can prove the first one had no -effect. The power worker does not repeat anything. A staff member who wants -another attempt creates a new operation, which leaves a second audit record and -passes the acceptance checks again. - -### Outcomes - -What counts as evidence depends on the action. HTTP success is never evidence. - -| Action | `Succeeded` requires | Otherwise | +| `CapacityBacked` | Customer capacity is defined on the Device. | +| `OperationInProgress` | Another operation on the Device is still running. | +| `SystemUUIDNotRecorded` | The Device has no system UUID on record. | +| `SystemUUIDMismatch` | The expected UUID differs from the Device record. | +| `DiscoveryNotCurrent` | Discovery has not recently read the BMC and matched its identity. | +| `ResetTypeNotOffered` | The server does not offer the requested action. | +| `DeviceRetired` | The Device is retired. | +| `Expired` | The operation waited more than five minutes to be accepted. | + +**Execution.** The worker re-checks the server's identity and offered actions, +reads the power state, and sends one command. If the server is already in the +requested state, the worker sends nothing and reports success. A restart or +power cycle of a server that is off is refused. + +**Result.** HTTP success from the BMC is not proof. The result depends on what +the worker observes afterwards: + +| Action | `Succeeded` when | Otherwise | | --- | --- | --- | -| `On` | `PowerState` reads `On` before the deadline | `Unknown`, reason `TargetStateNotObserved` | -| `ForceOff` | `PowerState` reads `Off` before the deadline | `Unknown`, reason `TargetStateNotObserved` | -| `ForceRestart`, `PowerCycle` | `PowerState` reads `On` at the end, and either the BMC's `LastResetTime` is later than `requestSentAt` or a state other than `On` was observed after the request | `Unknown`, reason `ResetNotObserved` | +| `On`, `ForceOff` | The requested power state appears within three minutes. | `Unknown` | +| `ForceRestart`, `PowerCycle` | The BMC shows that a reset happened after the request, and the server is on again. | `Unknown` | -The BMC's answer to the request also matters: +A BMC that refuses the command gives `Failed`. A command whose response is lost +is never resent, and its result follows the table above. -| BMC response | Result | -| --- | --- | -| 2xx | Judged by the evidence above. | -| 400, 401, 403, 404, 405 or 409 | `Failed`, reason `RefusedByBMC`. The worker still observes power once and records it as `after`. If that observation shows a change, the result is `Unknown` instead. | -| 412, any other status, a timeout or a transport error | `response: Lost`. The worker keeps observing. `On` and `ForceOff` can still reach `Succeeded` with reason `ObservedAfterLostResponse`. A restart is `Unknown` unless `LastResetTime` proves it. | - -For `On` and `ForceOff`, this refines the rule that a lost response ends as -`Unknown`. A lost response followed by the requested state, observed through -the pinned client on the exact system, is the same evidence the installation -provider already accepts for `ForceOff`. The result records the lost response -in `response` so staff can see it. Whether to accept it is listed as an -[open question](#open-design-questions). +**What staff see when something breaks.** If Fleet knows nothing was sent, the +result is `Failed`. If a command may have been sent and Fleet cannot prove the +outcome, the result is `Unknown`. This covers these cases: -A short restart can finish between two polls. A BMC that reports neither -`LastResetTime` nor an intermediate state leaves every restart `Unknown`. -Phase 4 measures this on real hardware before `ForceRestart` and `PowerCycle` -are enabled there. +- a worker that crashes; +- a site process that restarts; +- a BMC that stops answering; +- a second worker started by mistake, which stops before it contacts the BMC + and leaves the first worker's result in place. -### Failure handling +`Unknown` ends the operation. Staff check the next discovery result and create +a new operation if they still need one. Deleting an operation does not cancel a +command already sent. -The dispatcher derives the result from the Job and the Lease when the worker -cannot report: +## Who can do what -| Case | What happens | Result | -| --- | --- | --- | -| Pod or Job lost before the Lease exists | Nothing was sent. | `Failed`, reason `WorkerLost` | -| Pod or Job lost with the Lease at a stage before `Requesting` | Nothing was sent. | `Failed`, reason `WorkerLost` | -| Pod or Job lost with the Lease at `Requesting` and no result | The reset may have been sent. | `Unknown`, reason `WorkerLost` | -| Job missing while the operation is `Executing` | The dispatcher cannot tell whether a worker ran. It never creates a second Job. | `Unknown`, reason `DispatchLost` | -| Dispatcher restarts | It rebuilds its state from operation status, Jobs and Leases. It adopts existing Jobs by name and never re-dispatches an `Executing` operation. | Unchanged | -| Duplicate dispatch: a second Job or Pod for one operation | The second worker finds the Lease and exits with `Duplicate` before contacting the BMC. The second Job's exit does not change the operation. | Unchanged | -| Operation older than five minutes when first seen | Refused at acceptance. | `Failed`, reason `Expired` | -| Worker starts after its deadline, for example a Pod pending on an image pull | The worker exits before claiming. | `Failed`, reason `Stale` | -| Discovery not current | Refused at acceptance. | `Failed`, reason `DiscoveryNotCurrent` | -| TLS pin mismatch, rejected credential, identity mismatch, action no longer offered | The worker stops before sending. | `Failed` with `PinMismatch`, `CredentialRejected`, `IdentityMismatch` or `ResetTypeNotOffered` | -| BMC unreachable after the request | The worker observes until the deadline. | `Unknown`, reason `TargetStateNotObserved` | -| Operation deleted while executing | Deletion does not cancel the reset. The worker finishes. The result stays in the Lease and the worker log. | Not published | - -`Unknown` is a final result for the operation, not a state of the Device. The -next discovery pass reports the Device's power. Staff decide whether to create -another operation. - -### Identities and permissions - -Each component gets its own identity. None inherits another's role. - -| Identity | Milo project permissions | Cell permissions | BMC access | -| --- | --- | --- | --- | -| Staff, role `fleet.datumapis.com-device-power-operator` | `devicepoweroperations` create, get, list, watch; `devices` get, list, watch | None | None | -| Dispatcher, role `fleet.datumapis.com-device-power-dispatcher` | `devicepoweroperations` get, list, watch and status update; `devices` get, list, watch; `metal.datumapis.com/machinecapacities` get, list, watch | In the credential namespace: create, get, list, watch and delete Jobs, ServiceAccounts, Roles and RoleBindings; create, get, list, watch, update and delete Leases. No Secret access, and no `bind` or `escalate`. | None | -| Worker, one ServiceAccount per operation | None | Create Leases; get and update its own Lease | The one mounted credential | -| Discovery, role `fleet.datumapis.com-inventory-discoverer` | Unchanged | Unchanged | Read-only, unchanged | - -The staff role grants no update, patch or delete on operations. A finished -operation is the audit record. Retention is an -[open question](#open-design-questions). - -Kubernetes RBAC lets an identity create a Role only with permissions it -already holds. The dispatcher therefore holds the Lease verbs it grants to -workers, and needs neither `bind` nor `escalate`. Holding them lets the -dispatcher write a Lease itself. That adds no authority, because the dispatcher -already writes the operation's result. - -The workers run in the credential namespace, so the dispatcher's right to -create Jobs reaches every `bmc-*` Secret there. Its own RBAC grants no Secret -read. Two `ValidatingAdmissionPolicies` in the cell are the barrier: they limit -the dispatcher's writes to the worker shape, as the site execution composition -already does for kro. - -- A Job has a name `dpo-` and the Job's own ServiceAccount. -- It runs one container, from the image the dispatcher runs, with the worker - command. -- It mounts exactly one Secret volume, named `bmc-` and 20 hex digits. -- It has no privilege, added capability or host namespace. -- A Role grants only Lease create, and get and update on its own Lease by - `resourceNames`. -- A RoleBinding binds only its own Role to its own ServiceAccount. - -A dispatcher that is compromised could still point a worker at the wrong Device's -Secret or at another endpoint. The pin stops the second case: an endpoint -without that BMC's private key fails the TLS handshake before the credential is -sent. In the first case the worker's UUID check fails and nothing is sent, -unless both Devices share a TLS key. - -### Redfish client and discovery changes - -- **Power-only discovery.** Add `Client.DiscoverSystem(ctx, uuid)`. It reads - every Systems member with `GET` only, requires exactly one member with the - UUID, checks that the reset target and `ActionInfo` sit under that System, and - returns the System with its `ResetTypes`. It requires no boot target, no - `On` or `ForceOff`, and no installation `Target`. `Discover` becomes - `DiscoverSystem` plus the enrolled Id check and the installation checks it - makes today, so the installation provider behaves exactly as before. -- **Reset evidence.** `Observe` also returns `LastResetTime` when the BMC - reports it. -- **Offered reset types in discovery.** `Inventory` reads each System's - `#ComputerSystem.Reset` allowable values, and its `ActionInfo` with one more - `GET` when the values are not inline. `ObservedSystem` gains `resetTypes`. - An empty list means the BMC did not report any, and every operation on that - System is refused. Discovery stays read-only: it reads the action's - description and never invokes it. -- **No fault hooks** in `internal/redfish`. Faults stay in the lab adapter. - -### Relationship to Machine power - -`Machine.spec.powerState` is persistent On or Off intent on an allocated -Machine, owned by the consumer. `DevicePowerOperation` is a one-shot staff -action on an unallocated Device. They never act on the same hardware at the -same time: - -- A Device power operation is refused while any `MachineCapacity` names the - Device. A Machine exists only on allocated capacity. -- After phase 5, the allocator refuses to allocate capacity whose Device has an - unfinished power operation. - -The Machine path reuses the executor, not the resource. A location-side Machine -power reconciler receives intent through the coordination handoff and starts the -same worker, with these differences: - -| | Device power operation | Machine power | -| --- | --- | --- | -| Authority | Staff role and Device acceptance checks | MachineAllocation, its generation and the per-allocation fence | -| Intent | One action | Persistent On or Off, plus a bounded reset operation | -| Serialization | One unfinished operation per Device | Shared with installation and release for the allocation | -| Result | `DevicePowerOperation.status` | Machine `status.power`, through the projector | - -The shared parts are `DiscoverSystem`, the pinned client, the claim record, the -single-request rule and the outcome table. - -### Staff UI - -The Device page in the provider UI gets a power control next to the observed -power state: - -- A power button with a menu of the actions the Device's discovery reports as - offered. Disabled actions carry their refusal reason, such as - `CapacityBacked`, in a tooltip. -- A confirm dialog that shows the action, the Device name and the last four - characters of the system UUID, and a required reason field. Confirming - creates the operation with the UUID from discovery. -- While an operation runs, the control shows a spinner and its condition. When - it finishes, a colored badge shows the result, with the reason and times in - its tooltip. -- An **Operations** tab on the Device lists past operations as a dense table: - time, action, requester, result, before and after power. - -The page adds no explanatory prose. A user without the power operator role -does not see the control. - -### Security boundaries - -- BMC credentials stay in the cell. Only discovery and a per-operation worker - read them, and each worker reads one. -- Every BMC connection is pinned, and the worker re-checks identity before it - sends anything. -- No component writes `Device.spec` or `Device.status` for a power operation. -- Logs and status record outcome classes, never credentials, pins, request - bodies or response bodies. -- The operation's requester comes from admission, not from the client. +| Who | Can | +| --- | --- | +| Staff with the power operator role | Create and read operations, and read Devices. They cannot edit or delete operations or write their status. | +| The dispatcher | Read operations, Devices and capacity, write operation status, and start workers in its site. | +| A worker | Read one Device's BMC credential and record its own progress in the site. | +| BMC discovery | Unchanged: read BMCs and write Device status. | + +The dispatcher could, in principle, start a worker with any credential in its +site. Admission policies in the site limit every worker to the approved image, +one credential, and no extra privileges. A worker pointed at the wrong BMC fails +the TLS key check before it sends the credential. A worker given the wrong +credential fails the identity check before it sends a command. + +## Design decisions + +**A separate resource, not a Device field.** A reset is an event, not a state. +A field on the Device would need a controller to tell an old value from a new +request, and re-applying a manifest would reset the server again. A separate +resource gives each operation its own audit record and keeps one writer for each +part of the Device. + +**No override for capacity-backed Devices.** A server that offers customer +capacity may be allocated, installing or being cleaned. Every power action on it +must be ordered with that work, and a staff override would skip that ordering. +Staff first remove the capacity through the normal release process. + +**Refuse instead of queueing.** A second request while one is running is +refused. A queued request could run minutes later, after its reason is gone. + +**One command, no retries.** Repeating a restart is a second restart. A staff +member who wants another attempt creates a new operation, which leaves a new +audit record and passes the checks again. + +**One credential per worker.** Neither discovery nor the dispatcher sends power +commands. A long-lived process that could send commands to every BMC would be +the most valuable target in the site. Each worker can reach only one BMC. + +**Name the exact server.** The request carries the server's UUID, and the worker +re-checks it against the BMC before acting. A replaced or renumbered server +behind the same BMC address is refused. + +## Relationship to Machine power + +`Machine.spec.powerState` in the +[machine lifecycle enhancement](../machine-lifecycle/README.md) is the +customer's ongoing on or off intent for an allocated machine. A +`DevicePowerOperation` is a one-time staff action on an unallocated Device. The +two never act on the same server at once. A Device with capacity refuses power +operations, and a later phase makes the allocator refuse a Device with a running +operation. + +The Machine path will reuse the worker and its outcome rules, not the resource. +Its authority comes from the allocation, as the +[bare-metal hardware proposal](../../proposals/fleet-management/bare-metal-hardware.md) +requires for resets: "a bounded, idempotent operation with MachineAllocation +preconditions." + +## Staff UI + +The Device page gets a power button next to the observed power state. Its menu +lists only the actions the server offers, and an unavailable action shows its +refusal reason in a tooltip. Confirming asks for a reason and creates the +operation, and a badge then shows progress and the result. An **Operations** +tab lists past operations as a table of time, action, requester, result, and +power before and after. Users without the power operator role do not see the +button. ## Delivery phases -1. **Redfish and discovery.** `DiscoverSystem`, `LastResetTime`, and - `resetTypes` in `ObservedSystem`, with unit tests against `httptest` - Redfish services. No new effect path. -2. **API.** The CRD, admission policy, ProtectedResource and the two Milo - roles. With no dispatcher deployed, operations are inert: they stay - unaccepted. -3. **Dispatcher and worker.** Both binaries, the cell admission policies, - Kustomize packaging, the credential Secret name rule, and the lab acceptance - tests below. -4. **Staff UI and one real host.** The Device page control, and one staged test - on a single real server that backs no capacity: `On`, `ForceOff`, then - `ForceRestart`, recording whether the BMC reports `LastResetTime`. - `ForceRestart` and `PowerCycle` stay disabled on real hardware until this - test shows a restart can be proven. -5. **Allocator gate.** The allocator refuses capacity whose Device has an - unfinished operation, which closes the window described under - [acceptance checks](#acceptance-checks). - -## Acceptance tests - -Unit tests cover the acceptance table, the outcome table and the failure table -case by case, with a fake clock. Lab tests run against `hack/redfish-lab`. The -lab needs three additions first, all lab-only: - -- a TLS listener with a generated key in front of the adapter, because pinned - clients refuse plain HTTP; -- `LastResetTime` published on each reset; -- an identity-swap fault that reports another System's UUID at the enrolled Id. - -| Test | Expected | -| --- | --- | -| `On` and `ForceOff` on an idle lab target | `Succeeded`; the BMC audit shows one `POST` per operation. | -| `On` on a target that is already on | `Succeeded`, `AlreadyInState`; the audit shows no `POST`. | -| `drop-response` on `ForceOff` | `response: Lost`, `Succeeded`, `ObservedAfterLostResponse`; one `POST`. | -| `drop-response` on `ForceRestart` with `LastResetTime` withheld | `Unknown`, `ResetNotObserved`; one `POST`; no retry. | -| `ForceRestart` with `LastResetTime` | `Succeeded`, `resetEvidence: LastResetTime`. | -| Identity swap after acceptance | `Failed`, `IdentityMismatch`; the audit shows `GET` requests only. | -| `hide-reset ForceRestart` after discovery | `Failed`, `ResetTypeNotOffered`; no `POST`. | -| `PowerCycle`, which the lab never offers | Refused at acceptance with `ResetTypeNotOffered`. | -| Wrong TLS key | `Failed`, `PinMismatch`; the lab receives no request. | -| `reject-auth` | `Failed`, `CredentialRejected`; no `POST`. | -| A second Job created by hand for one operation | The second worker exits `Duplicate`; one `POST`. | -| Worker Pod deleted after the `POST` | `Unknown`, `WorkerLost`; no second Job. | -| Job deleted while `Executing`, then the dispatcher restarted | `Unknown`, `DispatchLost`; no second Job. | -| Two operations created together for one Device | One accepted, one `OperationInProgress`. | -| `MachineCapacity` naming the Device | `CapacityBacked`; no Job created. | -| `requester` set to another user | Denied at admission. | -| Staff role tries to write status, update spec or delete | Denied. | -| Discovery's audit during all tests | `GET` requests only. | - -## Production readiness review questionnaire - -### How is the feature enabled or disabled? - -Per cell, by deploying the dispatcher for a set of Device namespaces. Without a -dispatcher, operations stay unaccepted and have no effect. Removing the -dispatcher stops new work; a running worker finishes, and its result waits in -the Lease until a dispatcher publishes it. - -### What must operators monitor? - -Operations unaccepted for more than a minute, `Unknown` results, workers that -exit `Duplicate`, dispatcher restarts, and Leases at `Requesting` with no -result. - -### How are failures recovered? - -An `Unknown` operation needs a person. Read the next discovery pass and the BMC -audit, then create a new operation if one is still needed. Nothing retries -automatically. - -### What must upgrades preserve? - -The Job and Lease naming, the Lease stage values, and the rule that an -`Executing` operation is never dispatched again. Upgrade the dispatcher with no -operation executing. - -## Drawbacks - -- One more cell process and a Job per action add seconds of latency over a - direct BMC call. -- Restarts can end as `Unknown` on BMCs that do not report `LastResetTime`. -- The credential Secret gains a name rule that operators must follow. -- Staff cannot power-control a capacity-backed Device without first removing - its capacity. - -## Alternatives - -- **A Device spec field or annotation.** Rejected: a reset is not desired state, - and a second writer on `Device.spec` breaks single ownership. -- **Machine power intent for unallocated Devices.** Rejected: a Machine is a - consumer allocation, and creating one for staff would expose capacity. -- **Let discovery send resets.** Rejected: discovery would stop being read-only, - and a long-lived process would hold every BMC credential with write power. -- **The dispatcher sends resets itself.** Rejected for the same reason. The - per-operation worker limits each process to one credential. -- **Reuse the installation provider.** It needs an enrollment, a journal and - boot targets, and it uses one shared unpinned credential. -- **Queue operations per Device.** Rejected: a queued request can run after its - reason is gone. -- **A staff override for capacity-backed Devices.** Not proposed; see - [acceptance checks](#acceptance-checks). +1. **Discovery records offered actions.** No new effect. +2. **API and roles.** Operations can be created but stay unaccepted, so they + have no effect. +3. **Dispatcher and worker**, tested against an emulated BMC for lost + responses, a replaced server, an unsupported action and a duplicate worker. +4. **Staff UI and one real server** that backs no capacity. Restart and power + cycle stay disabled on real hardware until this test shows a restart can be + proven. +5. **Allocator gate.** The allocator refuses capacity whose Device has a running + operation. This closes a window of about two minutes between acceptance and + the command, in which new capacity could be defined. ## Open design questions -These need a decision from a reviewer: - -- **Override for capacity-backed Devices.** This proposal has none. A future - audited maintenance transition on the capacity is the alternative. Is that - acceptable for incident response? -- **Lost response, then the requested state observed.** This proposal reports - `Succeeded` for `On` and `ForceOff`, with `response: Lost`. The stricter - option is `Unknown` for every lost response. -- **Restart evidence.** Should `ForceRestart` and `PowerCycle` ship in phase 3 - for the lab only, or wait for the phase 4 hardware result? -- **Graceful actions.** `GracefulShutdown` and `GracefulRestart` depend on the - OS cooperating, and an unallocated Device often has no trusted OS. They are - excluded. Is there a need for them? -- **Retention.** How long finished operations stay, and who may delete them. -- **Unserved operations.** An operation for a Device that no dispatcher serves - is never accepted. Should a management-side controller expire it? -- **Credential Secret names.** The derived name changes the discovery Secret - contract. Alternatives are a dispatcher with Secret read access, or a - credential broker. -- **Installation enrollment overlap.** The installation provider's enrollment is - separate configuration. A lab Device can be enrolled there without a - `MachineCapacity`. Should enrollment derive from Devices so the capacity check +- **Override for capacity-backed Devices.** This proposal has none. Is a future + audited maintenance step on the capacity enough for incidents? +- **Lost response, then the right state.** The proposal reports `Succeeded` + when the requested power state appears after a lost response. The stricter + option reports `Unknown`. +- **When restarts ship.** Should restart and power cycle wait for the + real-hardware test, or ship earlier for the lab only? +- **Graceful actions.** They are excluded because an unallocated server often + has no trusted operating system. Does anyone need them? +- **Retention.** How long are finished operations kept, and who may delete + them? +- **Unserved operations.** An operation for a Device that no site serves is + never accepted. Should something expire it? +- **Credential naming.** Workers find their credential by a name derived from + the Device, which changes how discovery credentials are named. Is that + acceptable, or should a credential broker handle it? +- **Installation server list.** The installation system keeps its own list of + servers. Should it derive that list from Devices, so the capacity check covers it? -- **Requester.** If Milo records the creating user in an audit stream the - dispatcher can read, the `requester` field could come from there instead. - -## Infrastructure needed - -The Redfish lab additions listed under [acceptance tests](#acceptance-tests), a -dispatcher deployed beside discovery, with workers in the credential namespace, -and for phase 4, one real server that backs no capacity, with an approved TLS -pin and a credential Secret. +- **Requester source.** Should the requester come from Milo's audit record + instead of a spec field checked at admission? From 320a70d26c5e1bdc6613b688b6958f2a8500be83 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 15:10:17 -0600 Subject: [PATCH 03/26] docs: Restore Device power safety rules The shorter proposal dropped three rules from the longer draft. Without them it promised more than the design gives. It claimed that a worker pointed at the wrong BMC always fails the TLS check, which does not hold when two BMCs share a key. It also gave a two-minute window with nothing in the design to bound it. The proposal now refuses Devices whose BMCs share a TLS key, and reports Unknown when a BMC refuses a command but the power changes anyway. The dispatcher repeats the capacity check before it starts a worker, and a worker that starts late refuses as Stale. The refusal list also covers a missing Device, a server discovery did not see, and a power state that is still changing. Co-Authored-By: Claude Opus 5.5 --- docs/README.md | 3 +- docs/enhancements/device-power/README.md | 44 ++++++++++++++++-------- 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/docs/README.md b/docs/README.md index 13378048..99eb0dee 100644 --- a/docs/README.md +++ b/docs/README.md @@ -71,7 +71,8 @@ Each topic folder has a `README.md` entry point: | [Operations](operations/README.md) | Deployment, validation, and local smoke tests | | [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, plus [Device power operations](enhancements/device-power/README.md) | +| [Enhancements](enhancements/machine-lifecycle/README.md) | Focused machine lifecycle contracts and acceptance requirements | +| [Device power](enhancements/device-power/README.md) | Proposed staff power operations on unallocated servers | | [Proposals](proposals/fleet-management/README.md) | Broader service proposals, examples, diagrams, and provenance | ## Read implementation and design separately diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index f141780c..35384e22 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -26,8 +26,9 @@ This is a proposal. None of it is implemented. Staff who build and maintain hardware need to power servers on and off, and to reset them. Today they do it by hand in each server's management controller -(BMC). Fleet keeps no record of who did it, the action uses credentials Fleet -does not manage, and nothing stops a reset of a server a customer is using. +(BMC). Fleet keeps no record of who did it, the action bypasses the per-Device +credentials and TLS checks Fleet already uses, and nothing stops a reset of a +server a customer is using. This proposal adds a `DevicePowerOperation` resource. A staff member creates one to ask for a single power action on one unallocated Device. Fleet checks the @@ -159,14 +160,21 @@ sends nothing, when any of these holds: | `SystemUUIDNotRecorded` | The Device has no system UUID on record. | | `SystemUUIDMismatch` | The expected UUID differs from the Device record. | | `DiscoveryNotCurrent` | Discovery has not recently read the BMC and matched its identity. | +| `SystemNotObserved` | Discovery did not see exactly one server with the expected UUID. | +| `SharedPublicKey` | The BMC shares its TLS key with another BMC, so the key cannot tell them apart. | | `ResetTypeNotOffered` | The server does not offer the requested action. | +| `DeviceNotFound` | The Device does not exist in the namespace. | | `DeviceRetired` | The Device is retired. | | `Expired` | The operation waited more than five minutes to be accepted. | -**Execution.** The worker re-checks the server's identity and offered actions, -reads the power state, and sends one command. If the server is already in the -requested state, the worker sends nothing and reports success. A restart or -power cycle of a server that is off is refused. +**Execution.** Just before it starts the worker, the dispatcher checks again +that no capacity is defined on the Device. A worker that starts more than two +minutes after that check, for example because its image was slow to pull, +refuses with reason `Stale` and sends nothing. The worker then re-checks the +server's identity and offered actions, reads the power state, and sends one +command. If the server is already in the requested state, it sends nothing and +reports success. It refuses a restart or power cycle of a server that is off, +and any action while the power state is still changing. **Result.** HTTP success from the BMC is not proof. The result depends on what the worker observes afterwards: @@ -176,8 +184,9 @@ the worker observes afterwards: | `On`, `ForceOff` | The requested power state appears within three minutes. | `Unknown` | | `ForceRestart`, `PowerCycle` | The BMC shows that a reset happened after the request, and the server is on again. | `Unknown` | -A BMC that refuses the command gives `Failed`. A command whose response is lost -is never resent, and its result follows the table above. +A BMC that refuses the command gives `Failed`, unless the power state has +changed anyway, which gives `Unknown`. A command whose response is lost is +never resent, and its result follows the table above. **What staff see when something breaks.** If Fleet knows nothing was sent, the result is `Failed`. If a command may have been sent and Fleet cannot prove the @@ -205,8 +214,9 @@ command already sent. The dispatcher could, in principle, start a worker with any credential in its site. Admission policies in the site limit every worker to the approved image, one credential, and no extra privileges. A worker pointed at the wrong BMC fails -the TLS key check before it sends the credential. A worker given the wrong -credential fails the identity check before it sends a command. +the TLS key check before it sends the credential. Fleet refuses Devices whose +BMCs share a TLS key, because the check cannot tell those BMCs apart. A worker +given the wrong credential fails the identity check before it sends a command. ## Design decisions @@ -273,8 +283,10 @@ button. cycle stay disabled on real hardware until this test shows a restart can be proven. 5. **Allocator gate.** The allocator refuses capacity whose Device has a running - operation. This closes a window of about two minutes between acceptance and - the command, in which new capacity could be defined. + operation. This closes the window of up to two minutes between the + dispatcher's last capacity check and the command. New capacity is disabled + for allocation by default, so using that window would also take a second + operator action. ## Open design questions @@ -283,7 +295,8 @@ button. - **Lost response, then the right state.** The proposal reports `Succeeded` when the requested power state appears after a lost response. The stricter option reports `Unknown`. -- **When restarts ship.** Should restart and power cycle wait for the +- **Restart evidence.** A restart can be proven only when the BMC reports + that a reset happened. Should restart and power cycle wait for the real-hardware test, or ship earlier for the lab only? - **Graceful actions.** They are excluded because an unallocated server often has no trusted operating system. Does anyone need them? @@ -292,8 +305,9 @@ button. - **Unserved operations.** An operation for a Device that no site serves is never accepted. Should something expire it? - **Credential naming.** Workers find their credential by a name derived from - the Device, which changes how discovery credentials are named. Is that - acceptable, or should a credential broker handle it? + the Device, which changes how discovery credentials are named. The + alternatives are a dispatcher that can read credentials, or a credential + broker. Which should Fleet use? - **Installation server list.** The installation system keeps its own list of servers. Should it derive that list from Devices, so the capacity check covers it? From 8c521fa3cce687e4cdd74eb680427efa9adb6840 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 15:19:24 -0600 Subject: [PATCH 04/26] docs: Match the Device power proposal to the template Reviewers read enhancements in the shape the machine lifecycle proposal set. It uses summary, motivation, proposal, design details, readiness questions, drawbacks and alternatives, with commented API examples and diagrams that show who takes part and how work flows. The Device power proposal now follows that shape, so a reviewer can compare it with the other enhancements section by section. Three diagrams replace the text sketch: the participants, one operation from request to result, and the lifecycle with its three outcomes. They are hand-written SVG in the same palette, type and accessible title and description as the lifecycle diagrams, because those have no checked-in generator. Design rationale moves into the alternatives, and the safety rules are unchanged. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 401 +++++++++++------- .../diagrams/operation-lifecycle.svg | 40 ++ .../diagrams/operation-sequence.svg | 47 ++ .../device-power/diagrams/participants.svg | 53 +++ 4 files changed, 376 insertions(+), 165 deletions(-) create mode 100644 docs/enhancements/device-power/diagrams/operation-lifecycle.svg create mode 100644 docs/enhancements/device-power/diagrams/operation-sequence.svg create mode 100644 docs/enhancements/device-power/diagrams/participants.svg diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 35384e22..8ee3d130 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -7,105 +7,131 @@ stage: alpha [Documentation overview](../../README.md) · [Architecture guide](../../architecture/README.md) -This is a proposal. None of it is implemented. - - [Summary](#summary) -- [Who it is for](#who-it-is-for) -- [Goals and non-goals](#goals-and-non-goals) -- [How it works](#how-it-works) -- [API](#api) -- [Lifecycle and outcomes](#lifecycle-and-outcomes) -- [Who can do what](#who-can-do-what) -- [Design decisions](#design-decisions) -- [Relationship to Machine power](#relationship-to-machine-power) -- [Staff UI](#staff-ui) -- [Delivery phases](#delivery-phases) +- [Motivation](#motivation) + - [Goals](#goals) + - [Non-goals](#non-goals) +- [Proposal](#proposal) + - [User stories](#user-stories) + - [Requesting a power operation](#requesting-a-power-operation) + - [Who takes part](#who-takes-part) + - [Risks and mitigations](#risks-and-mitigations) +- [Design details](#design-details) + - [API design](#api-design) + - [Status contract](#status-contract) + - [Acceptance checks](#acceptance-checks) + - [Execution and outcomes](#execution-and-outcomes) + - [Authorization](#authorization) + - [Relationship to Machine power](#relationship-to-machine-power) + - [Delivery phases](#delivery-phases) + - [Acceptance tests](#acceptance-tests) +- [Production readiness review questionnaire](#production-readiness-review-questionnaire) +- [Drawbacks](#drawbacks) +- [Alternatives](#alternatives) - [Open design questions](#open-design-questions) +- [Infrastructure needed](#infrastructure-needed) ## Summary -Staff who build and maintain hardware need to power servers on and off, and to -reset them. Today they do it by hand in each server's management controller -(BMC). Fleet keeps no record of who did it, the action bypasses the per-Device -credentials and TLS checks Fleet already uses, and nothing stops a reset of a -server a customer is using. - -This proposal adds a `DevicePowerOperation` resource. A staff member creates one -to ask for a single power action on one unallocated Device. Fleet checks the -request, sends one command to the exact server named, and reports whether the +Staff will be able to power an unallocated server on or off, or reset it, from +Fleet. One new resource defines the contract: `DevicePowerOperation`. Each +operation asks for a single action on one Device. Fleet checks the request, +sends at most one command to the exact server named, and reports whether the action succeeded, failed, or has an unknown outcome. -## Who it is for +This is a proposal. Nothing in it is implemented. + +## Motivation + +Staff who build and maintain hardware need basic power control. Today they use +each server's baseboard management controller (BMC) by hand. Fleet keeps no +record of who did it, the action bypasses the per-Device credentials and TLS +checks Fleet already uses, and nothing stops a reset of a server a customer is +using. + +### Goals + +- Let staff power on, power off, restart and power cycle an unallocated Device, + and see the result. +- Send at most one command per request, to the exact server staff named. +- Report an outcome Fleet cannot prove as unknown, never as success, and never + retry it automatically. +- Record who asked, why, and the power state before and after. + +### Non-goals + +This enhancement excludes power control of allocated servers, which stays with +the customer's Machine. It also excludes a desired power state for Devices, +graceful shutdown and restart, boot settings, virtual media, BMC settings, +firmware, and power distribution units. -Infrastructure staff who rack, qualify and move servers before those servers -offer capacity to customers. +## Proposal -- A technician racks a new server and powers it on from the Device page, so - Fleet can read its hardware inventory. -- Staff reset a server that hangs during qualification. The Device page shows - who reset it, when, and the power state afterwards. +Fleet will let staff request one power action at a time on a Device that offers +no customer capacity. The Device keeps its identity; only its power changes. +Each request becomes a permanent record of the action and its result. + +### User stories + +- A technician racks a new server and powers it on, so Fleet can read its + hardware inventory. +- Staff reset a server that hangs during qualification, and see who reset it, + when, and the power state afterwards. - Staff power off a server before moving it to another rack. -- A server's BMC is replaced and now reports a different system. A power - request made against the old record is refused before anything reaches the - server. +- A server's BMC is replaced and now reports a different system. A request made + against the old record is refused before anything reaches the server. - Staff try to reset a server that backs customer capacity. Fleet refuses, and nothing reaches the server. -## Goals and non-goals - -Goals: - -- Staff can request power on, power off, restart and power cycle on an - unallocated Device, and see the result. -- Each request sends at most one command, to the exact server staff named. -- An outcome Fleet cannot prove is reported as unknown, never as success, and - is never retried automatically. -- Each request records who asked, why, and the power state before and after. - -Non-goals: - -- Power control of allocated servers. That stays with the customer's Machine. -- A desired power state for Devices. A Device has none. -- Graceful shutdown and graceful restart, which need the operating system to - cooperate. -- Boot settings, virtual media, BMC settings, firmware, or power distribution - units. - -## How it works - -```text -staff creates a DevicePowerOperation - │ - ▼ -dispatcher, in the site that can reach the BMC - checks the request, then starts one worker - │ - ▼ -worker, holding only this Device's BMC credential - re-checks the server's identity, sends one command, - watches the power state, reports the result -``` +### Requesting a power operation + +Staff use a power button on the Device page, next to the observed power state. +Its menu lists only the actions the server offers. An unavailable action shows +its refusal reason in a tooltip. Confirming asks for a reason and creates the +operation. A badge then shows progress and the result. An **Operations** tab +lists past operations with their time, action, requester, result, and power +before and after. Users without the power operator role do not see the button. -Three components take part: +Staff can also create the resource directly through the API. + +### Who takes part + +The request lives in the provider project. The work happens in the site that can +reach the server's BMC: + +![Staff create the operation; the site dispatcher checks it and starts one worker that holds one credential](diagrams/participants.svg) - **The dispatcher** runs in the site, next to the existing BMC discovery - process. It accepts or refuses each request and starts a worker. It is the - only writer of the operation's status. It holds no BMC credential. -- **The worker** is a short-lived process started for one operation. It can - read only the target Device's BMC credential. It has no access to the Fleet - control plane. + process. It accepts or refuses each request, starts a worker, and is the only + writer of the operation's status. It holds no BMC credential. +- **The worker** is a short-lived process started for one operation. It can read + only the target Device's BMC credential, and it cannot reach the provider + project. - **BMC discovery** already reads each BMC and records what it reports on the - Device. It stays read-only. This proposal adds one thing to what it records: - which power actions each server offers. + Device. It stays read-only. It will also record which power actions each + server offers. Every connection to a BMC checks the BMC's approved TLS key before it sends a credential, the same check discovery uses today. -## API +### Risks and mitigations + +- **Resetting a customer's server:** [Acceptance checks](#acceptance-checks) + refuse any Device with capacity defined on it. +- **Resetting the wrong server:** The request names the server's UUID, and the + worker re-checks it against the BMC before it acts. +- **Repeating a reset:** Each operation sends at most one command, and nothing + retries it. See [execution and outcomes](#execution-and-outcomes). +- **Credential exposure:** Each worker reads one credential, and the dispatcher + reads none. See [authorization](#authorization). + +## Design details + +### API design `DevicePowerOperation` belongs to `fleet.datumapis.com`. It lives in the -provider project, in the same namespace as its Device. The values below are -synthetic. +provider project, in the same namespace as its Device. Identifiers and +timestamps in the example are synthetic. ```yaml apiVersion: fleet.datumapis.com/v1alpha1 @@ -113,71 +139,100 @@ kind: DevicePowerOperation metadata: name: device-a-restart-1 namespace: default +# The whole spec is fixed at creation. A changed request is a new operation. spec: + # The Device to act on, in the same namespace. deviceRef: {name: device-a} + # One of On, ForceOff, ForceRestart or PowerCycle. action: ForceRestart + # The server staff expect behind the BMC. The operation fails if the Device + # record or the BMC reports another. expectedSystemUUID: 00000000-0000-4000-8000-0000000000a1 + # Admission requires this to equal the user who creates the operation. requester: staff@example.com + # Required free text for the audit record. reason: Hung in firmware during qualification + +# The site dispatcher alone writes status. It never carries a credential or +# any BMC response content. status: conditions: - {type: Accepted, status: "True", reason: Accepted} - {type: Executing, status: "False", reason: Finished} - {type: Finished, status: "True", reason: ResetObserved} + # Succeeded, Failed or Unknown. Set once and never changed. result: Succeeded + # When the one command was sent. Absent if none was sent. requestSentAt: "2026-01-02T03:04:06Z" + # The power state seen before and after the command. power: before: {state: "On", observedAt: "2026-01-02T03:04:05Z"} after: {state: "On", observedAt: "2026-01-02T03:04:41Z"} finishedAt: "2026-01-02T03:04:42Z" ``` -| Field | Meaning | -| --- | --- | -| `deviceRef` | The Device to act on, in the same namespace. | -| `action` | `On`, `ForceOff`, `ForceRestart` or `PowerCycle`. | -| `expectedSystemUUID` | The server staff expect behind the BMC. The operation fails if the Device record or the BMC reports another. | -| `requester` | Must equal the user who creates the operation. Admission enforces this. | -| `reason` | Required free text for the audit record. | -| `status.result` | `Succeeded`, `Failed` or `Unknown`. Set once and never changed. | -| `status.power` | The power state seen before and after the command. | +A separate resource fits better than a field on the Device. A reset is an event, +not a state, and each operation needs its own audit record. See +[alternatives](#alternatives). -The whole spec is fixed at creation. A changed request is a new operation. -Status never carries a credential or any BMC response content. +### Status contract -## Lifecycle and outcomes +An operation moves through `Accepted` and `Executing` to `Finished`, or is +refused before it is accepted: -An operation moves through three conditions: `Accepted`, `Executing`, then -`Finished` with a result. +![An operation is refused or accepted, executes once, and finishes as Succeeded, Failed or Unknown](diagrams/operation-lifecycle.svg) -**Acceptance.** The dispatcher refuses an operation with `result: Failed`, and -sends nothing, when any of these holds: +- **`Failed`** means Fleet knows nothing was sent, or the BMC refused the + command and the power did not change. +- **`Unknown`** means a command may have been sent and Fleet cannot prove the + outcome. It ends the operation. Staff check the next discovery result and + create a new operation if they still need one. +- **`Succeeded`** means Fleet observed the requested state, or observed the + reset. + +Deleting an operation does not cancel a command already sent. + +### Acceptance checks + +The dispatcher refuses an operation with `result: Failed`, and sends nothing, +when any of these holds: | Reason | When | | --- | --- | | `CapacityBacked` | Customer capacity is defined on the Device. | | `OperationInProgress` | Another operation on the Device is still running. | +| `DeviceNotFound` | The Device does not exist in the namespace. | +| `DeviceRetired` | The Device is retired. | | `SystemUUIDNotRecorded` | The Device has no system UUID on record. | | `SystemUUIDMismatch` | The expected UUID differs from the Device record. | | `DiscoveryNotCurrent` | Discovery has not recently read the BMC and matched its identity. | | `SystemNotObserved` | Discovery did not see exactly one server with the expected UUID. | | `SharedPublicKey` | The BMC shares its TLS key with another BMC, so the key cannot tell them apart. | | `ResetTypeNotOffered` | The server does not offer the requested action. | -| `DeviceNotFound` | The Device does not exist in the namespace. | -| `DeviceRetired` | The Device is retired. | | `Expired` | The operation waited more than five minutes to be accepted. | -**Execution.** Just before it starts the worker, the dispatcher checks again -that no capacity is defined on the Device. A worker that starts more than two -minutes after that check, for example because its image was slow to pull, -refuses with reason `Stale` and sends nothing. The worker then re-checks the -server's identity and offered actions, reads the power state, and sends one -command. If the server is already in the requested state, it sends nothing and -reports success. It refuses a restart or power cycle of a server that is off, -and any action while the power state is still changing. +A second request while one is running is refused, not queued. A queued request +could run minutes later, after its reason is gone. + +### Execution and outcomes + +One operation runs from request to result like this: + +![Sequence of one power operation from request to result](diagrams/operation-sequence.svg) + +Just before it starts the worker, the dispatcher checks again that no capacity +is defined on the Device. A worker that starts more than two minutes after that +check, for example because its image was slow to pull, refuses with reason +`Stale` and sends nothing. -**Result.** HTTP success from the BMC is not proof. The result depends on what -the worker observes afterwards: +The worker re-checks the server's identity and offered actions, reads the power +state, and sends one command. If the server is already in the requested state, +the worker sends nothing and reports success. It refuses a restart or power +cycle of a server that is off, and any action while the power state is still +changing. + +HTTP success from the BMC is not proof. The result depends on what the worker +observes afterwards: | Action | `Succeeded` when | Otherwise | | --- | --- | --- | @@ -185,24 +240,15 @@ the worker observes afterwards: | `ForceRestart`, `PowerCycle` | The BMC shows that a reset happened after the request, and the server is on again. | `Unknown` | A BMC that refuses the command gives `Failed`, unless the power state has -changed anyway, which gives `Unknown`. A command whose response is lost is -never resent, and its result follows the table above. - -**What staff see when something breaks.** If Fleet knows nothing was sent, the -result is `Failed`. If a command may have been sent and Fleet cannot prove the -outcome, the result is `Unknown`. This covers these cases: +changed anyway, which gives `Unknown`. A command whose response is lost is never +resent, and its result follows the table above. -- a worker that crashes; -- a site process that restarts; -- a BMC that stops answering; -- a second worker started by mistake, which stops before it contacts the BMC - and leaves the first worker's result in place. +The same rule covers failures inside Fleet. If a worker crashes, a site process +restarts, or a BMC stops answering after a command may have been sent, the +result is `Unknown`. A second worker started by mistake stops before it contacts +the BMC and leaves the first worker's result in place. -`Unknown` ends the operation. Staff check the next discovery result and create -a new operation if they still need one. Deleting an operation does not cancel a -command already sent. - -## Who can do what +### Authorization | Who | Can | | --- | --- | @@ -218,35 +264,7 @@ the TLS key check before it sends the credential. Fleet refuses Devices whose BMCs share a TLS key, because the check cannot tell those BMCs apart. A worker given the wrong credential fails the identity check before it sends a command. -## Design decisions - -**A separate resource, not a Device field.** A reset is an event, not a state. -A field on the Device would need a controller to tell an old value from a new -request, and re-applying a manifest would reset the server again. A separate -resource gives each operation its own audit record and keeps one writer for each -part of the Device. - -**No override for capacity-backed Devices.** A server that offers customer -capacity may be allocated, installing or being cleaned. Every power action on it -must be ordered with that work, and a staff override would skip that ordering. -Staff first remove the capacity through the normal release process. - -**Refuse instead of queueing.** A second request while one is running is -refused. A queued request could run minutes later, after its reason is gone. - -**One command, no retries.** Repeating a restart is a second restart. A staff -member who wants another attempt creates a new operation, which leaves a new -audit record and passes the checks again. - -**One credential per worker.** Neither discovery nor the dispatcher sends power -commands. A long-lived process that could send commands to every BMC would be -the most valuable target in the site. Each worker can reach only one BMC. - -**Name the exact server.** The request carries the server's UUID, and the worker -re-checks it against the BMC before acting. A replaced or renumbered server -behind the same BMC address is refused. - -## Relationship to Machine power +### Relationship to Machine power `Machine.spec.powerState` in the [machine lifecycle enhancement](../machine-lifecycle/README.md) is the @@ -262,23 +280,12 @@ Its authority comes from the allocation, as the requires for resets: "a bounded, idempotent operation with MachineAllocation preconditions." -## Staff UI - -The Device page gets a power button next to the observed power state. Its menu -lists only the actions the server offers, and an unavailable action shows its -refusal reason in a tooltip. Confirming asks for a reason and creates the -operation, and a badge then shows progress and the result. An **Operations** -tab lists past operations as a table of time, action, requester, result, and -power before and after. Users without the power operator role do not see the -button. - -## Delivery phases +### Delivery phases 1. **Discovery records offered actions.** No new effect. 2. **API and roles.** Operations can be created but stay unaccepted, so they have no effect. -3. **Dispatcher and worker**, tested against an emulated BMC for lost - responses, a replaced server, an unsupported action and a duplicate worker. +3. **Dispatcher and worker.** Tested against an emulated BMC. 4. **Staff UI and one real server** that backs no capacity. Restart and power cycle stay disabled on real hardware until this test shows a restart can be proven. @@ -288,6 +295,65 @@ button. for allocation by default, so using that window would also take a second operator action. +### Acceptance tests + +Tests against an emulated BMC must show, for each case, the result staff see +and how many commands reached the BMC: + +- a lost response after power on, power off, and restart; +- a replaced server behind the same BMC address; +- an action the server does not offer, and a wrong TLS key or credential; +- a second worker for one operation, and a worker lost after its command; +- two requests at once for one Device, and a Device with capacity defined. + +One staged test on a real server follows before restarts are enabled on real +hardware. These tests are required and have not been written. + +## Production readiness review questionnaire + +These controls are proposed, not implemented. + +### How do operators enable or disable the feature? + +Per site, by deploying the dispatcher. Without a dispatcher, operations stay +unaccepted and have no effect. Removing it stops new work. A running worker +finishes, and its result waits in the site until a dispatcher publishes it. + +### What must operators monitor? + +Operations that stay unaccepted, `Unknown` results, duplicate workers, and +dispatcher restarts. + +### How are failures recovered? + +An `Unknown` operation needs a person. Check the next discovery result, then +create a new operation if one is still needed. Nothing retries automatically. + +## Drawbacks + +- A site process and a worker per action add seconds of delay over a direct + BMC call. +- Restarts can end as `Unknown` on BMCs that do not report when a reset + happened. +- Staff cannot power-control a capacity-backed Device without first removing + its capacity. + +## Alternatives + +- **A power field on the Device.** Rejected. A field would need a controller to + tell an old value from a new request, and re-applying a manifest would reset + the server again. It would also add a second writer to the Device. +- **A staff override for capacity-backed Devices.** Not proposed. Every power + action on such a server must be ordered with allocation, installation and + cleaning, and an override would skip that ordering. +- **Automatic retries.** Rejected. Repeating a restart is a second restart. A + new operation leaves a new audit record and passes the checks again. +- **Let discovery or the dispatcher send commands.** Rejected. A long-lived + process that could send commands to every BMC would be the most valuable + target in the site. +- **Machine power intent for unallocated Devices.** Rejected. A Machine is a + customer allocation, and creating one for staff would expose capacity. + ## Open design questions - **Override for capacity-backed Devices.** This proposal has none. Is a future @@ -295,9 +361,9 @@ button. - **Lost response, then the right state.** The proposal reports `Succeeded` when the requested power state appears after a lost response. The stricter option reports `Unknown`. -- **Restart evidence.** A restart can be proven only when the BMC reports - that a reset happened. Should restart and power cycle wait for the - real-hardware test, or ship earlier for the lab only? +- **Restart evidence.** A restart can be proven only when the BMC reports that + a reset happened. Should restart and power cycle wait for the real-hardware + test, or ship earlier for the lab only? - **Graceful actions.** They are excluded because an unallocated server often has no trusted operating system. Does anyone need them? - **Retention.** How long are finished operations kept, and who may delete @@ -313,3 +379,8 @@ button. covers it? - **Requester source.** Should the requester come from Milo's audit record instead of a spec field checked at admission? + +## Infrastructure needed + +An emulated BMC that supports TLS and reports when a reset happened, and one +real server that backs no capacity, with an approved TLS key and a credential. diff --git a/docs/enhancements/device-power/diagrams/operation-lifecycle.svg b/docs/enhancements/device-power/diagrams/operation-lifecycle.svg new file mode 100644 index 00000000..b26a8562 --- /dev/null +++ b/docs/enhancements/device-power/diagrams/operation-lifecycle.svg @@ -0,0 +1,40 @@ + +Device power operation lifecycle and outcomesAn operation is created with its spec fixed and its requester checked. The dispatcher either refuses it, which ends as Failed with nothing sent, or marks it Accepted. An accepted operation moves to Executing, where one worker sends at most one command. It finishes with one of three results. Succeeded means the requested power state or a reset was observed. Failed means Fleet knows nothing was sent, or the BMC refused and power did not change. Unknown means a command may have been sent and the outcome is unproven. The result is set once and never changes. + + + + +Created +Spec fixed; requester checked + + +Accepted +Every dispatcher check passed + + +Executing +One worker; at most one command + +Refused +Failed; nothing sent + + + +Finished + + + + +Succeeded +Requested state or +reset observed + +Failed +Nothing sent, or the +BMC refused it + +Unknown +Maybe sent; +outcome unproven +The result is set once. Staff create a new operation to try again. + diff --git a/docs/enhancements/device-power/diagrams/operation-sequence.svg b/docs/enhancements/device-power/diagrams/operation-sequence.svg new file mode 100644 index 00000000..20fb3a35 --- /dev/null +++ b/docs/enhancements/device-power/diagrams/operation-sequence.svg @@ -0,0 +1,47 @@ + +One Device power operation from request to resultStaff create an operation in the provider project. The dispatcher checks the Device, its discovery and its capacity, then marks the operation Accepted. It marks the operation Executing, checks capacity again, and starts one worker. The worker checks the BMC's TLS key, the server's identity and the offered actions, then sends one command. It watches the power state, and reports the result to the dispatcher, which writes it to the operation. Staff read Succeeded, Failed or Unknown. A lost response is never resent, and an outcome Fleet cannot prove ends as Unknown. + + + + +Staff + + +Provider +project + + +Dispatcher + + +Worker + + +BMC + +Create operation + +Checks pass: +mark Accepted + +Mark Executing + +Check capacity +again; start one + +Check TLS key, +identity, actions + +Send one command + +Power state + +Result + +Write result + +Read result + + +A lost response is never resent. An outcome Fleet cannot prove ends as Unknown. + diff --git a/docs/enhancements/device-power/diagrams/participants.svg b/docs/enhancements/device-power/diagrams/participants.svg new file mode 100644 index 00000000..5903dce0 --- /dev/null +++ b/docs/enhancements/device-power/diagrams/participants.svg @@ -0,0 +1,53 @@ + +Who takes part in a Device power operationStaff with the power operator role create a DevicePowerOperation in the provider project. The operation names a Device. MachineCapacity on a Device blocks power operations. In the site that can reach the BMC, the dispatcher reads the operation, the Device and capacity, and writes the operation's status. It starts one worker per operation. The worker holds one Device's BMC credential and sends at most one command to that BMC. BMC discovery reads BMCs, never changes them, and writes Device status. Only the worker and discovery read BMC credentials, and the worker has no access to the provider project. + + + + +Staff +Power operator role + +Provider project + +Device +Identity and discovery + +DevicePowerOperation +One action, fixed at creation + +MachineCapacity +Blocks power operations + +creates + +names + +Site + +Dispatcher +Checks, starts workers + +Worker +One operation, one credential + +BMC discovery +Read-only + +BMC +One per server + +reads, writes status + +reads + +reads + +writes status + +starts + +one command + +reads, never changes +Only the worker and discovery read BMC credentials. The worker cannot reach the provider project. + From 9ebfe0e191dbfa74210aa3ba278bf60351064c2e Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 15:20:51 -0600 Subject: [PATCH 05/26] docs: Clarify Device power diagram labels Reviewers read the lifecycle's refusal box as the only way an operation fails before its command, and the participants diagram set the "names" label far from its arrow. The refusal box now says it is refused at acceptance, its description says a worker that stops before its command also ends as Failed, and the label sits on its arrow. The proposal also gains the implementation history section the machine lifecycle template has, and an open question no longer hints at a test environment. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 8 +++++++- .../device-power/diagrams/operation-lifecycle.svg | 4 ++-- .../device-power/diagrams/participants.svg | 10 +++++----- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 8ee3d130..92c9ca10 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -26,6 +26,7 @@ stage: alpha - [Delivery phases](#delivery-phases) - [Acceptance tests](#acceptance-tests) - [Production readiness review questionnaire](#production-readiness-review-questionnaire) +- [Implementation history](#implementation-history) - [Drawbacks](#drawbacks) - [Alternatives](#alternatives) - [Open design questions](#open-design-questions) @@ -329,6 +330,11 @@ dispatcher restarts. An `Unknown` operation needs a person. Check the next discovery result, then create a new operation if one is still needed. Nothing retries automatically. +## Implementation history + +- 2026-11-24: Proposed. The design builds on BMC discovery, TLS key pinning + and the per-operation worker pattern already used for installation. + ## Drawbacks - A site process and a worker per action add seconds of delay over a direct @@ -363,7 +369,7 @@ create a new operation if one is still needed. Nothing retries automatically. option reports `Unknown`. - **Restart evidence.** A restart can be proven only when the BMC reports that a reset happened. Should restart and power cycle wait for the real-hardware - test, or ship earlier for the lab only? + test, or ship earlier for test hardware only? - **Graceful actions.** They are excluded because an unallocated server often has no trusted operating system. Does anyone need them? - **Retention.** How long are finished operations kept, and who may delete diff --git a/docs/enhancements/device-power/diagrams/operation-lifecycle.svg b/docs/enhancements/device-power/diagrams/operation-lifecycle.svg index b26a8562..d2d284f2 100644 --- a/docs/enhancements/device-power/diagrams/operation-lifecycle.svg +++ b/docs/enhancements/device-power/diagrams/operation-lifecycle.svg @@ -1,5 +1,5 @@ -Device power operation lifecycle and outcomesAn operation is created with its spec fixed and its requester checked. The dispatcher either refuses it, which ends as Failed with nothing sent, or marks it Accepted. An accepted operation moves to Executing, where one worker sends at most one command. It finishes with one of three results. Succeeded means the requested power state or a reset was observed. Failed means Fleet knows nothing was sent, or the BMC refused and power did not change. Unknown means a command may have been sent and the outcome is unproven. The result is set once and never changes. +Device power operation lifecycle and outcomesAn operation is created with its spec fixed and its requester checked. The dispatcher either refuses it at acceptance, which ends as Failed with nothing sent, or marks it Accepted. An accepted operation moves to Executing, where one worker sends at most one command. A worker that stops before its command also ends as Failed. It finishes with one of three results. Succeeded means the requested power state or a reset was observed. Failed means Fleet knows nothing was sent, or the BMC refused and power did not change. Unknown means a command may have been sent and the outcome is unproven. The result is set once and never changes. @@ -15,7 +15,7 @@ Executing One worker; at most one command -Refused +Refused at acceptance Failed; nothing sent diff --git a/docs/enhancements/device-power/diagrams/participants.svg b/docs/enhancements/device-power/diagrams/participants.svg index 5903dce0..0288936b 100644 --- a/docs/enhancements/device-power/diagrams/participants.svg +++ b/docs/enhancements/device-power/diagrams/participants.svg @@ -8,9 +8,9 @@ Power operator role Provider project - -Device -Identity and discovery + +Device +Identity and discovery DevicePowerOperation One action, fixed at creation @@ -19,8 +19,8 @@ Blocks power operations creates - -names + +names Site From cda942a1bc9783d105dcb31053f72136dd9c7bb3 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 15:21:48 -0600 Subject: [PATCH 06/26] docs: Mark Device power dependencies as unmerged The implementation history said the per-operation worker pattern is already used for installation. On main it is not: discovery, TLS key pinning and the installation workers exist only on an integration branch. The entry now says so, keeping proposed and implemented behavior apart. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 92c9ca10..94ae9aed 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -333,7 +333,8 @@ create a new operation if one is still needed. Nothing retries automatically. ## Implementation history - 2026-11-24: Proposed. The design builds on BMC discovery, TLS key pinning - and the per-operation worker pattern already used for installation. + and per-operation workers from the installation work, which exist on an + integration branch and are not yet on `main`. ## Drawbacks From dbc41da78ab9d1c58d411de276860f8736bee233 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 15:22:15 -0600 Subject: [PATCH 07/26] docs: Describe BMC discovery as not yet on main Two lines in the Device power proposal described BMC discovery and its TLS key check as current behavior. Discovery is built on an integration branch but is not on main, and the implementation history already says so. The two lines now agree with it. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 94ae9aed..ea991053 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -108,12 +108,12 @@ reach the server's BMC: - **The worker** is a short-lived process started for one operation. It can read only the target Device's BMC credential, and it cannot reach the provider project. -- **BMC discovery** already reads each BMC and records what it reports on the - Device. It stays read-only. It will also record which power actions each - server offers. +- **BMC discovery** reads each BMC and records what it reports on the Device. + It is built but not yet on `main`. It stays read-only, and will also record + which power actions each server offers. Every connection to a BMC checks the BMC's approved TLS key before it sends a -credential, the same check discovery uses today. +credential, the same check discovery makes. ### Risks and mitigations From 2de2e486065d28896ddd41c6734f97886b7ea4f7 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 15:22:25 -0600 Subject: [PATCH 08/26] docs: Tie Device power motivation to discovery The motivation said staff bypass credentials and TLS checks "Fleet already uses". Those belong to BMC discovery, which is not yet on main, so the sentence now names discovery instead of implying the checks are current behavior. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index ea991053..cc1f8b6f 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -47,8 +47,8 @@ This is a proposal. Nothing in it is implemented. Staff who build and maintain hardware need basic power control. Today they use each server's baseboard management controller (BMC) by hand. Fleet keeps no record of who did it, the action bypasses the per-Device credentials and TLS -checks Fleet already uses, and nothing stops a reset of a server a customer is -using. +checks that BMC discovery uses, and nothing stops a reset of a server a +customer is using. ### Goals From 950dce25f6a3c8e300c00e6e4275ac01440714e2 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 15:22:57 -0600 Subject: [PATCH 09/26] docs: Stop calling Device power dependencies existing The proposal still called BMC discovery "existing" and described the installation work's server list as a current system, while the same document says both are not yet on main. Both lines now describe them without implying they are implemented there. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index cc1f8b6f..997e9eca 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -102,9 +102,9 @@ reach the server's BMC: ![Staff create the operation; the site dispatcher checks it and starts one worker that holds one credential](diagrams/participants.svg) -- **The dispatcher** runs in the site, next to the existing BMC discovery - process. It accepts or refuses each request, starts a worker, and is the only - writer of the operation's status. It holds no BMC credential. +- **The dispatcher** runs in the site, next to the BMC discovery process. It + accepts or refuses each request, starts a worker, and is the only writer of + the operation's status. It holds no BMC credential. - **The worker** is a short-lived process started for one operation. It can read only the target Device's BMC credential, and it cannot reach the provider project. @@ -381,7 +381,7 @@ create a new operation if one is still needed. Nothing retries automatically. the Device, which changes how discovery credentials are named. The alternatives are a dispatcher that can read credentials, or a credential broker. Which should Fleet use? -- **Installation server list.** The installation system keeps its own list of +- **Installation server list.** The installation work keeps its own list of servers. Should it derive that list from Devices, so the capacity check covers it? - **Requester source.** Should the requester come from Milo's audit record From 5c5f2ae537d95fd50d11c0a7436880df558c6181 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 16:57:37 -0600 Subject: [PATCH 10/26] docs: Build Device power on device custody The device custody and operations proposal defines one custody record per server, the operation envelope, admission, site execution and recovery holds for every physical action. The power proposal had its own lock, a capacity check, a site process that wrote status, and an Unknown result that left the server free, so the two disagreed. The power proposal now specifies only the power kind and links to the custody proposal for the rest. Staff power needs holder None, which allows disabled capacity, and customer power runs under the Machine's allocation when powerState changes. The coordinator writes status from fenced site results, and an Unknown result places a recovery hold that settles with fresh discovery evidence and a staff recovery record. The diagrams show the same flow. Co-Authored-By: Claude Opus 5.5 --- README.md | 3 +- docs/README.md | 2 +- docs/architecture/README.md | 2 +- docs/enhancements/device-power/README.md | 406 +++++++----------- .../diagrams/operation-lifecycle.svg | 25 +- .../diagrams/operation-sequence.svg | 79 ++-- .../device-power/diagrams/participants.svg | 98 ++--- 7 files changed, 271 insertions(+), 344 deletions(-) diff --git a/README.md b/README.md index e41c70f7..b0e96972 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,8 @@ today. Then choose a topic: The [Bare Metal CLI enhancement](docs/enhancements/metal-cli/README.md) proposes `datumctl metal` discovery, machine management, and safe recovery workflows. The [Device power enhancement](docs/enhancements/device-power/README.md) -proposes how staff power unallocated servers on, off, or reset them. +proposes the power operation that staff and Metal customers use to change a +server's power. Contributors should also read the [repository guidance](AGENTS.md) and [implementation roadmap](docs/development/roadmap.md). diff --git a/docs/README.md b/docs/README.md index 99eb0dee..0a0294cd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -72,7 +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 power](enhancements/device-power/README.md) | Proposed staff power operations on unallocated servers | +| [Device power](enhancements/device-power/README.md) | Proposed power operations for staff and Metal customers | | [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 62805d49..90e360e1 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -38,7 +38,7 @@ Key principles to carry into the detailed design: | How are reservations and concurrent operations coordinated? | [Durable coordination](../enhancements/machine-lifecycle/README.md#durable-coordination) | | 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) | -| How do staff power-control an unallocated Device? | [Device power operations](../enhancements/device-power/README.md) | +| How is a server's power changed? | [Device power operations](../enhancements/device-power/README.md) | | Which internal interfaces and guarantees exist? | [Implementation status](../development/README.md) | | Which milestones must precede rollout? | [Implementation roadmap](../development/roadmap.md) | | Where did the design originate? | [Pinned source proposals](design.md#source-proposals), [migration record](../proposals/fleet-management/MIGRATION.md) | diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 997e9eca..106f2121 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -3,7 +3,7 @@ status: provisional stage: alpha --- -# Staff power operations on physical Devices +# Device power operations [Documentation overview](../../README.md) · [Architecture guide](../../architecture/README.md) @@ -13,16 +13,14 @@ stage: alpha - [Non-goals](#non-goals) - [Proposal](#proposal) - [User stories](#user-stories) - - [Requesting a power operation](#requesting-a-power-operation) + - [Requesting staff power](#requesting-staff-power) + - [Customer power](#customer-power) - [Who takes part](#who-takes-part) - - [Risks and mitigations](#risks-and-mitigations) - [Design details](#design-details) - [API design](#api-design) - - [Status contract](#status-contract) - - [Acceptance checks](#acceptance-checks) + - [Admission](#admission) - [Execution and outcomes](#execution-and-outcomes) - - [Authorization](#authorization) - - [Relationship to Machine power](#relationship-to-machine-power) + - [Recovery](#recovery) - [Delivery phases](#delivery-phases) - [Acceptance tests](#acceptance-tests) - [Production readiness review questionnaire](#production-readiness-review-questionnaire) @@ -34,105 +32,88 @@ stage: alpha ## Summary -Staff will be able to power an unallocated server on or off, or reset it, from -Fleet. One new resource defines the contract: `DevicePowerOperation`. Each -operation asks for a single action on one Device. Fleet checks the request, -sends at most one command to the exact server named, and reports whether the -action succeeded, failed, or has an unknown outcome. +`DevicePowerOperation` powers a server on or off, or resets it, with one +command. Staff use it on servers that no customer holds. Fleet's Metal provider +uses it when a customer changes `Machine.spec.powerState`. -This is a proposal. Nothing in it is implemented. +This document specifies the power kind only. The [device custody and +operations proposal][ops] defines custody, the operation envelope, admission, +site execution, recovery holds and authorization. Both documents are proposals, +and the device operations proposal is not yet merged. Nothing in either is +implemented. ## Motivation -Staff who build and maintain hardware need basic power control. Today they use -each server's baseboard management controller (BMC) by hand. Fleet keeps no -record of who did it, the action bypasses the per-Device credentials and TLS -checks that BMC discovery uses, and nothing stops a reset of a server a -customer is using. +Staff need basic power control to rack, qualify and move servers. Today they +use each server's baseboard management controller (BMC) by hand. Fleet keeps no +record of the action, and nothing stops a reset of a server a customer is using. +Customer power intent on a Machine has no executor yet. ### Goals -- Let staff power on, power off, restart and power cycle an unallocated Device, - and see the result. -- Send at most one command per request, to the exact server staff named. -- Report an outcome Fleet cannot prove as unknown, never as success, and never - retry it automatically. -- Record who asked, why, and the power state before and after. +- Staff and customer power changes use one kind, one executor and one set of + outcome rules. +- Each operation sends at most one command, to the exact server named. +- Each staff operation records why it ran and the power state before and after. ### Non-goals -This enhancement excludes power control of allocated servers, which stays with -the customer's Machine. It also excludes a desired power state for Devices, -graceful shutdown and restart, boot settings, virtual media, BMC settings, -firmware, and power distribution units. +- Graceful shutdown and restart, which need the operating system to cooperate. +- A customer restart. The Machine API has only on and off intent. +- Boot settings, virtual media, BMC settings, firmware and power distribution + units. ## Proposal -Fleet will let staff request one power action at a time on a Device that offers -no customer capacity. The Device keeps its identity; only its power changes. -Each request becomes a permanent record of the action and its result. - ### User stories - A technician racks a new server and powers it on, so Fleet can read its hardware inventory. -- Staff reset a server that hangs during qualification, and see who reset it, +- Staff reset a server that hangs during qualification, then see who reset it, when, and the power state afterwards. -- Staff power off a server before moving it to another rack. -- A server's BMC is replaced and now reports a different system. A request made +- A customer sets a Machine's power to off, and the server powers off. +- A server's BMC is replaced and reports a different system. A request made against the old record is refused before anything reaches the server. -- Staff try to reset a server that backs customer capacity. Fleet refuses, and - nothing reaches the server. -### Requesting a power operation +### Requesting staff power Staff use a power button on the Device page, next to the observed power state. Its menu lists only the actions the server offers. An unavailable action shows -its refusal reason in a tooltip. Confirming asks for a reason and creates the -operation. A badge then shows progress and the result. An **Operations** tab -lists past operations with their time, action, requester, result, and power -before and after. Users without the power operator role do not see the button. - -Staff can also create the resource directly through the API. +why in a tooltip, for example that a customer holds the server. Confirming asks +for a reason and creates the operation. A badge shows progress and the result. +An **Operations** tab lists past operations with their time, action, requester, +result, and power before and after. Users without the power operator role do +not see the button. -### Who takes part +### Customer power -The request lives in the provider project. The work happens in the site that can -reach the server's BMC: +The [Fleet provider for Metal][provider] creates a `DevicePowerOperation` when +a Machine's `powerState` differs from the server's observed power: -![Staff create the operation; the site dispatcher checks it and starts one worker that holds one credential](diagrams/participants.svg) +| `powerState` | Action | +| --- | --- | +| `On` | `On` | +| `Off` | `ForceOff` | -- **The dispatcher** runs in the site, next to the BMC discovery process. It - accepts or refuses each request, starts a worker, and is the only writer of - the operation's status. It holds no BMC credential. -- **The worker** is a short-lived process started for one operation. It can read - only the target Device's BMC credential, and it cannot reach the provider - project. -- **BMC discovery** reads each BMC and records what it reports on the Device. - It is built but not yet on `main`. It stays read-only, and will also record - which power actions each server offers. +The provider keeps at most one power operation per Machine. When one finishes, +it compares the observed power with the latest `powerState` and creates another +only if they differ. A superseded intent therefore never reaches the server, as +the [machine lifecycle](../machine-lifecycle/README.md) requires. -Every connection to a BMC checks the BMC's approved TLS key before it sends a -credential, the same check discovery makes. +### Who takes part -### Risks and mitigations +![Staff and the Metal provider create power operations; the coordinator admits them and writes status; one site worker acts on the BMC](diagrams/participants.svg) -- **Resetting a customer's server:** [Acceptance checks](#acceptance-checks) - refuse any Device with capacity defined on it. -- **Resetting the wrong server:** The request names the server's UUID, and the - worker re-checks it against the BMC before it acts. -- **Repeating a reset:** Each operation sends at most one command, and nothing - retries it. See [execution and outcomes](#execution-and-outcomes). -- **Credential exposure:** Each worker reads one credential, and the dispatcher - reads none. See [authorization](#authorization). +BMC discovery is read-only. It reports which power actions each server offers +and the server's current power state. The coordinator uses both to check a +request, and recovery uses the power state as evidence. ## Design details ### API design -`DevicePowerOperation` belongs to `fleet.datumapis.com`. It lives in the -provider project, in the same namespace as its Device. Identifiers and -timestamps in the example are synthetic. +`DevicePowerOperation` uses the [operation envelope][operations]. This document +adds the power fields. Identifiers and timestamps are synthetic. ```yaml apiVersion: fleet.datumapis.com/v1alpha1 @@ -140,175 +121,123 @@ kind: DevicePowerOperation metadata: name: device-a-restart-1 namespace: default -# The whole spec is fixed at creation. A changed request is a new operation. spec: - # The Device to act on, in the same namespace. deviceRef: {name: device-a} - # One of On, ForceOff, ForceRestart or PowerCycle. + # Staff use a service request, and the reason is required. The Metal + # provider uses allocationRef instead. + authority: + serviceRequest: {reason: "Hung in firmware during qualification"} + # On, ForceOff, ForceRestart or PowerCycle. action: ForceRestart - # The server staff expect behind the BMC. The operation fails if the Device - # record or the BMC reports another. + # The server the requester expects behind the BMC. The Metal provider copies + # it from the Device record. expectedSystemUUID: 00000000-0000-4000-8000-0000000000a1 - # Admission requires this to equal the user who creates the operation. - requester: staff@example.com - # Required free text for the audit record. - reason: Hung in firmware during qualification - -# The site dispatcher alone writes status. It never carries a credential or -# any BMC response content. status: - conditions: - - {type: Accepted, status: "True", reason: Accepted} - - {type: Executing, status: "False", reason: Finished} - - {type: Finished, status: "True", reason: ResetObserved} - # Succeeded, Failed or Unknown. Set once and never changed. - result: Succeeded + admission: {fence: 43} + phase: Succeeded # When the one command was sent. Absent if none was sent. requestSentAt: "2026-01-02T03:04:06Z" - # The power state seen before and after the command. power: before: {state: "On", observedAt: "2026-01-02T03:04:05Z"} after: {state: "On", observedAt: "2026-01-02T03:04:41Z"} - finishedAt: "2026-01-02T03:04:42Z" ``` -A separate resource fits better than a field on the Device. A reset is an event, -not a state, and each operation needs its own audit record. See -[alternatives](#alternatives). - -### Status contract - -An operation moves through `Accepted` and `Executing` to `Finished`, or is -refused before it is accepted: +Status never carries a credential or BMC response content. -![An operation is refused or accepted, executes once, and finishes as Succeeded, Failed or Unknown](diagrams/operation-lifecycle.svg) +### Admission -- **`Failed`** means Fleet knows nothing was sent, or the BMC refused the - command and the power did not change. -- **`Unknown`** means a command may have been sent and Fleet cannot prove the - outcome. It ends the operation. Staff check the next discovery result and - create a new operation if they still need one. -- **`Succeeded`** means Fleet observed the requested state, or observed the - reset. +The coordinator admits a power operation through [custody admission][admission] +when the holder matches its authority: -Deleting an operation does not cancel a command already sent. - -### Acceptance checks +| Authority | Required holder | +| --- | --- | +| `serviceRequest` | `None`. Disabled capacity on the Device does not block it. Custody moves to `Service` while it runs. | +| `allocationRef` | `Allocation`, naming the same allocation. | -The dispatcher refuses an operation with `result: Failed`, and sends nothing, -when any of these holds: +Power adds these refusals. Each ends the operation as `Failed` with nothing +sent: | Reason | When | | --- | --- | -| `CapacityBacked` | Customer capacity is defined on the Device. | -| `OperationInProgress` | Another operation on the Device is still running. | -| `DeviceNotFound` | The Device does not exist in the namespace. | -| `DeviceRetired` | The Device is retired. | +| `AuthorityNotPermitted` | A creator other than the Fleet provider for Metal uses `allocationRef`. | | `SystemUUIDNotRecorded` | The Device has no system UUID on record. | -| `SystemUUIDMismatch` | The expected UUID differs from the Device record. | -| `DiscoveryNotCurrent` | Discovery has not recently read the BMC and matched its identity. | -| `SystemNotObserved` | Discovery did not see exactly one server with the expected UUID. | +| `SystemUUIDMismatch` | `expectedSystemUUID` differs from the Device record or from discovery. | +| `DiscoveryNotCurrent` | Discovery has not read the BMC within twice its interval. | | `SharedPublicKey` | The BMC shares its TLS key with another BMC, so the key cannot tell them apart. | -| `ResetTypeNotOffered` | The server does not offer the requested action. | -| `Expired` | The operation waited more than five minutes to be accepted. | +| `ResetTypeNotOffered` | Discovery does not report the action as offered. | +| `Expired` | A staff operation was not admitted within five minutes. | -A second request while one is running is refused, not queued. A queued request -could run minutes later, after its reason is gone. +A customer operation does not expire. It waits while another operation, such as +an installation, holds custody. ### Execution and outcomes -One operation runs from request to result like this: +![One power operation from request to result](diagrams/operation-sequence.svg) -![Sequence of one power operation from request to result](diagrams/operation-sequence.svg) +The [site worker][site] adds these rules for power: -Just before it starts the worker, the dispatcher checks again that no capacity -is defined on the Device. A worker that starts more than two minutes after that -check, for example because its image was slow to pull, refuses with reason -`Stale` and sends nothing. - -The worker re-checks the server's identity and offered actions, reads the power -state, and sends one command. If the server is already in the requested state, -the worker sends nothing and reports success. It refuses a restart or power -cycle of a server that is off, and any action while the power state is still -changing. +- It refuses with `Stale`, and sends nothing, if it starts more than two minutes + after admission. +- It re-checks that the action is offered, then reads the power state. +- If the server is already in the requested state, it sends nothing and reports + success. +- It refuses a restart or power cycle of a server that is off, and any action + while the power state is still changing. HTTP success from the BMC is not proof. The result depends on what the worker -observes afterwards: +observes after the command: | Action | `Succeeded` when | Otherwise | | --- | --- | --- | | `On`, `ForceOff` | The requested power state appears within three minutes. | `Unknown` | -| `ForceRestart`, `PowerCycle` | The BMC shows that a reset happened after the request, and the server is on again. | `Unknown` | +| `ForceRestart`, `PowerCycle` | The BMC shows a reset after the request, and the server is on again. | `Unknown` | -A BMC that refuses the command gives `Failed`, unless the power state has -changed anyway, which gives `Unknown`. A command whose response is lost is never -resent, and its result follows the table above. +A BMC that refuses the command gives `Failed`, unless the power state changed +anyway, which gives `Unknown`. A lost response is never resent. Its result +follows the table above. -The same rule covers failures inside Fleet. If a worker crashes, a site process -restarts, or a BMC stops answering after a command may have been sent, the -result is `Unknown`. A second worker started by mistake stops before it contacts -the BMC and leaves the first worker's result in place. +### Recovery -### Authorization +![A power operation ends Succeeded or Failed and releases custody, or ends Unknown and places a recovery hold](diagrams/operation-lifecycle.svg) -| Who | Can | -| --- | --- | -| Staff with the power operator role | Create and read operations, and read Devices. They cannot edit or delete operations or write their status. | -| The dispatcher | Read operations, Devices and capacity, write operation status, and start workers in its site. | -| A worker | Read one Device's BMC credential and record its own progress in the site. | -| BMC discovery | Unchanged: read BMCs and write Device status. | - -The dispatcher could, in principle, start a worker with any credential in its -site. Admission policies in the site limit every worker to the approved image, -one credential, and no extra privileges. A worker pointed at the wrong BMC fails -the TLS key check before it sends the credential. Fleet refuses Devices whose -BMCs share a TLS key, because the check cannot tell those BMCs apart. A worker -given the wrong credential fails the identity check before it sends a command. - -### Relationship to Machine power - -`Machine.spec.powerState` in the -[machine lifecycle enhancement](../machine-lifecycle/README.md) is the -customer's ongoing on or off intent for an allocated machine. A -`DevicePowerOperation` is a one-time staff action on an unallocated Device. The -two never act on the same server at once. A Device with capacity refuses power -operations, and a later phase makes the allocator refuse a Device with a running -operation. - -The Machine path will reuse the worker and its outcome rules, not the resource. -Its authority comes from the allocation, as the -[bare-metal hardware proposal](../../proposals/fleet-management/bare-metal-hardware.md) -requires for resets: "a bounded, idempotent operation with MachineAllocation -preconditions." +An `Unknown` power operation places a [recovery hold][unknown] on custody. The +hold settles only with both: + +- discovery evidence of the power state, observed after the operation ended; + and +- a staff recovery record that names the operation, that evidence and the + decision. + +A held allocated server keeps its customer. The Machine reports power as +`Unknown` until the hold settles. ### Delivery phases 1. **Discovery records offered actions.** No new effect. -2. **API and roles.** Operations can be created but stay unaccepted, so they - have no effect. -3. **Dispatcher and worker.** Tested against an emulated BMC. -4. **Staff UI and one real server** that backs no capacity. Restart and power - cycle stay disabled on real hardware until this test shows a restart can be +2. **Staff power.** The kind and the staff role, on the custody and site + execution from the device operations proposal. Tested against an emulated + BMC. +3. **Staff UI and one real server** with holder `None`. Restart and power cycle + stay disabled on real hardware until this test shows a restart can be proven. -5. **Allocator gate.** The allocator refuses capacity whose Device has a running - operation. This closes the window of up to two minutes between the - dispatcher's last capacity check and the command. New capacity is disabled - for allocation by default, so using that window would also take a second - operator action. +4. **Customer power.** The Metal provider creates operations from `powerState`. ### Acceptance tests -Tests against an emulated BMC must show, for each case, the result staff see -and how many commands reached the BMC: - -- a lost response after power on, power off, and restart; -- a replaced server behind the same BMC address; -- an action the server does not offer, and a wrong TLS key or credential; -- a second worker for one operation, and a worker lost after its command; -- two requests at once for one Device, and a Device with capacity defined. - -One staged test on a real server follows before restarts are enabled on real -hardware. These tests are required and have not been written. +These tests are required and not written: + +- A lost response after on, off and restart gives the result in the outcome + table, with one command at the BMC. +- A replaced server behind the same BMC address is refused before any command. +- An action the server does not offer, and a BMC with a shared TLS key, are + refused. +- A staff operation is admitted on a Device with disabled capacity and holder + `None`. +- A staff creator using `allocationRef` is refused. +- A worker that starts late refuses as `Stale`. +- Quick `powerState` changes send only the latest intent. +- An `Unknown` power operation settles only with fresh discovery evidence and a + recovery record. ## Production readiness review questionnaire @@ -316,78 +245,67 @@ These controls are proposed, not implemented. ### How do operators enable or disable the feature? -Per site, by deploying the dispatcher. Without a dispatcher, operations stay -unaccepted and have no effect. Removing it stops new work. A running worker -finishes, and its result waits in the site until a dispatcher publishes it. +Grant or revoke the staff power operator role. Customer power follows the Fleet +provider for Metal. Pausing admission is covered in the [device operations +proposal][ops]. ### What must operators monitor? -Operations that stay unaccepted, `Unknown` results, duplicate workers, and -dispatcher restarts. +Power recovery holds, most urgently on allocated servers, `Expired` and `Stale` +refusals, and restarts that end `Unknown` on each BMC model. ### How are failures recovered? -An `Unknown` operation needs a person. Check the next discovery result, then -create a new operation if one is still needed. Nothing retries automatically. +Wait for discovery to read the server's power state after the operation ended. +Then record the decision in a staff recovery record, which settles the hold. ## Implementation history -- 2026-11-24: Proposed. The design builds on BMC discovery, TLS key pinning - and per-operation workers from the installation work, which exist on an - integration branch and are not yet on `main`. +- 2026-11-24: Proposed as a standalone staff feature. +- 2026-11-24: Revised as the power kind of the device custody and operations + proposal, covering customer power. ## Drawbacks -- A site process and a worker per action add seconds of delay over a direct - BMC call. -- Restarts can end as `Unknown` on BMCs that do not report when a reset - happened. -- Staff cannot power-control a capacity-backed Device without first removing - its capacity. +- Restarts can end `Unknown` on BMCs that do not report when a reset happened. +- An `Unknown` customer power change keeps the customer's server held until + staff record recovery. +- A customer power change waits behind a running installation. ## Alternatives -- **A power field on the Device.** Rejected. A field would need a controller to - tell an old value from a new request, and re-applying a manifest would reset - the server again. It would also add a second writer to the Device. -- **A staff override for capacity-backed Devices.** Not proposed. Every power - action on such a server must be ordered with allocation, installation and - cleaning, and an override would skip that ordering. -- **Automatic retries.** Rejected. Repeating a restart is a second restart. A - new operation leaves a new audit record and passes the checks again. -- **Let discovery or the dispatcher send commands.** Rejected. A long-lived - process that could send commands to every BMC would be the most valuable - target in the site. +- **Separate kinds for staff and customer power.** Rejected. Both need the same + executor and outcome rules. `AuthorityNotPermitted` keeps allocation authority + with the Metal provider. - **Machine power intent for unallocated Devices.** Rejected. A Machine is a customer allocation, and creating one for staff would expose capacity. ## Open design questions -- **Override for capacity-backed Devices.** This proposal has none. Is a future - audited maintenance step on the capacity enough for incidents? -- **Lost response, then the right state.** The proposal reports `Succeeded` +- **Lost response, then the right state.** This proposal reports `Succeeded` when the requested power state appears after a lost response. The stricter option reports `Unknown`. -- **Restart evidence.** A restart can be proven only when the BMC reports that - a reset happened. Should restart and power cycle wait for the real-hardware - test, or ship earlier for test hardware only? -- **Graceful actions.** They are excluded because an unallocated server often - has no trusted operating system. Does anyone need them? -- **Retention.** How long are finished operations kept, and who may delete - them? -- **Unserved operations.** An operation for a Device that no site serves is - never accepted. Should something expire it? -- **Credential naming.** Workers find their credential by a name derived from - the Device, which changes how discovery credentials are named. The - alternatives are a dispatcher that can read credentials, or a credential - broker. Which should Fleet use? -- **Installation server list.** The installation work keeps its own list of - servers. Should it derive that list from Devices, so the capacity check - covers it? -- **Requester source.** Should the requester come from Milo's audit record - instead of a spec field checked at admission? +- **Restart evidence.** A restart can be proven only when the BMC reports that a + reset happened. Should restart and power cycle wait for the real-hardware + test, or ship earlier on test hardware only? +- **Customer power off.** `Off` maps to `ForceOff`, which cuts power without + warning the operating system. Should Metal offer a graceful power off? +- **Requester.** The operation envelope has no requester field. Where does the + staff UI's requester come from? +- **Pending limits.** The device operations proposal sets one pending limit per + kind. Power needs five minutes for staff and none for customers. Should the + envelope allow a limit per authority? +- **Shared TLS keys.** The refusal protects every kind that contacts a BMC. + Should the device operations proposal apply it to all kinds? ## Infrastructure needed An emulated BMC that supports TLS and reports when a reset happened, and one -real server that backs no capacity, with an approved TLS key and a credential. +real server with holder `None`, an approved TLS key and a credential. + +[ops]: ../device-operations/README.md +[operations]: ../device-operations/README.md#operations +[admission]: ../device-operations/README.md#admission +[site]: ../device-operations/README.md#site-execution +[unknown]: ../device-operations/README.md#unknown-outcomes +[provider]: ../device-operations/README.md#fleet-as-a-metal-provider diff --git a/docs/enhancements/device-power/diagrams/operation-lifecycle.svg b/docs/enhancements/device-power/diagrams/operation-lifecycle.svg index d2d284f2..e7bd5ede 100644 --- a/docs/enhancements/device-power/diagrams/operation-lifecycle.svg +++ b/docs/enhancements/device-power/diagrams/operation-lifecycle.svg @@ -1,21 +1,21 @@ - -Device power operation lifecycle and outcomesAn operation is created with its spec fixed and its requester checked. The dispatcher either refuses it at acceptance, which ends as Failed with nothing sent, or marks it Accepted. An accepted operation moves to Executing, where one worker sends at most one command. A worker that stops before its command also ends as Failed. It finishes with one of three results. Succeeded means the requested power state or a reset was observed. Failed means Fleet knows nothing was sent, or the BMC refused and power did not change. Unknown means a command may have been sent and the outcome is unproven. The result is set once and never changes. + +Device power operation outcomes and recoveryA power operation is Pending until the coordinator admits it through the Device's custody, or refuses it, which ends as Failed with nothing sent. An admitted operation moves to Executing, where one worker sends at most one command. Succeeded means the requested power state or a reset was observed, and Failed means nothing was sent or the BMC refused and power did not change. Both release the custody slot. Unknown means a command may have been sent and the outcome is unproven. It places a recovery hold on custody, which settles only with discovery evidence of the power state observed after the operation ended and a staff recovery record. The result is set once. - + -Created -Spec fixed; requester checked +Pending +Waits for custody admission -Accepted -Every dispatcher check passed +Admitted +Custody names it; fence raised Executing One worker; at most one command -Refused at acceptance +Refused Failed; nothing sent @@ -36,5 +36,12 @@ Unknown Maybe sent; outcome unproven -The result is set once. Staff create a new operation to try again. + +Custody slot released + + +Recovery hold +Settles with fresh discovery +power and a recovery record +The result is set once. A new attempt is a new operation. diff --git a/docs/enhancements/device-power/diagrams/operation-sequence.svg b/docs/enhancements/device-power/diagrams/operation-sequence.svg index 20fb3a35..3670c182 100644 --- a/docs/enhancements/device-power/diagrams/operation-sequence.svg +++ b/docs/enhancements/device-power/diagrams/operation-sequence.svg @@ -1,47 +1,46 @@ - -One Device power operation from request to resultStaff create an operation in the provider project. The dispatcher checks the Device, its discovery and its capacity, then marks the operation Accepted. It marks the operation Executing, checks capacity again, and starts one worker. The worker checks the BMC's TLS key, the server's identity and the offered actions, then sends one command. It watches the power state, and reports the result to the dispatcher, which writes it to the operation. Staff read Succeeded, Failed or Unknown. A lost response is never resent, and an outcome Fleet cannot prove ends as Unknown. + +One Device power operation from request to resultA requester, either staff or the Fleet provider for Metal, creates a power operation with an action and the expected system UUID. The Fleet coordinator checks the Device record: the offered actions, the system UUID, how recent discovery is, and whether the BMC's TLS key is shared. It then admits the operation through the Device's custody and delivers it to a site worker with the fence. The worker checks the BMC's key and the server's identity, reads the power state, sends one command, and reads the power state again. It returns a result with the fence. The coordinator writes the status and either releases custody or places a recovery hold. A worker that starts more than two minutes after admission refuses as Stale. - + -Staff - +Requester + -Provider -project - - -Dispatcher - +Fleet +coordinator + + +Device +Discovery facts + -Worker - - +Worker +Site + + BMC - -Create operation - -Checks pass: -mark Accepted - -Mark Executing - -Check capacity -again; start one - -Check TLS key, -identity, actions - -Send one command - -Power state - -Result - -Write result - -Read result - - -A lost response is never resent. An outcome Fleet cannot prove ends as Unknown. + +Create: action, +expected UUID + +Offered action, UUID, +discovery age, key + +Admit through custody; deliver with fence + +Check key and +identity; read power + +Send one command + +Power state + +Result with fence + +Status; custody +released or held + + +A late worker refuses as Stale. A lost response is never resent. diff --git a/docs/enhancements/device-power/diagrams/participants.svg b/docs/enhancements/device-power/diagrams/participants.svg index 0288936b..59c8c410 100644 --- a/docs/enhancements/device-power/diagrams/participants.svg +++ b/docs/enhancements/device-power/diagrams/participants.svg @@ -1,53 +1,55 @@ -Who takes part in a Device power operationStaff with the power operator role create a DevicePowerOperation in the provider project. The operation names a Device. MachineCapacity on a Device blocks power operations. In the site that can reach the BMC, the dispatcher reads the operation, the Device and capacity, and writes the operation's status. It starts one worker per operation. The worker holds one Device's BMC credential and sends at most one command to that BMC. BMC discovery reads BMCs, never changes them, and writes Device status. Only the worker and discovery read BMC credentials, and the worker has no access to the provider project. +Who takes part in a Device power operationStaff, from the Device page with a required reason, and the Fleet provider for Metal, from a Machine's powerState, both create a DevicePowerOperation in the provider project. The Fleet coordinator in management admits the operation with a conditional update to the Device's custody, reads the Device's discovery facts, and is the only writer of operation status. It delivers the admitted operation to the site with the custody fence. In the site, one worker holds one Device's BMC credential, sends at most one command to the BMC, and returns a result carrying the fence. BMC discovery reads BMCs, never changes them, and writes the offered power actions and power state to Device status. Sites hold no credentials for project APIs. - -Staff -Power operator role - -Provider project - -Device -Identity and discovery - -DevicePowerOperation -One action, fixed at creation - -MachineCapacity -Blocks power operations - -creates - -names - -Site - -Dispatcher -Checks, starts workers - -Worker -One operation, one credential - -BMC discovery -Read-only - -BMC -One per server - -reads, writes status - -reads - -reads - -writes status - -starts - -one command - -reads, never changes -Only the worker and discovery read BMC credentials. The worker cannot reach the provider project. + +Staff +Device page; reason required + +Fleet provider for Metal +From Machine powerState + +Provider project + +DeviceCustody +Holder None or Allocation + +DevicePowerOperation +One action, one command + +Device +Offered actions, power + + +create + +Fleet coordinator +Management; only status writer + +writes status + +admits + +reads + +Site + +Worker +One operation, one credential + +BMC +One per server + +BMC discovery +Writes Device status + +delivers, with fence + +result, with fence + +one command + +reads, never changes +Sites hold no credentials for project APIs. Only the coordinator writes operation status. From 4e08569c5cbe577fc5fc6abb0bd58fd9bf9e5e7e Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:04:14 -0600 Subject: [PATCH 11/26] docs: Cut Device power to what custody lacks Review found the power proposal still restated the custody proposal: custody moves, the lost-response rule, the recovery record and the whole admission and delivery flow in its diagrams. The custody proposal has since added creator and authority pairs, a creator set by a webhook, a five-minute staff expiry, cancellation of superseded power intents, the DeviceRecovery kind and the OutcomeUnknown phase. The power proposal now links to those and keeps only power rules. Its refusal table says whether the coordinator or the worker refuses, the Metal provider stops after a refusal until powerState changes, and the three diagrams show only what power adds: the requesters and discovery facts, the worker's checks and command, and how a power result is decided. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 161 +++++++----------- .../diagrams/operation-lifecycle.svg | 47 ----- .../diagrams/operation-sequence.svg | 46 ----- .../device-power/diagrams/participants.svg | 89 +++++----- .../device-power/diagrams/power-outcomes.svg | 36 ++++ .../device-power/diagrams/worker-sequence.svg | 36 ++++ 6 files changed, 176 insertions(+), 239 deletions(-) delete mode 100644 docs/enhancements/device-power/diagrams/operation-lifecycle.svg delete mode 100644 docs/enhancements/device-power/diagrams/operation-sequence.svg create mode 100644 docs/enhancements/device-power/diagrams/power-outcomes.svg create mode 100644 docs/enhancements/device-power/diagrams/worker-sequence.svg diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 106f2121..7a3c1942 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -38,8 +38,8 @@ uses it when a customer changes `Machine.spec.powerState`. This document specifies the power kind only. The [device custody and operations proposal][ops] defines custody, the operation envelope, admission, -site execution, recovery holds and authorization. Both documents are proposals, -and the device operations proposal is not yet merged. Nothing in either is +site execution, recovery and authorization. Both documents are proposals, and +the device operations proposal is not yet merged. Nothing in either is implemented. ## Motivation @@ -72,8 +72,8 @@ Customer power intent on a Machine has no executor yet. - Staff reset a server that hangs during qualification, then see who reset it, when, and the power state afterwards. - A customer sets a Machine's power to off, and the server powers off. -- A server's BMC is replaced and reports a different system. A request made - against the old record is refused before anything reaches the server. +- A server's BMC is replaced and reports a different system. A staff request + made against the old record is refused before anything reaches the server. ### Requesting staff power @@ -81,32 +81,31 @@ Staff use a power button on the Device page, next to the observed power state. Its menu lists only the actions the server offers. An unavailable action shows why in a tooltip, for example that a customer holds the server. Confirming asks for a reason and creates the operation. A badge shows progress and the result. -An **Operations** tab lists past operations with their time, action, requester, +An **Operations** tab lists past operations with their time, action, creator, result, and power before and after. Users without the power operator role do not see the button. ### Customer power -The [Fleet provider for Metal][provider] creates a `DevicePowerOperation` when -a Machine's `powerState` differs from the server's observed power: +The Fleet provider for Metal maps a Machine's `powerState` to an action: | `powerState` | Action | | --- | --- | | `On` | `On` | | `Off` | `ForceOff` | -The provider keeps at most one power operation per Machine. When one finishes, -it compares the observed power with the latest `powerState` and creates another -only if they differ. A superseded intent therefore never reaches the server, as -the [machine lifecycle](../machine-lifecycle/README.md) requires. +The provider creates an operation only when `powerState` differs from the +server's observed power. Its name comes from the Machine generation, so a +refused operation is not retried until `powerState` changes again. The provider +reports the refusal reason on the Machine. ### Who takes part -![Staff and the Metal provider create power operations; the coordinator admits them and writes status; one site worker acts on the BMC](diagrams/participants.svg) +![Staff and the Metal provider create power operations; discovery facts gate them; one worker sends the command](diagrams/participants.svg) BMC discovery is read-only. It reports which power actions each server offers -and the server's current power state. The coordinator uses both to check a -request, and recovery uses the power state as evidence. +and the server's current power state. Admission uses both, and recovery uses +the power state as evidence. ## Design details @@ -121,20 +120,18 @@ kind: DevicePowerOperation metadata: name: device-a-restart-1 namespace: default +# Envelope fields other than the device and authority are omitted. spec: - deviceRef: {name: device-a} + deviceRef: {name: device-a, uid: 4b8e2f10-0000-4000-8000-0000000000a1} # Staff use a service request, and the reason is required. The Metal # provider uses allocationRef instead. authority: serviceRequest: {reason: "Hung in firmware during qualification"} # On, ForceOff, ForceRestart or PowerCycle. action: ForceRestart - # The server the requester expects behind the BMC. The Metal provider copies - # it from the Device record. + # Staff only: the server staff expect behind the BMC. expectedSystemUUID: 00000000-0000-4000-8000-0000000000a1 status: - admission: {fence: 43} - phase: Succeeded # When the one command was sent. Absent if none was sent. requestSentAt: "2026-01-02T03:04:06Z" power: @@ -142,74 +139,57 @@ status: after: {state: "On", observedAt: "2026-01-02T03:04:41Z"} ``` -Status never carries a credential or BMC response content. +The coordinator writes the power status fields from the site's result. Status +never carries a credential or BMC response content. ### Admission -The coordinator admits a power operation through [custody admission][admission] -when the holder matches its authority: - -| Authority | Required holder | -| --- | --- | -| `serviceRequest` | `None`. Disabled capacity on the Device does not block it. Custody moves to `Service` while it runs. | -| `allocationRef` | `Allocation`, naming the same allocation. | +[Custody admission][admission] decides which creator, authority and holder may +run a power operation. A staff operation needs holder `None`, so disabled +capacity on the Device does not block it. A customer operation runs under the +Machine's allocation. Power adds these refusals. Each ends the operation as `Failed` with nothing sent: -| Reason | When | -| --- | --- | -| `AuthorityNotPermitted` | A creator other than the Fleet provider for Metal uses `allocationRef`. | -| `SystemUUIDNotRecorded` | The Device has no system UUID on record. | -| `SystemUUIDMismatch` | `expectedSystemUUID` differs from the Device record or from discovery. | -| `DiscoveryNotCurrent` | Discovery has not read the BMC within twice its interval. | -| `SharedPublicKey` | The BMC shares its TLS key with another BMC, so the key cannot tell them apart. | -| `ResetTypeNotOffered` | Discovery does not report the action as offered. | -| `Expired` | A staff operation was not admitted within five minutes. | - -A customer operation does not expire. It waits while another operation, such as -an installation, holds custody. +| Reason | Refused by | When | +| --- | --- | --- | +| `SystemUUIDNotRecorded` | Coordinator | A staff operation targets a Device with no system UUID on record. | +| `SystemUUIDMismatch` | Coordinator or worker | `expectedSystemUUID` differs from the Device record, discovery or the BMC. | +| `DiscoveryNotCurrent` | Coordinator | Discovery has not read the BMC within twice its interval. | +| `SharedPublicKey` | Coordinator | The BMC shares its TLS key with another BMC, so the key cannot tell them apart. | +| `ResetTypeNotOffered` | Coordinator or worker | Discovery or the BMC does not offer the action. | +| `Expired` | Coordinator | A staff operation stayed pending for five minutes. | +| `Stale` | Worker | The worker started more than two minutes after admission. | +| `NotPoweredOn` | Worker | A restart or power cycle targets a server that is off. | +| `PowerStateNotSettled` | Worker | The power state is still changing. | ### Execution and outcomes -![One power operation from request to result](diagrams/operation-sequence.svg) +![What a site worker does for one power operation](diagrams/worker-sequence.svg) -The [site worker][site] adds these rules for power: - -- It refuses with `Stale`, and sends nothing, if it starts more than two minutes - after admission. -- It re-checks that the action is offered, then reads the power state. -- If the server is already in the requested state, it sends nothing and reports - success. -- It refuses a restart or power cycle of a server that is off, and any action - while the power state is still changing. +The [site worker][site] re-checks that the action is offered, then reads the +power state. If the server is already in the requested state, it sends nothing +and reports success. Otherwise it sends one command. HTTP success from the BMC is not proof. The result depends on what the worker -observes after the command: +observes after the command, including after a lost response: | Action | `Succeeded` when | Otherwise | | --- | --- | --- | -| `On`, `ForceOff` | The requested power state appears within three minutes. | `Unknown` | -| `ForceRestart`, `PowerCycle` | The BMC shows a reset after the request, and the server is on again. | `Unknown` | +| `On`, `ForceOff` | The requested power state appears within three minutes. | `OutcomeUnknown` | +| `ForceRestart`, `PowerCycle` | The BMC shows a reset after the request, and the server is on again. | `OutcomeUnknown` | A BMC that refuses the command gives `Failed`, unless the power state changed -anyway, which gives `Unknown`. A lost response is never resent. Its result -follows the table above. +anyway, which gives `OutcomeUnknown`. ### Recovery -![A power operation ends Succeeded or Failed and releases custody, or ends Unknown and places a recovery hold](diagrams/operation-lifecycle.svg) - -An `Unknown` power operation places a [recovery hold][unknown] on custody. The -hold settles only with both: +![How a power result is decided, and how a power recovery hold settles](diagrams/power-outcomes.svg) -- discovery evidence of the power state, observed after the operation ended; - and -- a staff recovery record that names the operation, that evidence and the - decision. - -A held allocated server keeps its customer. The Machine reports power as -`Unknown` until the hold settles. +A power [recovery hold][unknown] settles with a `DeviceRecovery` whose evidence +is a power state that discovery read after the operation ended. The Machine of +a held allocated server reports power as `Unknown` until then. ### Delivery phases @@ -224,20 +204,17 @@ A held allocated server keeps its customer. The Machine reports power as ### Acceptance tests -These tests are required and not written: - -- A lost response after on, off and restart gives the result in the outcome - table, with one command at the BMC. -- A replaced server behind the same BMC address is refused before any command. -- An action the server does not offer, and a BMC with a shared TLS key, are - refused. -- A staff operation is admitted on a Device with disabled capacity and holder - `None`. -- A staff creator using `allocationRef` is refused. -- A worker that starts late refuses as `Stale`. -- Quick `powerState` changes send only the latest intent. -- An `Unknown` power operation settles only with fresh discovery evidence and a - recovery record. +These tests are required and not written. Each checks the result and the +number of commands at the BMC: + +- Each refusal reason in the [admission](#admission) table, with no command. +- On, off, restart and power cycle against the outcome table, including a lost + response. +- A server already in the requested state, with no command. +- A staff operation on a Device with disabled capacity and holder `None`. +- A refused customer operation is not retried until `powerState` changes. +- A power hold settles only with discovery evidence read after the operation + ended. ## Production readiness review questionnaire @@ -252,12 +229,11 @@ proposal][ops]. ### What must operators monitor? Power recovery holds, most urgently on allocated servers, `Expired` and `Stale` -refusals, and restarts that end `Unknown` on each BMC model. +refusals, and restarts that end `OutcomeUnknown` on each BMC model. ### How are failures recovered? -Wait for discovery to read the server's power state after the operation ended. -Then record the decision in a staff recovery record, which settles the hold. +See [Recovery](#recovery). ## Implementation history @@ -267,34 +243,28 @@ Then record the decision in a staff recovery record, which settles the hold. ## Drawbacks -- Restarts can end `Unknown` on BMCs that do not report when a reset happened. -- An `Unknown` customer power change keeps the customer's server held until - staff record recovery. -- A customer power change waits behind a running installation. +- Restarts can end `OutcomeUnknown` on BMCs that do not report when a reset + happened. +- An unproven customer power change keeps the customer's server held until + staff record a recovery. ## Alternatives - **Separate kinds for staff and customer power.** Rejected. Both need the same - executor and outcome rules. `AuthorityNotPermitted` keeps allocation authority - with the Metal provider. + executor and outcome rules. - **Machine power intent for unallocated Devices.** Rejected. A Machine is a customer allocation, and creating one for staff would expose capacity. ## Open design questions - **Lost response, then the right state.** This proposal reports `Succeeded` - when the requested power state appears after a lost response. The stricter - option reports `Unknown`. + when the worker sees the requested state after a lost response. Should power + report `OutcomeUnknown` instead? - **Restart evidence.** A restart can be proven only when the BMC reports that a reset happened. Should restart and power cycle wait for the real-hardware test, or ship earlier on test hardware only? - **Customer power off.** `Off` maps to `ForceOff`, which cuts power without warning the operating system. Should Metal offer a graceful power off? -- **Requester.** The operation envelope has no requester field. Where does the - staff UI's requester come from? -- **Pending limits.** The device operations proposal sets one pending limit per - kind. Power needs five minutes for staff and none for customers. Should the - envelope allow a limit per authority? - **Shared TLS keys.** The refusal protects every kind that contacts a BMC. Should the device operations proposal apply it to all kinds? @@ -308,4 +278,3 @@ real server with holder `None`, an approved TLS key and a credential. [admission]: ../device-operations/README.md#admission [site]: ../device-operations/README.md#site-execution [unknown]: ../device-operations/README.md#unknown-outcomes -[provider]: ../device-operations/README.md#fleet-as-a-metal-provider diff --git a/docs/enhancements/device-power/diagrams/operation-lifecycle.svg b/docs/enhancements/device-power/diagrams/operation-lifecycle.svg deleted file mode 100644 index e7bd5ede..00000000 --- a/docs/enhancements/device-power/diagrams/operation-lifecycle.svg +++ /dev/null @@ -1,47 +0,0 @@ - -Device power operation outcomes and recoveryA power operation is Pending until the coordinator admits it through the Device's custody, or refuses it, which ends as Failed with nothing sent. An admitted operation moves to Executing, where one worker sends at most one command. Succeeded means the requested power state or a reset was observed, and Failed means nothing was sent or the BMC refused and power did not change. Both release the custody slot. Unknown means a command may have been sent and the outcome is unproven. It places a recovery hold on custody, which settles only with discovery evidence of the power state observed after the operation ended and a staff recovery record. The result is set once. - - - - -Pending -Waits for custody admission - - -Admitted -Custody names it; fence raised - - -Executing -One worker; at most one command - -Refused -Failed; nothing sent - - - -Finished - - - - -Succeeded -Requested state or -reset observed - -Failed -Nothing sent, or the -BMC refused it - -Unknown -Maybe sent; -outcome unproven - -Custody slot released - - -Recovery hold -Settles with fresh discovery -power and a recovery record -The result is set once. A new attempt is a new operation. - diff --git a/docs/enhancements/device-power/diagrams/operation-sequence.svg b/docs/enhancements/device-power/diagrams/operation-sequence.svg deleted file mode 100644 index 3670c182..00000000 --- a/docs/enhancements/device-power/diagrams/operation-sequence.svg +++ /dev/null @@ -1,46 +0,0 @@ - -One Device power operation from request to resultA requester, either staff or the Fleet provider for Metal, creates a power operation with an action and the expected system UUID. The Fleet coordinator checks the Device record: the offered actions, the system UUID, how recent discovery is, and whether the BMC's TLS key is shared. It then admits the operation through the Device's custody and delivers it to a site worker with the fence. The worker checks the BMC's key and the server's identity, reads the power state, sends one command, and reads the power state again. It returns a result with the fence. The coordinator writes the status and either releases custody or places a recovery hold. A worker that starts more than two minutes after admission refuses as Stale. - - - - -Requester - - -Fleet -coordinator - - -Device -Discovery facts - - -Worker -Site - - -BMC - -Create: action, -expected UUID - -Offered action, UUID, -discovery age, key - -Admit through custody; deliver with fence - -Check key and -identity; read power - -Send one command - -Power state - -Result with fence - -Status; custody -released or held - - -A late worker refuses as Stale. A lost response is never resent. - diff --git a/docs/enhancements/device-power/diagrams/participants.svg b/docs/enhancements/device-power/diagrams/participants.svg index 59c8c410..2b8f6ea4 100644 --- a/docs/enhancements/device-power/diagrams/participants.svg +++ b/docs/enhancements/device-power/diagrams/participants.svg @@ -1,55 +1,44 @@ - -Who takes part in a Device power operationStaff, from the Device page with a required reason, and the Fleet provider for Metal, from a Machine's powerState, both create a DevicePowerOperation in the provider project. The Fleet coordinator in management admits the operation with a conditional update to the Device's custody, reads the Device's discovery facts, and is the only writer of operation status. It delivers the admitted operation to the site with the custody fence. In the site, one worker holds one Device's BMC credential, sends at most one command to the BMC, and returns a result carrying the fence. BMC discovery reads BMCs, never changes them, and writes the offered power actions and power state to Device status. Sites hold no credentials for project APIs. + +What power adds to device operationsStaff, from the Device page with a required reason, and the Fleet provider for Metal, from a Machine's powerState, both create a DevicePowerOperation that names an action and the expected system UUID. Custody admission and site execution, defined in the device operations proposal, admit and deliver it. The Device's discovery facts, the offered power actions and the power state, gate admission. BMC discovery reads the BMC without changing it and reports those facts on the Device. The site worker checks the power state and sends at most one command to the BMC. A later discovery reading of the power state is the evidence that settles a power recovery hold. - - + + Staff Device page; reason required - -Fleet provider for Metal -From Machine powerState - -Provider project - -DeviceCustody -Holder None or Allocation - -DevicePowerOperation -One action, one command - -Device -Offered actions, power - - -create - -Fleet coordinator -Management; only status writer - -writes status - -admits - -reads - -Site - -Worker -One operation, one credential - -BMC -One per server - -BMC discovery -Writes Device status - -delivers, with fence - -result, with fence - -one command - -reads, never changes -Sites hold no credentials for project APIs. Only the coordinator writes operation status. + +Fleet provider for Metal +From Machine powerState + +DevicePowerOperation +Action, expected UUID + + + +Custody admission and site execution +Device operations proposal + + +BMC discovery +Read-only + +Device +Offered actions, power + +reports + +gates + +Worker +Checks power first + +delivers + +BMC +One per server + +one command + +reads +A later discovery reading of the power state settles a power recovery hold. diff --git a/docs/enhancements/device-power/diagrams/power-outcomes.svg b/docs/enhancements/device-power/diagrams/power-outcomes.svg new file mode 100644 index 00000000..c255466b --- /dev/null +++ b/docs/enhancements/device-power/diagrams/power-outcomes.svg @@ -0,0 +1,36 @@ + +How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state, or for a restart or power cycle a reset, was observed within three minutes. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within the deadline, or the power changed after a refusal. It places a recovery hold, which a DeviceRecovery settles using a discovery reading of the power state taken after the operation ended. + + + + +After admission +The worker checks, then sends at most one command + + + + + + +Succeeded +Requested state, or a +reset, seen within +three minutes + +Failed +Nothing sent, or the +BMC refused and power +did not change + +OutcomeUnknown +No evidence in time, +or power changed +after a refusal + + +Power recovery hold +Settled by a DeviceRecovery +citing a later discovery read +The result is set once. +A new attempt is a new operation. + diff --git a/docs/enhancements/device-power/diagrams/worker-sequence.svg b/docs/enhancements/device-power/diagrams/worker-sequence.svg new file mode 100644 index 00000000..3573a369 --- /dev/null +++ b/docs/enhancements/device-power/diagrams/worker-sequence.svg @@ -0,0 +1,36 @@ + +What a site worker does for one power operationThe worker receives an admitted power operation with its admission time. It reads the offered power actions and the current power state from the BMC. Unless the server is already in the requested state, it sends one command. It then reads the power state until the requested state or reset evidence appears, or three minutes pass. It returns a result with the power state before and after. Before sending, the worker refuses with no command if it started more than two minutes after admission, if a restart or power cycle targets a server that is off, or if the power state is still changing. + + + + +Fleet coordinator +Custody admission + + +Worker +Site + + +BMC + +Admitted operation, +with admission time + +Read offered actions +and power state + +Power state + +One command, unless +already in that state + +Power state and reset +time, for up to 3 minutes + +Result, power before +and after + + +No command if late, if a restart targets an off server, or if power is changing. + From 0fa3097ea6f6d88dc760f6445011fd848e1888ca Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:05:34 -0600 Subject: [PATCH 12/26] docs: Align Device power details with custody The custody proposal names power operations from the Machine generation and lists the expected system UUID as a staff input only, so the power proposal now says the same in its prose, tests and participants diagram. The custody proposal also makes operation status a copy of custody, which leaves no room for the power before and after fields. The power proposal now records them with the site's result and asks whether custody's last result should carry kind-specific detail. The README entry gets its own paragraph. Co-Authored-By: Claude Opus 5.5 --- README.md | 1 + docs/enhancements/device-power/README.md | 14 +++++++++----- .../device-power/diagrams/participants.svg | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b0e96972..c254f180 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ today. Then choose a topic: The [Bare Metal CLI enhancement](docs/enhancements/metal-cli/README.md) proposes `datumctl metal` discovery, machine management, and safe recovery workflows. + The [Device power enhancement](docs/enhancements/device-power/README.md) proposes the power operation that staff and Metal customers use to change a server's power. diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 7a3c1942..c8b03b90 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -96,8 +96,8 @@ The Fleet provider for Metal maps a Machine's `powerState` to an action: The provider creates an operation only when `powerState` differs from the server's observed power. Its name comes from the Machine generation, so a -refused operation is not retried until `powerState` changes again. The provider -reports the refusal reason on the Machine. +refused operation is not retried until the Machine generation changes. The +provider reports the refusal reason on the Machine. ### Who takes part @@ -139,8 +139,8 @@ status: after: {state: "On", observedAt: "2026-01-02T03:04:41Z"} ``` -The coordinator writes the power status fields from the site's result. Status -never carries a credential or BMC response content. +The coordinator records the power fields with the site's result. They never +carry a credential or BMC response content. ### Admission @@ -212,7 +212,8 @@ number of commands at the BMC: response. - A server already in the requested state, with no command. - A staff operation on a Device with disabled capacity and holder `None`. -- A refused customer operation is not retried until `powerState` changes. +- A refused customer operation is not retried until the Machine generation + changes. - A power hold settles only with discovery evidence read after the operation ended. @@ -267,6 +268,9 @@ See [Recovery](#recovery). warning the operating system. Should Metal offer a graceful power off? - **Shared TLS keys.** The refusal protects every kind that contacts a BMC. Should the device operations proposal apply it to all kinds? +- **Result detail.** The device operations proposal makes operation status a + copy of custody, which has no room for the power fields. Should custody's + last result carry kind-specific detail? ## Infrastructure needed diff --git a/docs/enhancements/device-power/diagrams/participants.svg b/docs/enhancements/device-power/diagrams/participants.svg index 2b8f6ea4..28645e35 100644 --- a/docs/enhancements/device-power/diagrams/participants.svg +++ b/docs/enhancements/device-power/diagrams/participants.svg @@ -1,5 +1,5 @@ -What power adds to device operationsStaff, from the Device page with a required reason, and the Fleet provider for Metal, from a Machine's powerState, both create a DevicePowerOperation that names an action and the expected system UUID. Custody admission and site execution, defined in the device operations proposal, admit and deliver it. The Device's discovery facts, the offered power actions and the power state, gate admission. BMC discovery reads the BMC without changing it and reports those facts on the Device. The site worker checks the power state and sends at most one command to the BMC. A later discovery reading of the power state is the evidence that settles a power recovery hold. +What power adds to device operationsStaff, from the Device page with a required reason, and the Fleet provider for Metal, from a Machine's powerState, both create a DevicePowerOperation that names an action. Staff operations also name the expected system UUID. Custody admission and site execution, defined in the device operations proposal, admit and deliver it. The Device's discovery facts, the offered power actions and the power state, gate admission. BMC discovery reads the BMC without changing it and reports those facts on the Device. The site worker checks the power state and sends at most one command to the BMC. A later discovery reading of the power state is the evidence that settles a power recovery hold. @@ -11,7 +11,7 @@ From Machine powerState DevicePowerOperation -Action, expected UUID +Action; staff add a UUID From 4007b50f2bcccf7bd89a0a7f3a19c295f57e363a Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:09:09 -0600 Subject: [PATCH 13/26] docs: Match Device power to settled custody The custody proposal now has each kind define the evidence its result carries, refuses shared BMC keys in the site worker for every kind, and ends an expired operation as Cancelled. The power proposal now defines its result evidence: when the command was sent, the power before and after, and the reset evidence a restart needs. It refers to site execution for the shared-key check, reports Expired as Cancelled, and drops the two open questions the custody proposal answered. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 30 ++++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index c8b03b90..2a63aa23 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -132,15 +132,24 @@ spec: # Staff only: the server staff expect behind the BMC. expectedSystemUUID: 00000000-0000-4000-8000-0000000000a1 status: - # When the one command was sent. Absent if none was sent. + # Power result evidence, copied from the site's result. requestSentAt: "2026-01-02T03:04:06Z" power: before: {state: "On", observedAt: "2026-01-02T03:04:05Z"} after: {state: "On", observedAt: "2026-01-02T03:04:41Z"} + resetEvidence: LastResetTime ``` -The coordinator records the power fields with the site's result. They never -carry a credential or BMC response content. +A power result carries this evidence, which the coordinator copies to status as +[site execution][site] describes: + +| Field | Meaning | +| --- | --- | +| `requestSentAt` | When the one command was sent. Absent if none was sent. | +| `power.before`, `power.after` | The power state the worker read before the command and at the end. | +| `resetEvidence` | For a restart or power cycle: `LastResetTime` if the BMC reported a reset after the request, or `ObservedOff` if the worker saw the server off. | + +The evidence never carries a credential or BMC response content. ### Admission @@ -149,17 +158,17 @@ run a power operation. A staff operation needs holder `None`, so disabled capacity on the Device does not block it. A customer operation runs under the Machine's allocation. -Power adds these refusals. Each ends the operation as `Failed` with nothing -sent: +Power adds these refusals. Each ends the operation with nothing sent: +`Expired` as `Cancelled`, and the others as `Failed`. | Reason | Refused by | When | | --- | --- | --- | | `SystemUUIDNotRecorded` | Coordinator | A staff operation targets a Device with no system UUID on record. | | `SystemUUIDMismatch` | Coordinator or worker | `expectedSystemUUID` differs from the Device record, discovery or the BMC. | | `DiscoveryNotCurrent` | Coordinator | Discovery has not read the BMC within twice its interval. | -| `SharedPublicKey` | Coordinator | The BMC shares its TLS key with another BMC, so the key cannot tell them apart. | +| `SharedPublicKey` | Worker | The [site execution][site] shared-key check fails. | | `ResetTypeNotOffered` | Coordinator or worker | Discovery or the BMC does not offer the action. | -| `Expired` | Coordinator | A staff operation stayed pending for five minutes. | +| `Expired` | Coordinator | A staff operation was not admitted within five minutes. | | `Stale` | Worker | The worker started more than two minutes after admission. | | `NotPoweredOn` | Worker | A restart or power cycle targets a server that is off. | | `PowerStateNotSettled` | Worker | The power state is still changing. | @@ -178,7 +187,7 @@ observes after the command, including after a lost response: | Action | `Succeeded` when | Otherwise | | --- | --- | --- | | `On`, `ForceOff` | The requested power state appears within three minutes. | `OutcomeUnknown` | -| `ForceRestart`, `PowerCycle` | The BMC shows a reset after the request, and the server is on again. | `OutcomeUnknown` | +| `ForceRestart`, `PowerCycle` | `resetEvidence` is set within three minutes, and the server is on again. | `OutcomeUnknown` | A BMC that refuses the command gives `Failed`, unless the power state changed anyway, which gives `OutcomeUnknown`. @@ -266,11 +275,6 @@ See [Recovery](#recovery). test, or ship earlier on test hardware only? - **Customer power off.** `Off` maps to `ForceOff`, which cuts power without warning the operating system. Should Metal offer a graceful power off? -- **Shared TLS keys.** The refusal protects every kind that contacts a BMC. - Should the device operations proposal apply it to all kinds? -- **Result detail.** The device operations proposal makes operation status a - copy of custody, which has no room for the power fields. Should custody's - last result carry kind-specific detail? ## Infrastructure needed From 832d44de4bc00dd1d92ddd3d99cccf3c7d956ab9 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:09:39 -0600 Subject: [PATCH 14/26] docs: Follow custody on evidence and shared keys The custody proposal now records each kind's result evidence in custody with the result, and refuses a Device whose BMC key digest another Device records at admission instead of in the site worker. The power proposal now says its evidence is recorded in custody with the result, and its SharedPublicKey reason points to the custody admission rule, refused by the coordinator. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 2a63aa23..84e728bf 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -132,7 +132,7 @@ spec: # Staff only: the server staff expect behind the BMC. expectedSystemUUID: 00000000-0000-4000-8000-0000000000a1 status: - # Power result evidence, copied from the site's result. + # Power result evidence, recorded in custody with the result. requestSentAt: "2026-01-02T03:04:06Z" power: before: {state: "On", observedAt: "2026-01-02T03:04:05Z"} @@ -140,8 +140,8 @@ status: resetEvidence: LastResetTime ``` -A power result carries this evidence, which the coordinator copies to status as -[site execution][site] describes: +A power result carries this evidence. The coordinator records it in custody +with the result, as [site execution][site] describes: | Field | Meaning | | --- | --- | @@ -166,7 +166,7 @@ Power adds these refusals. Each ends the operation with nothing sent: | `SystemUUIDNotRecorded` | Coordinator | A staff operation targets a Device with no system UUID on record. | | `SystemUUIDMismatch` | Coordinator or worker | `expectedSystemUUID` differs from the Device record, discovery or the BMC. | | `DiscoveryNotCurrent` | Coordinator | Discovery has not read the BMC within twice its interval. | -| `SharedPublicKey` | Worker | The [site execution][site] shared-key check fails. | +| `SharedPublicKey` | Coordinator | The shared-key rule of [custody admission][admission] fails. | | `ResetTypeNotOffered` | Coordinator or worker | Discovery or the BMC does not offer the action. | | `Expired` | Coordinator | A staff operation was not admitted within five minutes. | | `Stale` | Worker | The worker started more than two minutes after admission. | From 0a278c116a7af2bb28385a8a50273b5d478ca79b Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:11:40 -0600 Subject: [PATCH 15/26] docs: Remove Device power rules custody owns Review found the power proposal still restated custody admission: the creator and authority rule, the shared-key and five-minute expiry rows, and the authority comment in the example. Those now point to the custody proposal, keeping only the power reason names. The example uses a generated staff name, as custody requires. Review also found four inaccuracies. The no-op for a server already in the requested state now applies only to On and ForceOff. A settled power state is defined. The participants caption said discovery settles a hold, when a DeviceRecovery does. The held Machine's Unknown power is now stated as this proposal's requirement, with a test. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 45 +++++++++---------- .../device-power/diagrams/participants.svg | 6 +-- .../device-power/diagrams/power-outcomes.svg | 11 +++-- 3 files changed, 29 insertions(+), 33 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 84e728bf..4da0b7a8 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -38,9 +38,8 @@ uses it when a customer changes `Machine.spec.powerState`. This document specifies the power kind only. The [device custody and operations proposal][ops] defines custody, the operation envelope, admission, -site execution, recovery and authorization. Both documents are proposals, and -the device operations proposal is not yet merged. Nothing in either is -implemented. +site execution, recovery and authorization. Both documents are proposals. +Nothing in either is implemented. ## Motivation @@ -103,9 +102,9 @@ provider reports the refusal reason on the Machine. ![Staff and the Metal provider create power operations; discovery facts gate them; one worker sends the command](diagrams/participants.svg) -BMC discovery is read-only. It reports which power actions each server offers -and the server's current power state. Admission uses both, and recovery uses -the power state as evidence. +BMC discovery reads each BMC without sending it commands. It reports on the +Device which power actions the server offers and its current power state. +Admission uses both, and recovery uses the power state as evidence. ## Design details @@ -118,13 +117,11 @@ adds the power fields. Identifiers and timestamps are synthetic. apiVersion: fleet.datumapis.com/v1alpha1 kind: DevicePowerOperation metadata: - name: device-a-restart-1 + name: device-a-power-7k2pq namespace: default # Envelope fields other than the device and authority are omitted. spec: deviceRef: {name: device-a, uid: 4b8e2f10-0000-4000-8000-0000000000a1} - # Staff use a service request, and the reason is required. The Metal - # provider uses allocationRef instead. authority: serviceRequest: {reason: "Hung in firmware during qualification"} # On, ForceOff, ForceRestart or PowerCycle. @@ -153,33 +150,31 @@ The evidence never carries a credential or BMC response content. ### Admission -[Custody admission][admission] decides which creator, authority and holder may -run a power operation. A staff operation needs holder `None`, so disabled -capacity on the Device does not block it. A customer operation runs under the -Machine's allocation. +Disabled capacity on a Device does not block staff power, because it leaves +the holder `None`. Power reports two [custody admission][admission] refusals +under its own names: a shared BMC key as `SharedPublicKey`, and an expired +staff operation as `Expired`. -Power adds these refusals. Each ends the operation with nothing sent: -`Expired` as `Cancelled`, and the others as `Failed`. +Power adds these refusals. Each ends the operation as `Failed` with nothing +sent: | Reason | Refused by | When | | --- | --- | --- | | `SystemUUIDNotRecorded` | Coordinator | A staff operation targets a Device with no system UUID on record. | | `SystemUUIDMismatch` | Coordinator or worker | `expectedSystemUUID` differs from the Device record, discovery or the BMC. | | `DiscoveryNotCurrent` | Coordinator | Discovery has not read the BMC within twice its interval. | -| `SharedPublicKey` | Coordinator | The shared-key rule of [custody admission][admission] fails. | | `ResetTypeNotOffered` | Coordinator or worker | Discovery or the BMC does not offer the action. | -| `Expired` | Coordinator | A staff operation was not admitted within five minutes. | | `Stale` | Worker | The worker started more than two minutes after admission. | | `NotPoweredOn` | Worker | A restart or power cycle targets a server that is off. | -| `PowerStateNotSettled` | Worker | The power state is still changing. | +| `PowerStateNotSettled` | Worker | The BMC reports a transition state, such as `PoweringOn` or `PoweringOff`. | ### Execution and outcomes ![What a site worker does for one power operation](diagrams/worker-sequence.svg) The [site worker][site] re-checks that the action is offered, then reads the -power state. If the server is already in the requested state, it sends nothing -and reports success. Otherwise it sends one command. +power state. For `On` and `ForceOff`, if the server is already in the requested +state, it sends nothing and reports success. Otherwise it sends one command. HTTP success from the BMC is not proof. The result depends on what the worker observes after the command, including after a lost response: @@ -197,8 +192,9 @@ anyway, which gives `OutcomeUnknown`. ![How a power result is decided, and how a power recovery hold settles](diagrams/power-outcomes.svg) A power [recovery hold][unknown] settles with a `DeviceRecovery` whose evidence -is a power state that discovery read after the operation ended. The Machine of -a held allocated server reports power as `Unknown` until then. +is a power state that discovery read after the operation ended. This proposal +also requires the Metal projector to report a held Machine's power as +`Unknown` until the hold settles. ### Delivery phases @@ -224,11 +220,12 @@ number of commands at the BMC: - A refused customer operation is not retried until the Machine generation changes. - A power hold settles only with discovery evidence read after the operation - ended. + ended, and the held Machine reports power as `Unknown` until then. ## Production readiness review questionnaire -These controls are proposed, not implemented. +These controls are proposed, not implemented. This section covers only what +power adds to the [device operations proposal][ops]. ### How do operators enable or disable the feature? diff --git a/docs/enhancements/device-power/diagrams/participants.svg b/docs/enhancements/device-power/diagrams/participants.svg index 28645e35..2c4d52a4 100644 --- a/docs/enhancements/device-power/diagrams/participants.svg +++ b/docs/enhancements/device-power/diagrams/participants.svg @@ -1,5 +1,5 @@ -What power adds to device operationsStaff, from the Device page with a required reason, and the Fleet provider for Metal, from a Machine's powerState, both create a DevicePowerOperation that names an action. Staff operations also name the expected system UUID. Custody admission and site execution, defined in the device operations proposal, admit and deliver it. The Device's discovery facts, the offered power actions and the power state, gate admission. BMC discovery reads the BMC without changing it and reports those facts on the Device. The site worker checks the power state and sends at most one command to the BMC. A later discovery reading of the power state is the evidence that settles a power recovery hold. +What power adds to device operationsStaff, from the Device page with a required reason, and the Fleet provider for Metal, from a Machine's powerState, both create a DevicePowerOperation that names an action. Staff operations also name the expected system UUID. Custody admission and site execution, defined in the device operations proposal, admit and deliver it. The Device's discovery facts, the offered power actions and the power state, gate admission. BMC discovery reads the BMC without sending it commands and reports those facts on the Device. The site worker checks the power state and sends at most one command to the BMC. A DeviceRecovery settles a power recovery hold, citing a later discovery reading of the power state. @@ -20,7 +20,7 @@ BMC discovery -Read-only +Sends no commands Device Offered actions, power @@ -40,5 +40,5 @@ one command reads -A later discovery reading of the power state settles a power recovery hold. +A DeviceRecovery cites a later discovery reading to settle a power hold. diff --git a/docs/enhancements/device-power/diagrams/power-outcomes.svg b/docs/enhancements/device-power/diagrams/power-outcomes.svg index c255466b..aa2cb1c6 100644 --- a/docs/enhancements/device-power/diagrams/power-outcomes.svg +++ b/docs/enhancements/device-power/diagrams/power-outcomes.svg @@ -1,5 +1,5 @@ -How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state, or for a restart or power cycle a reset, was observed within three minutes. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within the deadline, or the power changed after a refusal. It places a recovery hold, which a DeviceRecovery settles using a discovery reading of the power state taken after the operation ended. +How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state was observed within three minutes, or for a restart or power cycle, reset evidence and power on. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within three minutes, or the power changed after a refusal. It places a recovery hold, which a DeviceRecovery settles using a discovery reading of the power state taken after the operation ended. @@ -14,8 +14,8 @@ Succeeded Requested state, or a -reset, seen within -three minutes +reset and power on, +within three minutes Failed Nothing sent, or the @@ -23,7 +23,7 @@ did not change OutcomeUnknown -No evidence in time, +No evidence in 3 minutes, or power changed after a refusal @@ -31,6 +31,5 @@ Power recovery hold Settled by a DeviceRecovery citing a later discovery read -The result is set once. -A new attempt is a new operation. +The result is set once. From d89ba918c6b2a69b394c685dacd73e3915cac609 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:13:27 -0600 Subject: [PATCH 16/26] docs: Settle Device power review details The admission section named SharedPublicKey and Expired without the phase each ends in, so a reader could take an expired operation as Failed. It now says SharedPublicKey ends Failed and Expired ends Cancelled, and the refusal test covers both. The no-op test now covers only On and ForceOff, and the Machine power requirement names the machine lifecycle projector. The document also gains the template's Functionality guide link and a short risks section. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 4da0b7a8..57103f90 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -5,7 +5,7 @@ stage: alpha # Device power operations -[Documentation overview](../../README.md) · [Architecture guide](../../architecture/README.md) +[Documentation overview](../../README.md) · [Functionality guide](../../functionality/README.md) - [Summary](#summary) - [Motivation](#motivation) @@ -16,6 +16,7 @@ stage: alpha - [Requesting staff power](#requesting-staff-power) - [Customer power](#customer-power) - [Who takes part](#who-takes-part) + - [Risks and mitigations](#risks-and-mitigations) - [Design details](#design-details) - [API design](#api-design) - [Admission](#admission) @@ -106,6 +107,13 @@ BMC discovery reads each BMC without sending it commands. It reports on the Device which power actions the server offers and its current power state. Admission uses both, and recovery uses the power state as evidence. +### Risks and mitigations + +- **Resetting the wrong server:** staff name the expected system UUID, and the + worker checks it against the BMC. See [Admission](#admission). +- **An unproven customer power change:** the server is held until staff + record a recovery. See [Recovery](#recovery). + ## Design details ### API design @@ -152,8 +160,8 @@ The evidence never carries a credential or BMC response content. Disabled capacity on a Device does not block staff power, because it leaves the holder `None`. Power reports two [custody admission][admission] refusals -under its own names: a shared BMC key as `SharedPublicKey`, and an expired -staff operation as `Expired`. +under its own names: a shared BMC key as `SharedPublicKey`, which ends +`Failed`, and an expired staff operation as `Expired`, which ends `Cancelled`. Power adds these refusals. Each ends the operation as `Failed` with nothing sent: @@ -193,8 +201,9 @@ anyway, which gives `OutcomeUnknown`. A power [recovery hold][unknown] settles with a `DeviceRecovery` whose evidence is a power state that discovery read after the operation ended. This proposal -also requires the Metal projector to report a held Machine's power as -`Unknown` until the hold settles. +also requires the [machine lifecycle](../machine-lifecycle/README.md) +projector to report a held Machine's power as `Unknown` until the hold +settles. ### Delivery phases @@ -212,10 +221,11 @@ also requires the Metal projector to report a held Machine's power as These tests are required and not written. Each checks the result and the number of commands at the BMC: -- Each refusal reason in the [admission](#admission) table, with no command. +- Each refusal reason in [Admission](#admission), including `SharedPublicKey` + and `Expired`, with no command. - On, off, restart and power cycle against the outcome table, including a lost response. -- A server already in the requested state, with no command. +- `On` or `ForceOff` on a server already in that state, with no command. - A staff operation on a Device with disabled capacity and holder `None`. - A refused customer operation is not retried until the Machine generation changes. From 9a15a9470e490542d33721788908fe9b78cdb041 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:25:39 -0600 Subject: [PATCH 17/26] docs: Align Device power with recovery decisions The custody proposal now defines four DeviceRecovery decisions, moves an OutcomeUnknown operation into the recovery hold, and lists both power rows in its operations table. The power proposal restated the shared goal, the separate-kinds alternative and the phases its admission refusals end in. The power proposal now reads as the per-kind specification under the custody proposal. It defines what counts as discovery evidence for a power hold: read after the operation ended, from the current BMC endpoint, with a settled power state. It says Retry does not apply to power and asks how a customer power intent continues after Settle, since provider names come from the Machine generation. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 54 +++++++++++-------- .../device-power/diagrams/power-outcomes.svg | 4 +- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 57103f90..f86d54c8 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -37,10 +37,10 @@ stage: alpha command. Staff use it on servers that no customer holds. Fleet's Metal provider uses it when a customer changes `Machine.spec.powerState`. -This document specifies the power kind only. The [device custody and -operations proposal][ops] defines custody, the operation envelope, admission, -site execution, recovery and authorization. Both documents are proposals. -Nothing in either is implemented. +This document is the per-kind specification of `DevicePowerOperation` under +the [device custody and operations proposal][ops], which defines custody, the +operation envelope, admission, site execution and recovery. Both documents are +proposals. Nothing in either is implemented. ## Motivation @@ -51,8 +51,6 @@ Customer power intent on a Machine has no executor yet. ### Goals -- Staff and customer power changes use one kind, one executor and one set of - outcome rules. - Each operation sends at most one command, to the exact server named. - Each staff operation records why it ran and the power state before and after. @@ -95,9 +93,9 @@ The Fleet provider for Metal maps a Machine's `powerState` to an action: | `Off` | `ForceOff` | The provider creates an operation only when `powerState` differs from the -server's observed power. Its name comes from the Machine generation, so a -refused operation is not retried until the Machine generation changes. The -provider reports the refusal reason on the Machine. +server's observed power. Provider power operations are [named from the Machine +generation][operations], so a refused one is not retried until the generation +changes. The provider reports the refusal reason on the Machine. ### Who takes part @@ -159,12 +157,11 @@ The evidence never carries a credential or BMC response content. ### Admission Disabled capacity on a Device does not block staff power, because it leaves -the holder `None`. Power reports two [custody admission][admission] refusals -under its own names: a shared BMC key as `SharedPublicKey`, which ends -`Failed`, and an expired staff operation as `Expired`, which ends `Cancelled`. +the holder `None`. Power names two outcomes of [custody +admission][admission]: the shared BMC key refusal is `SharedPublicKey`, and an +expired staff operation is `Expired`. -Power adds these refusals. Each ends the operation as `Failed` with nothing -sent: +Power adds these refusals. None sends a command: | Reason | Refused by | When | | --- | --- | --- | @@ -199,11 +196,19 @@ anyway, which gives `OutcomeUnknown`. ![How a power result is decided, and how a power recovery hold settles](diagrams/power-outcomes.svg) -A power [recovery hold][unknown] settles with a `DeviceRecovery` whose evidence -is a power state that discovery read after the operation ended. This proposal -also requires the [machine lifecycle](../machine-lifecycle/README.md) -projector to report a held Machine's power as `Unknown` until the hold -settles. +An `OutcomeUnknown` power operation becomes a [recovery hold][unknown]. The +`DeviceRecovery` that settles it must cite discovery evidence that: + +- was read after the operation ended; +- came from the Device's current BMC endpoint; and +- reports a settled power state, `On` or `Off`. + +The recovery decisions are defined in the device operations proposal. `Retry` +does not apply, because only a `DeviceRecovery` settles a power hold. + +This proposal also requires the [machine +lifecycle](../machine-lifecycle/README.md) projector to report a held +Machine's power as `Unknown` until the hold settles. ### Delivery phases @@ -229,8 +234,9 @@ number of commands at the BMC: - A staff operation on a Device with disabled capacity and holder `None`. - A refused customer operation is not retried until the Machine generation changes. -- A power hold settles only with discovery evidence read after the operation - ended, and the held Machine reports power as `Unknown` until then. +- A power hold settles only with discovery evidence that meets the + [Recovery](#recovery) rules, and the held Machine reports power as `Unknown` + until then. ## Production readiness review questionnaire @@ -267,8 +273,6 @@ See [Recovery](#recovery). ## Alternatives -- **Separate kinds for staff and customer power.** Rejected. Both need the same - executor and outcome rules. - **Machine power intent for unallocated Devices.** Rejected. A Machine is a customer allocation, and creating one for staff would expose capacity. @@ -282,6 +286,10 @@ See [Recovery](#recovery). test, or ship earlier on test hardware only? - **Customer power off.** `Off` maps to `ForceOff`, which cuts power without warning the operating system. Should Metal offer a graceful power off? +- **Customer power after a hold.** After `Settle`, the server's power can still + differ from `powerState`. The provider cannot create a new operation under + the same Machine generation, and `Retry` does not cover power. Should power + holds allow `Retry`, or should provider names change? ## Infrastructure needed diff --git a/docs/enhancements/device-power/diagrams/power-outcomes.svg b/docs/enhancements/device-power/diagrams/power-outcomes.svg index aa2cb1c6..773606a3 100644 --- a/docs/enhancements/device-power/diagrams/power-outcomes.svg +++ b/docs/enhancements/device-power/diagrams/power-outcomes.svg @@ -1,5 +1,5 @@ -How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state was observed within three minutes, or for a restart or power cycle, reset evidence and power on. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within three minutes, or the power changed after a refusal. It places a recovery hold, which a DeviceRecovery settles using a discovery reading of the power state taken after the operation ended. +How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state was observed within three minutes, or for a restart or power cycle, reset evidence and power on. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within three minutes, or the power changed after a refusal. It places a recovery hold, which a DeviceRecovery settles by citing a discovery reading of a settled power state taken after the operation ended. @@ -30,6 +30,6 @@ Power recovery hold Settled by a DeviceRecovery -citing a later discovery read +citing a later, settled power read The result is set once. From 2b084862d4b4b8ca6cfea09eac393e8f5ec27060 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:27:51 -0600 Subject: [PATCH 18/26] docs: Correct Device power names against custody Review found the power proposal called Expired a refusal, although the custody proposal ends an expired operation Cancelled, and stated the held Machine's Unknown power as a new requirement, although the machine lifecycle already reports unverified power as Unknown. Both now follow the existing rules. The reason and expected system UUID are now staff inputs in the spec, as the custody operations table lists them, and the proposal says a provider operation omits both. It also trims a restated naming rule, fixes the menu wording, and lists every worker refusal in the worker diagram. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 44 +++++++++++-------- .../device-power/diagrams/power-outcomes.svg | 1 - .../device-power/diagrams/worker-sequence.svg | 7 +-- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index f86d54c8..84d30ddf 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -34,8 +34,8 @@ stage: alpha ## Summary `DevicePowerOperation` powers a server on or off, or resets it, with one -command. Staff use it on servers that no customer holds. Fleet's Metal provider -uses it when a customer changes `Machine.spec.powerState`. +command. Staff use it from the Device page. Fleet's Metal provider uses it when +a customer changes `Machine.spec.powerState`. This document is the per-kind specification of `DevicePowerOperation` under the [device custody and operations proposal][ops], which defines custody, the @@ -76,8 +76,9 @@ Customer power intent on a Machine has no executor yet. ### Requesting staff power Staff use a power button on the Device page, next to the observed power state. -Its menu lists only the actions the server offers. An unavailable action shows -why in a tooltip, for example that a customer holds the server. Confirming asks +Its menu lists the actions the server offers. An action that cannot run now is +disabled, with the reason in a tooltip, for example that a customer holds the +server. Confirming asks for a reason and creates the operation. A badge shows progress and the result. An **Operations** tab lists past operations with their time, action, creator, result, and power before and after. Users without the power operator role do @@ -93,9 +94,9 @@ The Fleet provider for Metal maps a Machine's `powerState` to an action: | `Off` | `ForceOff` | The provider creates an operation only when `powerState` differs from the -server's observed power. Provider power operations are [named from the Machine -generation][operations], so a refused one is not retried until the generation -changes. The provider reports the refusal reason on the Machine. +server's observed power. Because of how the [operations][operations] section +names provider operations, a refused one is not retried until the Machine +generation changes. The provider reports the refusal reason on the Machine. ### Who takes part @@ -129,10 +130,11 @@ metadata: spec: deviceRef: {name: device-a, uid: 4b8e2f10-0000-4000-8000-0000000000a1} authority: - serviceRequest: {reason: "Hung in firmware during qualification"} + serviceRequest: {} # On, ForceOff, ForceRestart or PowerCycle. action: ForceRestart - # Staff only: the server staff expect behind the BMC. + # Staff only: why staff ran it, and the server they expect behind the BMC. + reason: Hung in firmware during qualification expectedSystemUUID: 00000000-0000-4000-8000-0000000000a1 status: # Power result evidence, recorded in custody with the result. @@ -143,6 +145,9 @@ status: resetEvidence: LastResetTime ``` +A staff operation requires `reason` and `expectedSystemUUID`. A provider +operation must omit both. + A power result carries this evidence. The coordinator records it in custody with the result, as [site execution][site] describes: @@ -157,9 +162,10 @@ The evidence never carries a credential or BMC response content. ### Admission Disabled capacity on a Device does not block staff power, because it leaves -the holder `None`. Power names two outcomes of [custody -admission][admission]: the shared BMC key refusal is `SharedPublicKey`, and an -expired staff operation is `Expired`. +the holder `None`. This document names two outcomes of [custody +admission][admission] for power: the shared BMC key refusal is +`SharedPublicKey`, and the cancellation of an expired staff operation is +`Expired`. Power adds these refusals. None sends a command: @@ -206,9 +212,9 @@ An `OutcomeUnknown` power operation becomes a [recovery hold][unknown]. The The recovery decisions are defined in the device operations proposal. `Retry` does not apply, because only a `DeviceRecovery` settles a power hold. -This proposal also requires the [machine -lifecycle](../machine-lifecycle/README.md) projector to report a held -Machine's power as `Unknown` until the hold settles. +A held Machine's power is unverified, so the [machine +lifecycle](../machine-lifecycle/README.md#machine) rule reports it as `Unknown` +until the hold settles. ### Delivery phases @@ -226,8 +232,8 @@ Machine's power as `Unknown` until the hold settles. These tests are required and not written. Each checks the result and the number of commands at the BMC: -- Each refusal reason in [Admission](#admission), including `SharedPublicKey` - and `Expired`, with no command. +- Each refusal reason in [Admission](#admission), including `SharedPublicKey`, + and an `Expired` cancellation, with no command. - On, off, restart and power cycle against the outcome table, including a lost response. - `On` or `ForceOff` on a server already in that state, with no command. @@ -251,8 +257,8 @@ proposal][ops]. ### What must operators monitor? -Power recovery holds, most urgently on allocated servers, `Expired` and `Stale` -refusals, and restarts that end `OutcomeUnknown` on each BMC model. +Power recovery holds, most urgently on allocated servers, `Expired` +cancellations, `Stale` refusals, and restarts that end `OutcomeUnknown` on each BMC model. ### How are failures recovered? diff --git a/docs/enhancements/device-power/diagrams/power-outcomes.svg b/docs/enhancements/device-power/diagrams/power-outcomes.svg index 773606a3..8cbdc7ad 100644 --- a/docs/enhancements/device-power/diagrams/power-outcomes.svg +++ b/docs/enhancements/device-power/diagrams/power-outcomes.svg @@ -31,5 +31,4 @@ Power recovery hold Settled by a DeviceRecovery citing a later, settled power read -The result is set once. diff --git a/docs/enhancements/device-power/diagrams/worker-sequence.svg b/docs/enhancements/device-power/diagrams/worker-sequence.svg index 3573a369..6441475f 100644 --- a/docs/enhancements/device-power/diagrams/worker-sequence.svg +++ b/docs/enhancements/device-power/diagrams/worker-sequence.svg @@ -1,5 +1,5 @@ -What a site worker does for one power operationThe worker receives an admitted power operation with its admission time. It reads the offered power actions and the current power state from the BMC. Unless the server is already in the requested state, it sends one command. It then reads the power state until the requested state or reset evidence appears, or three minutes pass. It returns a result with the power state before and after. Before sending, the worker refuses with no command if it started more than two minutes after admission, if a restart or power cycle targets a server that is off, or if the power state is still changing. +What a site worker does for one power operationThe worker receives an admitted power operation with its admission time. It reads the offered power actions and the current power state from the BMC. Unless the server is already in the requested state, it sends one command. It then reads the power state until the requested state or reset evidence appears, or three minutes pass. It returns a result with the power state before and after. Before sending, the worker refuses with no command if it started more than two minutes after admission, if the system UUID differs, if the action is not offered, if a restart or power cycle targets a server that is off, or if the power state is still changing. @@ -20,7 +20,7 @@ Read offered actions and power state -Power state +Offered actions, power state One command, unless already in that state @@ -32,5 +32,6 @@ and after -No command if late, if a restart targets an off server, or if power is changing. +No command if late, on a UUID mismatch, an action not offered, +a restart of an off server, or a power state still changing. From e4697ebe222d1f11fb237cb8a05230eb49703c3e Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:28:01 -0600 Subject: [PATCH 19/26] docs: Rewrap a Device power monitoring line Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 84d30ddf..10b2dfbe 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -258,7 +258,8 @@ proposal][ops]. ### What must operators monitor? Power recovery holds, most urgently on allocated servers, `Expired` -cancellations, `Stale` refusals, and restarts that end `OutcomeUnknown` on each BMC model. +cancellations, `Stale` refusals, and restarts that end `OutcomeUnknown` on each +BMC model. ### How are failures recovered? From 7224022a682723144f4709a6ed8dc5340bc73a7a Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 17:29:28 -0600 Subject: [PATCH 20/26] docs: Tidy Device power wording and history The implementation history listed a standalone revision that never reached main, so it now has one entry. The summary uses the same "Fleet provider for Metal" name as the rest of the document and the custody proposal, and the staff UI paragraph is rewrapped. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 10b2dfbe..1bd7b1be 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -34,8 +34,8 @@ stage: alpha ## Summary `DevicePowerOperation` powers a server on or off, or resets it, with one -command. Staff use it from the Device page. Fleet's Metal provider uses it when -a customer changes `Machine.spec.powerState`. +command. Staff use it from the Device page. The Fleet provider for Metal uses +it when a customer changes `Machine.spec.powerState`. This document is the per-kind specification of `DevicePowerOperation` under the [device custody and operations proposal][ops], which defines custody, the @@ -78,11 +78,10 @@ Customer power intent on a Machine has no executor yet. Staff use a power button on the Device page, next to the observed power state. Its menu lists the actions the server offers. An action that cannot run now is disabled, with the reason in a tooltip, for example that a customer holds the -server. Confirming asks -for a reason and creates the operation. A badge shows progress and the result. -An **Operations** tab lists past operations with their time, action, creator, -result, and power before and after. Users without the power operator role do -not see the button. +server. Confirming asks for a reason and creates the operation. A badge shows +progress and the result. An **Operations** tab lists past operations with their +time, action, creator, result, and power before and after. Users without the +power operator role do not see the button. ### Customer power @@ -267,9 +266,8 @@ See [Recovery](#recovery). ## Implementation history -- 2026-11-24: Proposed as a standalone staff feature. -- 2026-11-24: Revised as the power kind of the device custody and operations - proposal, covering customer power. +- 2026-11-24: Proposed as the power kind of the device custody and operations + proposal. ## Drawbacks From fc3d2e79a37219ef7d65ca8fa1cca38545261549 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 20:33:36 -0600 Subject: [PATCH 21/26] docs: Follow custody Retry and shared reasons The custody proposal now lets a power hold settle through Retry and a later power operation that succeeds, lets a kind add admission checks of its own inputs, and defines the reasons every kind shares, including SharedPublicKey and Expired. The power proposal now describes both ways a power hold settles and says a retried restart is a second reset of the server. Its refusal table keeps only power's own reasons and points to the custody rule for a kind's own checks. The open question about customer power after a hold is gone, and the outcome diagram shows Retry. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 32 +++++++++---------- .../device-power/diagrams/power-outcomes.svg | 11 ++++--- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 1bd7b1be..5d5733d8 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -161,12 +161,12 @@ The evidence never carries a credential or BMC response content. ### Admission Disabled capacity on a Device does not block staff power, because it leaves -the holder `None`. This document names two outcomes of [custody -admission][admission] for power: the shared BMC key refusal is -`SharedPublicKey`, and the cancellation of an expired staff operation is -`Expired`. +the holder `None`. [Custody admission][admission] defines the reasons every +kind shares. -Power adds these refusals. None sends a command: +Power adds these reasons. The coordinator checks run under the admission rule +for a kind's own inputs, and the worker checks run before the command. None +sends a command: | Reason | Refused by | When | | --- | --- | --- | @@ -201,15 +201,18 @@ anyway, which gives `OutcomeUnknown`. ![How a power result is decided, and how a power recovery hold settles](diagrams/power-outcomes.svg) -An `OutcomeUnknown` power operation becomes a [recovery hold][unknown]. The -`DeviceRecovery` that settles it must cite discovery evidence that: +An `OutcomeUnknown` power operation becomes a [recovery hold][unknown], which +settles in one of two ways. + +A `Settle` recovery must cite discovery evidence that: - was read after the operation ended; - came from the Device's current BMC endpoint; and - reports a settled power state, `On` or `Off`. -The recovery decisions are defined in the device operations proposal. `Retry` -does not apply, because only a `DeviceRecovery` settles a power hold. +After a `Retry` recovery, the next power operation settles the hold only if it +ends `Succeeded` under the [outcome table](#execution-and-outcomes). For +`ForceRestart` and `PowerCycle`, a retry is a second reset of the server. A held Machine's power is unverified, so the [machine lifecycle](../machine-lifecycle/README.md#machine) rule reports it as `Unknown` @@ -231,8 +234,7 @@ until the hold settles. These tests are required and not written. Each checks the result and the number of commands at the BMC: -- Each refusal reason in [Admission](#admission), including `SharedPublicKey`, - and an `Expired` cancellation, with no command. +- Each refusal reason in [Admission](#admission), with no command. - On, off, restart and power cycle against the outcome table, including a lost response. - `On` or `ForceOff` on a server already in that state, with no command. @@ -240,8 +242,8 @@ number of commands at the BMC: - A refused customer operation is not retried until the Machine generation changes. - A power hold settles only with discovery evidence that meets the - [Recovery](#recovery) rules, and the held Machine reports power as `Unknown` - until then. + [Recovery](#recovery) rules, or with a retried operation that succeeds, and + the held Machine reports power as `Unknown` until then. ## Production readiness review questionnaire @@ -291,10 +293,6 @@ See [Recovery](#recovery). test, or ship earlier on test hardware only? - **Customer power off.** `Off` maps to `ForceOff`, which cuts power without warning the operating system. Should Metal offer a graceful power off? -- **Customer power after a hold.** After `Settle`, the server's power can still - differ from `powerState`. The provider cannot create a new operation under - the same Machine generation, and `Retry` does not cover power. Should power - holds allow `Retry`, or should provider names change? ## Infrastructure needed diff --git a/docs/enhancements/device-power/diagrams/power-outcomes.svg b/docs/enhancements/device-power/diagrams/power-outcomes.svg index 8cbdc7ad..4537ea6a 100644 --- a/docs/enhancements/device-power/diagrams/power-outcomes.svg +++ b/docs/enhancements/device-power/diagrams/power-outcomes.svg @@ -1,5 +1,5 @@ -How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state was observed within three minutes, or for a restart or power cycle, reset evidence and power on. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within three minutes, or the power changed after a refusal. It places a recovery hold, which a DeviceRecovery settles by citing a discovery reading of a settled power state taken after the operation ended. +How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state was observed within three minutes, or for a restart or power cycle, reset evidence and power on. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within three minutes, or the power changed after a refusal. It places a recovery hold. A DeviceRecovery with Settle clears it by citing a discovery reading of a settled power state taken after the operation ended. A DeviceRecovery with Retry clears it once a later power operation succeeds. @@ -27,8 +27,9 @@ or power changed after a refusal - -Power recovery hold -Settled by a DeviceRecovery -citing a later, settled power read + +Power recovery hold +Settle: cite a later, settled power read +Retry: a later power operation +that succeeds From 898a8bba47080dc83f56906f34ab948347eb3977 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 20:34:20 -0600 Subject: [PATCH 22/26] docs: Say who retries a held power operation The custody proposal now lets a staff power operation run under its own power hold, names each retried operation from the held one, and ends an expired staff operation as Cancelled with reason Expired. The power proposal now says who creates the operation after a Retry for a staff hold and for a customer hold, and that it repeats the held operation's action and passes power's checks again. Monitoring describes Expired as a cancellation reason, not a refusal. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 5d5733d8..3381d14f 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -210,8 +210,11 @@ A `Settle` recovery must cite discovery evidence that: - came from the Device's current BMC endpoint; and - reports a settled power state, `On` or `Off`. -After a `Retry` recovery, the next power operation settles the hold only if it -ends `Succeeded` under the [outcome table](#execution-and-outcomes). For +After a `Retry` recovery, the held operation's requester creates one power +operation. For a staff hold, that is a staff power operation. For a customer +hold, the Fleet provider for Metal creates it. The operation repeats the held +operation's action, passes power's checks again, and settles the hold only if +it ends `Succeeded` under the [outcome table](#execution-and-outcomes). For `ForceRestart` and `PowerCycle`, a retry is a second reset of the server. A held Machine's power is unverified, so the [machine @@ -258,9 +261,9 @@ proposal][ops]. ### What must operators monitor? -Power recovery holds, most urgently on allocated servers, `Expired` -cancellations, `Stale` refusals, and restarts that end `OutcomeUnknown` on each -BMC model. +Power recovery holds, most urgently on allocated servers, staff operations +cancelled as `Expired`, `Stale` refusals, and restarts that end +`OutcomeUnknown` on each BMC model. ### How are failures recovered? From 584927b096ae3f2775a418680fc8aaa5a94149d8 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 20:36:06 -0600 Subject: [PATCH 23/26] docs: Guard customer power retries Review found that a customer retry repeated the held action even if the Machine's powerState had changed during the hold, and that the provider's "differs from observed power" rule cannot apply while power is Unknown. The provider now creates a retry only if powerState still maps to the held action. Otherwise staff settle the hold, and the newer operation runs after it. SystemUUIDMismatch now compares only the expected UUID with the recorded UUID and the BMC's, which leaves record against discovery to the custody identity rule. The proposal also drops who creates a retry, notes that DiscoveryNotCurrent extends the rule for a kind's own checks, and words the Retry path in the outcome diagram the same way as the text. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 23 +++++++++++-------- .../device-power/diagrams/power-outcomes.svg | 6 ++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 3381d14f..4f45a66a 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -93,9 +93,10 @@ The Fleet provider for Metal maps a Machine's `powerState` to an action: | `Off` | `ForceOff` | The provider creates an operation only when `powerState` differs from the -server's observed power. Because of how the [operations][operations] section -names provider operations, a refused one is not retried until the Machine -generation changes. The provider reports the refusal reason on the Machine. +server's observed power. A refused operation is not retried until the Machine +generation changes, because [provider operations are named by +generation][operations]. The provider reports the refusal reason on the +Machine. ### Who takes part @@ -165,13 +166,14 @@ the holder `None`. [Custody admission][admission] defines the reasons every kind shares. Power adds these reasons. The coordinator checks run under the admission rule -for a kind's own inputs, and the worker checks run before the command. None -sends a command: +for a kind's own inputs, which `DiscoveryNotCurrent` extends to the freshness of +the discovery facts the other checks read. The worker checks run before the +command. None sends a command: | Reason | Refused by | When | | --- | --- | --- | | `SystemUUIDNotRecorded` | Coordinator | A staff operation targets a Device with no system UUID on record. | -| `SystemUUIDMismatch` | Coordinator or worker | `expectedSystemUUID` differs from the Device record, discovery or the BMC. | +| `SystemUUIDMismatch` | Coordinator or worker | `expectedSystemUUID` differs from the Device's recorded UUID, or from the UUID the BMC reports. | | `DiscoveryNotCurrent` | Coordinator | Discovery has not read the BMC within twice its interval. | | `ResetTypeNotOffered` | Coordinator or worker | Discovery or the BMC does not offer the action. | | `Stale` | Worker | The worker started more than two minutes after admission. | @@ -210,13 +212,16 @@ A `Settle` recovery must cite discovery evidence that: - came from the Device's current BMC endpoint; and - reports a settled power state, `On` or `Off`. -After a `Retry` recovery, the held operation's requester creates one power -operation. For a staff hold, that is a staff power operation. For a customer -hold, the Fleet provider for Metal creates it. The operation repeats the held +The power operation created after a `Retry` recovery repeats the held operation's action, passes power's checks again, and settles the hold only if it ends `Succeeded` under the [outcome table](#execution-and-outcomes). For `ForceRestart` and `PowerCycle`, a retry is a second reset of the server. +The Fleet provider for Metal creates a retry without comparing observed power, +which is `Unknown` during the hold. It creates one only if the Machine's +current `powerState` still maps to the held action. Otherwise staff settle the +hold with `Settle`, and the newer operation runs after it. + A held Machine's power is unverified, so the [machine lifecycle](../machine-lifecycle/README.md#machine) rule reports it as `Unknown` until the hold settles. diff --git a/docs/enhancements/device-power/diagrams/power-outcomes.svg b/docs/enhancements/device-power/diagrams/power-outcomes.svg index 4537ea6a..4157faaf 100644 --- a/docs/enhancements/device-power/diagrams/power-outcomes.svg +++ b/docs/enhancements/device-power/diagrams/power-outcomes.svg @@ -1,5 +1,5 @@ -How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state was observed within three minutes, or for a restart or power cycle, reset evidence and power on. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within three minutes, or the power changed after a refusal. It places a recovery hold. A DeviceRecovery with Settle clears it by citing a discovery reading of a settled power state taken after the operation ended. A DeviceRecovery with Retry clears it once a later power operation succeeds. +How a power result is decidedAfter admission, the worker checks the server and sends at most one command. Succeeded means the requested power state was observed within three minutes, or for a restart or power cycle, reset evidence and power on. Failed means nothing was sent, or the BMC refused and the power did not change. OutcomeUnknown means no evidence appeared within three minutes, or the power changed after a refusal. It places a recovery hold. A DeviceRecovery with Settle clears it by citing a discovery reading of a settled power state taken after the operation ended. After a DeviceRecovery with Retry, a later power operation that repeats the held action clears it if it succeeds. @@ -30,6 +30,6 @@ Power recovery hold Settle: cite a later, settled power read -Retry: a later power operation -that succeeds +Retry, then a later power +operation that succeeds From d6744abc4c25e1f27aeace5528f8e82b19b6f255 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 20:37:33 -0600 Subject: [PATCH 24/26] docs: Test the customer power retry guard The last commit made the provider skip a retry when the Machine's powerState no longer maps to the held action. An acceptance test now covers that case and the newer operation running after a Settle. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 4f45a66a..26d9e3d9 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -249,6 +249,8 @@ number of commands at the BMC: - A staff operation on a Device with disabled capacity and holder `None`. - A refused customer operation is not retried until the Machine generation changes. +- After a customer `Retry`, a changed `powerState` produces no retry, and the + newer operation runs after staff `Settle` the hold. - A power hold settles only with discovery evidence that meets the [Recovery](#recovery) rules, or with a retried operation that succeeds, and the held Machine reports power as `Unknown` until then. From 24b2df0dabbf74d731776d0295fa2b58bb8fe86a Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 21:48:42 -0600 Subject: [PATCH 25/26] docs: Fit Device power checks to merged custody The merged custody proposal limits admission rule 7 to checks of a kind's own inputs, so discovery freshness cannot extend it. The power proposal now describes its coordinator checks as comparing the action and expected UUID with the Device record and discovery. It also says a staff retry carries the reason and expected UUID again, words the retry-guard test as a Retry on a customer hold, and places the power row in the architecture guide next to the device operations row. Co-Authored-By: Claude Opus 5.5 --- docs/architecture/README.md | 2 +- docs/enhancements/device-power/README.md | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/docs/architecture/README.md b/docs/architecture/README.md index b74bdae1..56d038f5 100644 --- a/docs/architecture/README.md +++ b/docs/architecture/README.md @@ -37,9 +37,9 @@ Key principles to carry into the detailed design: | 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 is a server's power changed? | [Device power operations](../enhancements/device-power/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) | -| How is a server's power changed? | [Device power operations](../enhancements/device-power/README.md) | | Which internal interfaces and guarantees exist? | [Implementation status](../development/README.md) | | Which milestones must precede rollout? | [Implementation roadmap](../development/roadmap.md) | | Where did the design originate? | [Pinned source proposals](design.md#source-proposals), [migration record](../proposals/fleet-management/MIGRATION.md) | diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 26d9e3d9..90222e87 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -165,10 +165,10 @@ Disabled capacity on a Device does not block staff power, because it leaves the holder `None`. [Custody admission][admission] defines the reasons every kind shares. -Power adds these reasons. The coordinator checks run under the admission rule -for a kind's own inputs, which `DiscoveryNotCurrent` extends to the freshness of -the discovery facts the other checks read. The worker checks run before the -command. None sends a command: +Power adds these reasons. The coordinator checks compare the action and the +expected UUID with the Device record and discovery, under the admission rule +for a kind's own inputs. The worker checks run before the command. None sends +a command: | Reason | Refused by | When | | --- | --- | --- | @@ -214,8 +214,9 @@ A `Settle` recovery must cite discovery evidence that: The power operation created after a `Retry` recovery repeats the held operation's action, passes power's checks again, and settles the hold only if -it ends `Succeeded` under the [outcome table](#execution-and-outcomes). For -`ForceRestart` and `PowerCycle`, a retry is a second reset of the server. +it ends `Succeeded` under the [outcome table](#execution-and-outcomes). A staff +retry carries `reason` and `expectedSystemUUID` again. For `ForceRestart` and +`PowerCycle`, a retry is a second reset of the server. The Fleet provider for Metal creates a retry without comparing observed power, which is `Unknown` during the hold. It creates one only if the Machine's @@ -249,8 +250,8 @@ number of commands at the BMC: - A staff operation on a Device with disabled capacity and holder `None`. - A refused customer operation is not retried until the Machine generation changes. -- After a customer `Retry`, a changed `powerState` produces no retry, and the - newer operation runs after staff `Settle` the hold. +- After a `Retry` on a customer hold, a changed `powerState` produces no retry, + and the newer operation runs after staff `Settle` the hold. - A power hold settles only with discovery evidence that meets the [Recovery](#recovery) rules, or with a retried operation that succeeds, and the held Machine reports power as `Unknown` until then. From 6776e42c4b7beb8321104f70363fb6c9a83d7a24 Mon Sep 17 00:00:00 2001 From: Scot Wells Date: Tue, 24 Nov 2026 21:49:26 -0600 Subject: [PATCH 26/26] docs: Say how discovery freshness guards power DiscoveryNotCurrent tests how recent the discovery read is, not one of the operation's inputs. The power proposal now says it guards the coordinator's comparisons against discovery by refusing stale reads. Co-Authored-By: Claude Opus 5.5 --- docs/enhancements/device-power/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/enhancements/device-power/README.md b/docs/enhancements/device-power/README.md index 90222e87..e21a0e1a 100644 --- a/docs/enhancements/device-power/README.md +++ b/docs/enhancements/device-power/README.md @@ -167,7 +167,8 @@ kind shares. Power adds these reasons. The coordinator checks compare the action and the expected UUID with the Device record and discovery, under the admission rule -for a kind's own inputs. The worker checks run before the command. None sends +for a kind's own inputs. `DiscoveryNotCurrent` guards those comparisons by +refusing stale discovery. The worker checks run before the command. None sends a command: | Reason | Refused by | When |