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
113 changes: 92 additions & 21 deletions docs/development/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,14 @@ removed as a breaking `v1alpha1` change with no conversion or migration. Stored
profiles with the old shape must be recreated before upgrading. The allocator
matches capacity only when the observed cores and memory equal the request.

Private records retained before that change still decode, but only so they can
be released. `controller.RetainedRequirements` is the `acceptedRequirements`
encoding in asset records, custody proposals, and Milo authority records. It
reads exact requirements unchanged. It also reads the complete former
`{min, max, exact}` shape for `cpu.cores` and `memory.capacity` and re-encodes
that shape verbatim. Allocation retries, selection, `Install`, network refresh,
and Milo recovery return `controller.ErrLegacyRecord` for such a record. That
error wraps `ErrRecordInvalid`. Synthetic staging reports it on a live Machine
as `Bound=False` and `Ready=False` with reason `LegacyCustodyRecord`, and does
not requeue. Deletion releases the record through the same verified cleanup
path as any other record, even when the profile UIDs it names were deleted
and recreated. Tests cover the legacy fixture decode, refusal without record
changes or provider effects, release with replaced profiles and with
unverified cleanup, staging status and finalizer removal, and Milo digest
preservation. See the
[upgrade notes](../enhancements/machine-lifecycle/README.md#machineprofile).
Private asset records, custody proposals, and Milo authority records retain
`acceptedRequirements` as the exact `MachineProfileSpec`. A private record whose
requirements use any other shape fails to decode, like a version 1
installation record or any other malformed record. Fleet keeps no decoder or
release path for older record shapes. How the coordinator contains such a
record, and how an operator removes it, is described in
[Undecodable private records](#undecodable-private-records). See the
[MachineProfile notes](../enhancements/machine-lifecycle/README.md#machineprofile).

`requestedhardware.Project` is the one projection that writes
`status.requestedHardware` and `RequestResolved`, and
Expand All @@ -105,6 +97,86 @@ provenance, missing and invalid profiles, post-acceptance profile changes,
inert-mode wiring, and staging and standalone carry-forward. See
[requested hardware](../enhancements/machine-lifecycle/README.md#requested-hardware).

## Undecodable private records

A private lifecycle record that does not decode into the current shape returns
`controller.ErrRecordUnreadable`, which wraps `ErrRecordInvalid`. This covers
asset, claim custody, installation, and Milo authority records. The record
blocks only the claim it belongs to (implemented):

- **Attribution.** The coordinator does not trust the body of a record it cannot
decode. It attributes the record by the `fleet.datumapis.com/claim-uid`
label, which `encodeRecord` and the Milo record store write on every record.
- **Scans across claims.** The asset scan behind allocation, installation,
network refresh, and release, and the installation scan by binding, skip a
record labeled for another claim. A record labeled for the scanning claim
fails that claim closed. A record with no claim label might belong to any
claim, so it fails every claim-scoped scan closed. Fleet never writes an
unlabeled record, so this case means the Secret was edited by hand. One such
Secret halts allocation, installation, and release for every claim on the
coordinator until an operator removes it.
- **Release from a selection.** A claim released while its custody only
proposes an asset reads that asset's record by name. If the record is
labeled for another claim, that claim holds the asset and the releasing
claim never did, so its custody is released without touching the record.
The record keeps fencing the asset's epoch. A record labeled for the
releasing claim, or with no label, fails release closed.
- **Capacity and epoch fencing.** Allocation reads each candidate asset's
record by name. If that record, or the custody record of the claim that last
held the asset, cannot be decoded, the asset is never proposed and allocation
tries the next candidate. Nothing proves that asset was released or what
epoch it reached, so treating it as free could double-bind it or restart its
epoch below a stale operation. A retained `Released` record that cannot be
decoded therefore keeps its asset out of allocation. It does not admit any
operation for its former claim either, because that claim's own scans fail
closed on it.
- **The claim's own work.** Allocation, installation, and release for the
attributed claim return `ErrRecordUnreadable`. They do not treat the claim as
having no record, and they never rewrite the record. Synthetic staging
reports the Machine as `Phase=Pending` with `Bound=False` and `Ready=False`,
reason `UnreadablePrivateRecord`, and does not requeue it. The managed
Machine handler also stops requeueing, and sets no condition: it writes no
Machine status at all, so synthetic staging is the only writer of Machine
lifecycle conditions. Release never removes the finalizer through such a
record.
- **Signals.** Every lifecycle decode goes through one reporting decoder, so
each record is logged once per lifecycle call at error level, whichever read
found it.
The log names the Secret and the attributed claim UID, never record
contents. The counter `fleet_private_lifecycle_record_undecodable_total`
counts the same events, labeled only by `record_type` (`asset`, `custody`,
`installation`, or `milo-authority`).

Fleet has no automated release for an undecodable record. To clear an affected
Machine, an operator does the following:

1. Find the Machine's UID. List the Secrets in `fleet-system-private` that
carry `fleet.datumapis.com/claim-uid=<UID>`. The error log names the
undecodable one.
2. If the Machine held an asset, set that MachineCapacity's
`allocationPolicy` to `Disabled`. Removing the records discards the binding,
its epoch, and any pending cleanup, so the physical machine's state is
unknown. Re-enable allocation only after the machine has been verified clean.
The next binding starts again at epoch 1, and an executor that retained a
higher epoch refuses it until its own fence is reset.
3. Delete the Machine. Release stops at the undecodable record and leaves the
finalizer in place.
4. Remove the `fleet.datumapis.com/machine-protection` finalizer from the
Machine by hand. Fleet cannot release through the record, so it never
removes the finalizer itself.
5. Delete every listed private record Secret for that claim UID, not only the
undecodable one. The claim no longer exists, and a record left behind keeps
describing authority that nothing will ever release.

A retained `Released` asset record whose Machine is already gone affects only
that asset. Delete that Secret after step 2 to return the asset to allocation.

Event routing reads only records that decode, so editing or deleting an
undecodable Secret wakes no claim. This is why the procedure deletes the
Machine and removes its finalizer before deleting the records. A claim blocked
by an unlabeled record is reconciled again on its next own event, or when the
manager restarts.

## Multi-project discovery

`cmd/fleet-manager` runs one set of controllers over every project that
Expand Down Expand Up @@ -539,11 +611,10 @@ provider effect, including the initiating principal and installation decision pl
the image catalog authority, revision, and image decision. The operation also
retains the installation and claim namespace, name, and UID, so an informer
initial Add can route unfinished work after restart even when the public
Installation has been deleted. This is installation-record schema v2. A v1
operation is upgraded atomically only when the exact public Installation and
claim request is still available to supply and verify the names omitted by v1;
otherwise it is quarantined from event routing and effects rather than guessed
or treated as ready. Image references must
Installation has been deleted. This is installation-record schema v2. A record
in any other schema version is invalid: it is quarantined from event routing
and effects and is never rewritten, guessed, or treated as ready. Image
references must
resolve to canonical lowercase SHA-256 digests. Stable operation and result
identities include the authority/project claim scope, so equal claim UIDs from
independent project APIs cannot share an operation record. Installation custody
Expand Down
75 changes: 45 additions & 30 deletions docs/enhancements/machine-lifecycle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,36 +358,40 @@ fields, or migration logic. A stored profile with the former
`cores: {min: ...}` or `capacity: {min: ...}` shape no longer decodes and must
be deleted and recreated with exact values before upgrading the manager.

Allocations accepted before this change can be released after the upgrade,
but they are never resumed (implemented). Private asset, claim custody, and
Milo authority records embed the accepted profile requirements. A narrowly
scoped decoder on those private records only (`RetainedRequirements`) still
reads the former `cpu.cores` and `memory.capacity` `{min, max, exact}` shape.
It accepts that shape only when both fields use it and no unknown fields are
present. The original JSON is kept verbatim, so retained requirement digests
stay valid when release rewrites the record. The public `MachineProfileSpec`
and the CRD are unchanged. A record in the former shape:

- never satisfies an allocation retry, selection, installation admission,
network refresh, or Milo authority recovery. Those paths return
`ErrLegacyRecord`, which wraps the generic invalid-record error, so they
fail closed. The record never produces `requestedHardware`,
`allocatedHardware`, or readiness. This holds even when the profile UIDs it
names still exist;
- is reported on a live Machine by synthetic staging as `Phase=Pending` with
`Bound=False` and `Ready=False`, reason `LegacyCustodyRecord`, without a retry
loop. The production Machine handler also stops retrying it;
- is released by the normal verified release path when the Machine is deleted:
cleanup must return correlated evidence, then the asset and custody records
become `Released`, the capacity becomes available again, and the finalizer
is removed. Release does not consult the profile, so profile UIDs that no
longer exist (a deleted and recreated profile) do not block it. Uncertain or
malformed cleanup evidence leaves the record `Releasing` and the finalizer in
place.

Operators do not edit private records. Delete each affected Machine and wait
for the finalizer to clear. A released record in the former shape is retained
for epoch fencing and does not block the next allocation of that machine.
Private asset, claim custody, and Milo authority records embed the accepted
requirements as the exact `MachineProfileSpec` (implemented). Fleet keeps no
decoder for an earlier record shape. A private record whose requirements do
not decode as the exact shape is undecodable. It never produces
`requestedHardware`, `allocatedHardware`, or readiness, and it is never
rewritten. It blocks only the claim it belongs to (implemented):

- The coordinator attributes an undecodable record by its
`fleet.datumapis.com/claim-uid` label, never by its body. Scans across
claims skip a record labeled for another claim. A record with no claim label
could belong to any claim, so it fails every claim-scoped scan closed: one
hand-edited Secret with no label halts allocation, installation, and release
for every claim until it is removed.
- A claim released while it only proposes an asset whose undecodable record
is labeled for another claim never held that asset, so it is released and
the record is left in place to keep fencing the asset.
- Allocation, installation admission, network refresh, Milo authority recovery,
and release fail closed for the attributed claim. Synthetic staging reports
the Machine as `Bound=False` and `Ready=False`, reason
`UnreadablePrivateRecord`, without a retry loop. Release never removes the
finalizer through such a record.
- Allocation never proposes an asset whose record, or whose previous claim's
custody record, cannot be decoded. Without the record there is no proof the
asset was released or of its epoch. A `Released` record kept for epoch
fencing that cannot be decoded therefore keeps its asset out of allocation
rather than restarting its epoch below a stale operation.
- Each such record is logged and counted in
`fleet_private_lifecycle_record_undecodable_total`, labeled by record type.

Fleet has no automated recovery. An operator disables allocation on the
affected capacity, deletes the Machine, removes its finalizer by hand, then
deletes that claim's private record Secrets. The
[implementation status](../../development/README.md#undecodable-private-records)
lists the steps.

GPU, disk, and interface requirements keep numeric constraints with inclusive
`min` and optional `max`, or `exact` alone. Counts are integers, capacities are
Expand Down Expand Up @@ -1455,6 +1459,17 @@ correctness violations.
- 2026-11-18: Retained private records written before exact CPU and memory
decode again for release only. Live Machines report `LegacyCustodyRecord`
instead of looping, and deletion releases them through verified cleanup.
- 2026-11-23: Removed the decoder and release path for private records written
before exact CPU and memory, the `LegacyCustodyRecord` reason, and the
installation-record v1 upgrader. Records in older shapes or schema versions
are invalid.
- 2026-11-23: An undecodable private record blocks only the claim its
`claim-uid` label names, plus the asset it fences, instead of every claim on
the coordinator. It is reported as `UnreadablePrivateRecord` and counted in
`fleet_private_lifecycle_record_undecodable_total`.
- 2026-11-24: Release from a selection skips an undecodable proposed asset
record labeled for another claim. Every lifecycle decode reports through one
decoder.

## Drawbacks

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
github.com/evanphx/json-patch/v5 v5.9.11
github.com/fsnotify/fsnotify v1.10.1 // indirect
github.com/fxamacker/cbor/v2 v2.9.1 // indirect
github.com/go-logr/logr v1.4.4 // indirect
Expand All @@ -75,8 +75,8 @@ require (
github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/client_golang v1.24.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/client_golang v1.24.0
github.com/prometheus/client_model v0.6.2
github.com/prometheus/common v0.70.0 // indirect
github.com/prometheus/procfs v0.21.1 // indirect
github.com/spf13/pflag v1.0.10 // indirect
Expand Down
Loading
Loading