Skip to content

refactor: Stop reading private lifecycle records in older shapes - #176

Merged
scotwells merged 4 commits into
mainfrom
chore/drop-legacy-lifecycle-records
Nov 24, 2026
Merged

scotwells merged 4 commits into
mainfrom
chore/drop-legacy-lifecycle-records

Conversation

@scotwells

@scotwells scotwells commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Build, vet, and the full race-enabled suite with envtest pass on current main plus these commits.
  • New tests break the releasing claim's own custody record, in the coordinator and in synthetic staging, and fail without the fix.
  • CI is green.

🤖 Generated with Claude Code

scotwells and others added 3 commits November 24, 2026 16:55
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)
@scotwells
scotwells requested a review from a team as a code owner November 24, 2026 22:56
@scotwells
scotwells requested review from ecv and kevwilliams November 24, 2026 22:56
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 ecv left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (unreadableCandidate skips it, so the asset stays fenced), a retained Released record keeps its epoch fence, and a record with no label blocks every claim in recordsForClaimScoped, operationsForBinding and release-from-proposed. Nothing in the diff deletes, rewrites or frees an unreadable record.
  • Tamper 1: removing the owner == "" arm of recordMayBelongTo fails TestUndecodableRecordAttribution and TestReleaseFromSelectionAttributesAnUndecodableProposedAsset. Tamper 2: making it return true (block everyone) fails six tests including TestUndecodableAssetRecordBlocksOnlyItsOwnClaim. Tamper 3: making unreadableCandidate always 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 RetainedRequirements marshal tests are deleted and no test pins a retained-requirements digest or record bytes for a MachineProfileSpec. 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, so ErrRecordUnreadable stays detectable. The cross-project release path now reports an unreadable record as pending with ReasonUnreadablePrivateRecord, instead of retrying, and it still releases nothing. Tests cover both.

@scotwells
scotwells merged commit c5d050f into main Nov 24, 2026
6 checks passed
@scotwells
scotwells deleted the chore/drop-legacy-lifecycle-records branch November 24, 2026 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants