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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/fleet-simulator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func main() {
defer stop()
results := site.NewResults(store)
runner := &site.Runner{Site: siteName, Store: store, Results: results, Access: fixture.Access{Enrollment: enrollment},
Kinds: map[string]site.Kind{"DeviceInstallation": simwork.Installation{}, "DeviceWipe": simwork.Wipe{}, "DeviceCommissioning": simwork.Commissioning{}}}
Kinds: map[string]site.Kind{"DeviceInstallation": simwork.Installation{}, "DeviceWipe": simwork.Wipe{}, "DeviceCommissioning": simwork.Commissioning{}}, Payloads: site.StorePayloads{Store: store}}
runner.Kinds["DevicePowerOperation"] = simwork.Power{}
dispatcher := &siteapi.Dispatcher{Runner: runner, Context: ctx, Logger: logger}
// The simulator's installs and wipes are simulated, so its declaration
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources: [fleet.datumapis.com.yaml]
resources: [fleet.datumapis.com.yaml, sealedpayloads.yaml]
41 changes: 41 additions & 0 deletions config/components/device-operations/crds/sealedpayloads.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# The sealed store for customer bootstrap data (#184). A dedicated kind, not a
# Secret, because Milo grants permissions per kind or per object, never per
# namespace: only roles that name this kind can read it.
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: sealedpayloads.fleet.datumapis.com
annotations:
discovery.miloapis.com/parent-contexts: Project
spec:
group: fleet.datumapis.com
names:
kind: SealedPayload
listKind: SealedPayloadList
plural: sealedpayloads
singular: sealedpayload
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
apiVersion: {type: string}
kind: {type: string}
metadata: {type: object}
spec:
type: object
x-kubernetes-validations:
- {rule: 'self == oldSelf', message: a sealed payload never changes}
required: [operationName, allocationName, digest, salt, data]
properties:
operationName: {type: string, minLength: 1, maxLength: 253}
allocationName: {type: string, minLength: 1, maxLength: 253}
digest: {type: string, pattern: '^sha256:[0-9a-f]{64}$'}
# 32 random bytes, base64.
salt: {type: string, format: byte, minLength: 44, maxLength: 44}
# At most 96 KiB of encoded bootstrap data, base64.
data: {type: string, format: byte, minLength: 1, maxLength: 131072}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resources:
- devicewipe.yaml
- devicepoweroperation.yaml
- devicerecovery.yaml
- sealedpayload.yaml
- cleaningpolicy.yaml
- devicecommissioning.yaml
- devicecommissioningplan.yaml
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: iam.miloapis.com/v1alpha1
kind: ProtectedResource
metadata:
name: fleet.datumapis.com-sealedpayload
spec:
serviceRef:
name: fleet.datumapis.com
kind: SealedPayload
plural: sealedpayloads
singular: sealedpayload
# The spec never changes, so there is no update or patch.
permissions: [list, get, watch, create, delete]
parentResources:
- apiGroup: resourcemanager.miloapis.com
kind: Project
7 changes: 7 additions & 0 deletions config/components/device-operations/roles/coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,10 @@ spec:
- metal.datumapis.com/machinecapacities.get
- metal.datumapis.com/machinecapacities.list
- metal.datumapis.com/machinecapacities.watch
# The coordinator checks each payload at admission, the federation
# courier in it delivers payloads to sites, and it deletes them. No
# other role can read the sealed store.
- fleet.datumapis.com/sealedpayloads.get
- fleet.datumapis.com/sealedpayloads.list
- fleet.datumapis.com/sealedpayloads.watch
- fleet.datumapis.com/sealedpayloads.delete
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ spec:
launchStage: Alpha
includedPermissions:
- fleet.datumapis.com/deviceinstallations.create
# It copies bootstrap data into the sealed store and never reads it back.
- fleet.datumapis.com/sealedpayloads.create
- fleet.datumapis.com/deviceinstallations.get
- fleet.datumapis.com/deviceinstallations.list
- fleet.datumapis.com/deviceinstallations.watch
Expand Down
14 changes: 14 additions & 0 deletions config/standalone/fixtures.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ spec:
version: "12"
architecture: amd64
firmwareModes: [UEFI]
bootstrapFormats: [NoCloud]
digest: "sha256:9f4ad8d8b8a6f6fc64d2cf2c7e70b9184b74f089adf8c36d84f4fcb99892f3cb"
availability: Available
---
Expand Down Expand Up @@ -97,6 +98,19 @@ spec:
machineRef: {name: allocation}
expectedPredecessor: {type: None}
imageRef: {name: debian-12}
bootstrapConfigRef: {name: debian-12-bootstrap}
---
# The consumer's bootstrap data, in its own namespace. Synthetic values only.
apiVersion: v1
kind: Secret
metadata: {name: debian-12-bootstrap, namespace: fleet-project-a}
type: metal.datumapis.com/bootstrap
stringData:
userData: |
#cloud-config
hostname: synthetic-example
sshAuthorizedKeys: |
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAISyntheticExampleOnly synthetic@example.com
---
apiVersion: metal.datumapis.com/v1alpha1
kind: Installation
Expand Down
14 changes: 14 additions & 0 deletions config/standalone/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ rules:
- apiGroups: [metal.datumapis.com]
resources: [machineimagepublications]
verbs: [get, create, delete]
# It copies bootstrap data into the sealed store and never reads it back.
- apiGroups: [fleet.datumapis.com]
resources: [sealedpayloads]
verbs: [create]
- apiGroups: [fleet.datumapis.com]
resources: [devices, devicecustodies, devicecommissionings, devicecommissioningplans, devicecommissioningplanapprovals]
verbs: [get, list]
Expand All @@ -73,6 +77,12 @@ apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata: {name: fleet-synthetic-consumer-writer, namespace: fleet-project-a}
rules:
# The Installation's bootstrap Secret. The fixture stands in for reading it
# under the Installation creator's authority.
- apiGroups: [""]
resources: [secrets]
resourceNames: [debian-12-bootstrap]
verbs: [get]
# The publisher's copy of the provider image.
- apiGroups: [metal.datumapis.com]
resources: [machineimages]
Expand Down Expand Up @@ -165,6 +175,10 @@ rules:
- apiGroups: [metal.datumapis.com]
resources: [machineallocations]
verbs: [get, list, watch]
# The only reader of the sealed store: it checks, delivers and deletes.
- apiGroups: [fleet.datumapis.com]
resources: [sealedpayloads]
verbs: [get, list, watch, delete]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
Expand Down
16 changes: 9 additions & 7 deletions docs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ is implemented on the same custody, and nothing creates power operations yet.
**implemented**: a provider-published, digest-pinned `MachineImage` that
admission resolves through a publication record and checks against the
server's architecture and firmware mode. The sealed bootstrap store is
proposed.
**implemented** through the simulator site; federation and the lab sites do
not carry bootstrap data yet.

