Skip to content

fix(admission): Keep Machine power to the power projector - #224

Merged
scotwells merged 4 commits into
feat/manual-inventory-recordsfrom
fix/machine-power-status-writer
Nov 29, 2026
Merged

scotwells merged 4 commits into
feat/manual-inventory-recordsfrom
fix/machine-power-status-writer

Conversation

@scotwells

@scotwells scotwells commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #182. Only the power projector may change a Machine’s observed status.power. Milo authorizes status writes through Machine update and patch permissions, which consumer roles hold, so RBAC alone cannot enforce this restriction. This PR adds a fail-closed admission webhook in the Milo root and an equivalent admission policy in standalone.

Rollout and scope

Verification

  • Build, unit, race, envtest, render, and harness checks pass.
  • Real API-server tests verify that the webhook and standalone policy reject power changes by update and patch from nine other identities and allow the projector’s writes. The tests fail if either guard is weakened or removed.
  • The render check covers every root and fails if another role gains Machine status access.

🤖 Generated with Claude Code

@scotwells
scotwells requested review from ecv and kevwilliams November 26, 2026 03:47
scotwells and others added 3 commits November 25, 2026 21:47
Nothing but convention stopped another identity from writing a Machine's
status.power. In Milo, a status write is authorized with the Machine's
update and patch permissions, which the consumer roles hold, and the
manager's other status writers share the projector's identity, so RBAC
cannot hold the field to one writer.

Add a fail-closed webhook, served by fleet-registration, that admits a
change to status.power only from the identity named by its new
--machine-power-writer flag; unset, every power change is refused. Only
status writes that change power are routed. config/milo installs it, and
config/standalone enforces the same rule with a ValidatingAdmissionPolicy
admitting only the smoke runner, which runs the projector there.

A render check over every root fails when another Kubernetes role gains
Machine status writes or another Milo role gains a Machine status, update
or patch permission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nder check

Name the webhook under the Machine's own API group, and add it and its
writer flag to the registration rollout contract. The render check now
reads roles held in JSON strings and treats an aggregated ClusterRole as a
Machine status writer. Move the writer audit into the device custody guide
and drop deployment state from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scotwells
scotwells force-pushed the fix/machine-power-status-writer branch from 124982e to 0b4c1d7 Compare November 26, 2026 03:47
Base automatically changed from feat/device-custody-cutover to feat/manual-inventory-records November 28, 2026 14:54
@scotwells
scotwells marked this pull request as ready for review November 29, 2026 17:37
@scotwells
scotwells requested a review from a team as a code owner November 29, 2026 17:37
@scotwells
scotwells removed the request for review from a team November 29, 2026 17:37

@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.

The handler admits a machines/status UPDATE that leaves status.power unchanged, and a change only from --machine-power-writer. Unset, it refuses every change. It reads power from the raw JSON with exact keys, so a case-folded or duplicate key cannot slip a value past it. The webhook routes only status writes that change power and is fail-closed. The standalone ValidatingAdmissionPolicy applies the same rule. The Machine CRD declares subresources: {status: {}}, so a main-resource update cannot carry a power change around the guard. The envtest drives update and patch from nine other identities against both guards, and the render test fails if any role other than the controller gains Machine status writes.

  • Fail-closed with an empty writer by default means the projector's first power write is refused in any Milo root that has not set --machine-power-writer. The rollout note says to set it before enabling the projector. Make sure the deploying repository's registration overlay sets it in the same change that enables the projector.
  • Other Machine status fields stay writable by consumer roles until Milo enables subresource authorization. The PR says so; that is the larger gap.

Follow-ups:

  • Track the Milo work the PR names (subresource authorization, the Machine ProtectedResource declaring its status subresource, controller-only machines/status update and patch) as an issue, so the remaining status fields are not forgotten.

@scotwells
scotwells merged commit fd0f33f into feat/manual-inventory-records Nov 29, 2026
15 checks passed
@scotwells
scotwells deleted the fix/machine-power-status-writer branch November 29, 2026 18:16
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