Repository navigation
refactor: Stop reading private lifecycle records in older shapes - #176
Conversation
Fleet keeps no backward-compatible code paths while in active development. Remove the decoder and release-only path for private records written before exact MachineProfile CPU and memory, the ErrLegacyRecord sentinel and its LegacyCustodyRecord reason, and the installation-record v1 upgrader. Accepted requirements are now the plain MachineProfileSpec, which encodes the same JSON as before, so digests and record comparisons for current records are unchanged. An older record shape or schema version fails decoding and is rejected through the existing ErrRecordInvalid path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 8b7480d)
Removing the legacy decoders made a record in an older shape fail every scan across claims: one undecodable asset record, even a retained Released one, blocked allocation, installation, and release for every claim on the coordinator. Attribute an undecodable record by its claim-uid label, never by its body. The asset scan and the installation scan by binding now skip a record labeled for another claim and fail closed only for the labeled claim. A record without the label could belong to any claim, so it still fails every claim-scoped scan closed. Allocation never proposes a candidate asset whose record, or whose previous claim's custody record, cannot be decoded, so an unreadable Released record keeps its asset and epoch fenced instead of letting a new binding restart below a stale operation. Decode failures now return ErrRecordUnreadable, which wraps ErrRecordInvalid. Synthetic staging reports the affected Machine with reason UnreadablePrivateRecord and does not requeue it; the managed Machine handler also stops requeueing. Each record is logged once per lifecycle call and counted in fleet_private_lifecycle_record_undecodable_total by record type. Milo authority records report through the same counter and sentinel. Document the containment rules and the operator cleanup, which removes the finalizer by hand because Fleet does not release through such a record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit b7d324f)
A claim released from Selecting read its proposed asset's record by name and returned any decode error, so an undecodable record that belonged to another claim kept this claim's finalizer. That record is attributed by its claim-uid label like any other: labeled for another claim, the releasing claim never held the asset, so its custody is released and the record is left in place to keep fencing the epoch. Labeled for the releasing claim, or unlabeled, release still fails closed. Lifecycle code now decodes through one reporting wrapper, so custody creation, operation reads, and operation completion log and count an undecodable record like the scans already did. Document that an unlabeled undecodable record halts every claim, that the managed handler writes no Machine status, and that removing an undecodable record wakes no claim. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit 48a63c3)
Release wrapped a custody read failure with %v, which dropped ErrRecordUnreadable. A claim whose own custody record could not be decoded was requeued forever on release and never reported UnreadablePrivateRecord. Wrap it with %w, and route an unreadable record from external release settlement through the same report. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ecv
left a comment
There was a problem hiding this comment.
Approve.
An undecodable record is attributed by its claim-uid label and blocks only that Machine and the asset it fences; I found no path where one releases or reuses its asset. Tests pass locally (controller, staging, manager, milo at 5006899).
- Fail-closed checked: an undecodable asset or custody record is never proposed by allocation (
unreadableCandidateskips it, so the asset stays fenced), a retainedReleasedrecord keeps its epoch fence, and a record with no label blocks every claim inrecordsForClaimScoped,operationsForBindingand release-from-proposed. Nothing in the diff deletes, rewrites or frees an unreadable record. - Tamper 1: removing the
owner == ""arm ofrecordMayBelongTofailsTestUndecodableRecordAttributionandTestReleaseFromSelectionAttributesAnUndecodableProposedAsset. Tamper 2: making it return true (block everyone) fails six tests includingTestUndecodableAssetRecordBlocksOnlyItsOwnClaim. Tamper 3: makingunreadableCandidatealways return the error fails three tests. Both guards are covered. - Scans terminate and do not block all Machines: the labeled-for-another-claim branch is
continue, and the reporting context dedups per call.
Follow-ups:
-
Tamper 4: disabling the own-claim fail-closed in
unreadableCandidate(secret.Labels[claimUIDLabel] == string(claimUID)) fails no test. Allocate reads the claim's own records first (lifecycle.go:441), so it is defence in depth today, but a test with the claim's own undecodable candidate asset record should pin it. -
"Digests of current records unchanged" rests on reasoning, not a test: the old
RetainedRequirementsmarshal tests are deleted and no test pins a retained-requirements digest or record bytes for aMachineProfileSpec. Add a golden digest or a byte comparison of the encoded record. -
One hand-edited unlabeled Secret halts allocate, install and release for every Machine; the PR documents it. A label-presence check at list time that names the Secret in a condition or alert would shorten the outage.
-
Re-checked at 08e5549. The new commit wraps the custody error with
%w, soErrRecordUnreadablestays detectable. The cross-project release path now reports an unreadable record as pending withReasonUnreadablePrivateRecord, instead of retrying, and it still releases nothing. Tests cover both.
Related to #90.
Fleet keeps no backward-compatible code, so this stops reading private lifecycle records written in older shapes and adds no migration. A record Fleet cannot decode now blocks only the claim it is labeled for, plus the asset it fences, instead of every claim on the coordinator. That claim is not allocated, installed, or released through the record, is reported as unreadable, and is not retried until an operator removes the record. The development docs carry the containment rules and the operator steps.
This lands the three commits of #152 from the feature branch, plus one fix found in review: an unreadable custody record for the releasing claim itself was retried forever instead of being reported.
Test plan
🤖 Generated with Claude Code