The opt-in [multi-plane acceptance harness](../operations/multiplane.md) composes
the [local VM site](../operations/local-vm.md) with native Milo project APIs, the
Expand Down Expand Up @@ -546,7 +547,7 @@ allocator selects again. An `Active` allocation that lost custody is not repaire

Installation admission creates a `DeviceInstallation` named from the allocation
and the Installation UID. The Installation's predecessor must be the Machine's
current installation, and a bootstrap reference is refused. Response-loss
current installation, and bootstrap data goes through the sealed store. Response-loss
recovery is an exact lookup by name, not a second effect. Release moves the
holder to `Release`, closes the gates, wipes the Device, deletes the quota claim,
and only then returns the Device to `None`. The allocation, installations and
Expand Down Expand Up @@ -814,13 +815,14 @@ acceptance inventory.
fence, consumer-project deletion recovery, or provider-project purge guard.
Production cross-project allocation therefore fails closed, and the quota claim
has no end-to-end run.
- `LocalDigestImageResolver` is test-only. Production image authority,
namespace authorization, catalog lifetime identity, and digest resolution are
not implemented.
- Image resolution uses a fixture authorizer; the Milo image-use check is not
implemented. See [OS images and bootstrap data](machine-images.md).
- No container image or Kubernetes deployment is delivered in this increment.
- There is no mTLS workload identity, target-level authorization, or production
site credential protocol.
- The capacity projector is unwired (O1) and bootstrap is refused (O10); see
[Device custody](device-custody.md#points-for-a-person).
- The capacity projector is unwired (O1); see
[Device custody](device-custody.md#points-for-a-person). Bootstrap data
reaches only the simulator site; see [OS images and bootstrap
data](machine-images.md).
- The site store is intended for a single site process per Device. Replication,
migration, backup, and upgrade/downgrade compatibility are not implemented.
21 changes: 11 additions & 10 deletions docs/development/device-custody.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ update). A retry finds the same allocation by its name.
- **Installation.** The `DeviceInstallation` is named from the allocation and the
Installation UID, which its `fleet.datumapis.com/installation-uid` label
records. Its predecessor must be the Machine's current installation.
A bootstrap reference is refused.
Bootstrap data goes through the [sealed store](machine-images.md).
- **Release.** The allocation's holder moves to `Release` with all six gates
open. Then:
- Access closes at once.
Expand Down Expand Up @@ -452,7 +452,8 @@ a Machine status, update or patch permission.

### Unchanged and still open

- Bootstrap stays refused (O10).
- Bootstrap data reaches only the simulator site. See
[OS images and bootstrap data](machine-images.md).
- `DeviceRecovery` needs no second person.

## Failure scenarios (Increment D)
Expand Down Expand Up @@ -756,10 +757,10 @@ remains.
a person](#points-for-a-person).
- Staff roles may read MachineAllocations, because nothing secret is on them.
Only the recovery operator role grants that read today.
- Bootstrap stays refused. A `DeviceInstallation` that names a bootstrap
reference ends `Failed` with `BootstrapUnsupported`. No role can read a
Secret, a sealed store, or a bootstrap payload, and a test checks the role
definitions.
- Bootstrap data lives in the [sealed store](machine-images.md). Only the
coordinator role can read it, the installation requester can only create
it, and no role reads a Secret or a bootstrap payload. A test walks every
role the repository ships to check this.

### Other decisions

Expand Down Expand Up @@ -1190,8 +1191,8 @@ These need a decision before the increment that depends on them.
- **Who approves commissioning plans.** No team holds the plan approver role
in any deployed environment yet, so no plan qualifies there. The roles keep
the author and the approver apart by username.
- **O10: the sealed store for bootstrap payloads.** Bootstrap stays refused in
every increment until a store is chosen.
- **O10: the sealed store for bootstrap payloads.** Chosen and implemented as
`SealedPayload`; see [OS images and bootstrap data](machine-images.md).
- **Machine status writes by consumers in Milo.** Milo's authorizer, with
subresource authorization off, checks a status write against `update` and
`patch`, which the consumer and claimant roles hold. The power webhook refuses
Expand Down Expand Up @@ -1440,7 +1441,7 @@ a real API server:

| Area | Tests |
| --- | --- |
| Every admission precondition, names, kind checks, bootstrap refusal, staff expiry | `TestAdmissionPreconditions` |
| Every admission precondition, names, kind checks, the sealed bootstrap payload check, staff expiry | `TestAdmissionPreconditions` |
| Every holder transition, pending order, supersede, cancellation on holder change, stale fences, results, deadlines | `TestLifecycle`, `TestImportedDeviceGetsUnverifiedCustodyAndSendsNothing` |
| Holds and settlement through the test-only kind, install and wipe holds, `Retry`, `Retire`, retention | `TestRecovery` |
| Rebuild from each source, each conflict, `Resolve`, custody deleted and restored | `TestRebuild` |
Expand Down Expand Up @@ -1482,7 +1483,7 @@ Increment B's site tests run with `go test -race ./internal/site/...`:
| One worker per assignment, final results, shutdown at each stage, an older worker that does not stop, a fence raised between journal and send | `TestARedeliveryWhileTheSameOperationRunsStoresNothing`, `TestACopyWaitingForTheLockReturnsTheStoredResult`, `TestAStoredResultSurvivesARedelivery`, `TestAWorkerStoppedFromOutsideStoresNoResult`, `TestAShutdownWhileWaitingForTheRunLockStoresNothing`, `TestAShutdownDuringTheChecksStoresNothing`, `TestANewerAssignmentThatCannotStopTheOlderWorkerSendsNothing`, `TestALostLockWithJournaledStepsIsUnknown`, `TestAFenceRaisedBetweenJournalAndSendStopsTheStep` |
| Per-Device credentials, the fence report | `TestSecretCredentialsUseThePerDeviceContract`, `TestReportGivesTheCoordinatorSeenAndStoppedFences` |
| Step payloads, the start-by window, identity separate from capabilities, a resumed worker reporting unknown | `TestAStepPayloadIsJournaledAndReadBack`, `TestALateStartIsStaleAndSendsNothing`, `TestIdentityIsSeparateFromInstallCapabilities`, `TestAResumedWorkerThatCannotReachTheBMCReportsUnknown` |
| Install and wipe against a simulated BMC, one power-on per phase after an interruption in either phase, the power-off bound, fenced boot admission, bootstrap refused | `TestAWorkerInterruptedInTheDiskPhaseResumes`, `TestAServerThatNeverPowersOffEndsTheStep`, `TestInstallationRunsBothPhasesWithOneOnEach`, `TestWipeChecksTheEnrolledDisk`, `TestAnInterruptedWorkerResumesWithoutASecondOn`, `TestOnlyTheCurrentFenceHasAnOpenBootAdmission`, `TestBootstrapIsRefusedAtTheSiteToo` |
| Install and wipe against a simulated BMC, one power-on per phase after an interruption in either phase, the power-off bound, fenced boot admission, bootstrap refused by a site that cannot hand it on | `TestAWorkerInterruptedInTheDiskPhaseResumes`, `TestAServerThatNeverPowersOffEndsTheStep`, `TestInstallationRunsBothPhasesWithOneOnEach`, `TestWipeChecksTheEnrolledDisk`, `TestAnInterruptedWorkerResumesWithoutASecondOn`, `TestOnlyTheCurrentFenceHasAnOpenBootAdmission`, `TestBootstrapIsRefusedAtTheSiteToo` |

Increment C's tests run with `task test:envtest`, and the smoke runs with
`task standalone:test`:
Expand Down
53 changes: 52 additions & 1 deletion docs/development/machine-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ proposal's API names are provisional. Each piece below is marked
| Increment | What it covers | Status |
| --- | --- | --- |
| 1: image catalog | `MachineImage` and `MachineImagePublication` kinds, publication, admission-time resolution to a pinned digest, architecture and firmware mode checks, the worker's firmware mode check, and IAM | **Implemented and verified.** The CRD rules are checked with the API server's own schema validator, resolution and publication with a fake API server, and installs of a resolved image against a real API server and in the standalone smoke. The multi-plane runs are not yet verified. |
| 2: sealed bootstrap store | `SealedPayload`, delivery to the operation's worker, deletion | **Proposed** |
| 2: sealed bootstrap store | `SealedPayload`, the coordinator's check and sweep, delivery to the operation's worker, deletion at the site, IAM | **Implemented and verified** through the simulator site, by unit tests, tests against a real API server, and the standalone smoke. Admission refuses bootstrap data for a Device served through federation, which the local VM and Redfish labs use. |
| 3: lab proof | A chosen image with bootstrap data installs in the local VM and Redfish labs, and the guest reports the data it received | **Proposed** |

## What increment 1 adds
Expand Down Expand Up @@ -70,6 +70,50 @@ proposal's API names are provisional. Each piece below is marked
publisher roles write images, only the publisher writes records, and only
the publisher and the Fleet provider read records.

## What increment 2 adds

- **Bootstrap Secret.** A Secret of type `metal.datumapis.com/bootstrap` with
`userData`, `sshAuthorizedKeys`, or both, as UTF-8 text, at most 64 KiB and
at most 96 KiB once encoded, so a site always receives it whole. Admission
refuses anything else with `BootstrapInvalid`, and a missing or unreadable
Secret with `BootstrapNotFound`.
- **Sealed store.** `SealedPayload` in `fleet.datumapis.com`, in the provider
project. Its spec never changes. It holds a random 32-byte salt and the data,
and its digest covers both. Its name derives from the operation name and the
digest.
- **Admission.** If the DeviceInstallation already exists, admission returns
it and reads nothing. Otherwise the Fleet provider seals the data, creates
the payload, then creates the operation, which carries only the payload's
name and digest. Of two concurrent admissions, one operation wins and the
other's payload is swept.
- **Coordinator check.** At the custody update, every site serving the Device
must be able to receive payloads, or the operation fails with
`BootstrapUnsupported`. The payload must exist under the derived name, name
the operation, and match a digest recomputed from its salt and data, or the
operation fails with `BootstrapUnavailable`. Either way nothing is sent. The
coordinator reads through to the API server, and a failed read refuses, as
in every kind check.
- **Sweep.** Each coordinator pass deletes, with a UID precondition, every
payload whose operation ended, whose operation names another payload, or
that has no operation and an allocation that is not `Active`.
- **Delivery.** The courier reads the payload, checks it again, and sends it to
the site beside the assignment. The site takes the payload reference from
the admitted inputs, not from the transport, stores the payload only if it
matches, and the runner checks it again before anything is sent.
- **Site deletion.** The site deletes the payload when the result is stored,
when the coordinator answers the result, and whenever it raises the Device's
fence, for a newer operation or a recovery, which removes every payload
below it, including one whose worker never ran. A worker stopped from
outside keeps it for its replacement.
- **Evidence.** A successful install's evidence names the digest of the data
the worker handed to the server, recomputed from what it handed. Custody
accepts a success only if that equals the admitted digest, and only if it is
empty when there was no bootstrap data.
- **IAM.** Only the coordinator role reads `SealedPayload`; the installation
requester may only create it. A test walks every Milo role the repository
ships, resolves inheritance, and fails if any other role can read it or holds
a wildcard.

## Not implemented yet

- The validating webhook that rejects image writes from anyone but the
Expand All @@ -80,3 +124,10 @@ proposal's API names are provisional. Each piece below is marked
- Artifact mirroring by digest from a provider registry. Each lab site holds
one pinned image and serves only that one.
- Firmware mode from BMC discovery. Lab fixtures write it on the capacity.
- Federation delivery of bootstrap payloads to a cell, and handing them to a
local VM or Redfish server. Admission refuses such an operation with
`BootstrapUnsupported` before the Device's fence moves.
- The Milo check that the Installation's creator can read the bootstrap
Secret. The lab compositions read it with their own identity.
- Encryption at rest for `SealedPayload` and an audit policy that omits its
bodies.
5 changes: 3 additions & 2 deletions docs/operations/site-execution.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,9 @@ objects. This sequence is proposed only.
## Secrets

A handoff carries one assignment: the Device, the operation, the fence, the
admitted snapshot and the exact inputs. It holds no credential. A bootstrap
payload is refused, so none is carried. A Redfish worker reads each Device's own
admitted snapshot and the exact inputs. It holds no credential and no
bootstrap payload. Federation does not yet carry bootstrap payloads, so
admission refuses an operation that names one. A Redfish worker reads each Device's own
BMC credential Secret in the site's cluster, never from a handoff. Cell readers
of handoffs are:

Expand Down
Loading
Loading