Repository navigation
feat(allocation): Power a Machine's server from its powerState - #203
Conversation
77770f1 to
a95a293
Compare
2509ab0 to
e8c60a2
Compare
a95a293 to
38d73b3
Compare
27371dc to
037b93d
Compare
38d73b3 to
acdab22
Compare
037b93d to
a1d32d7
Compare
acdab22 to
7bd9f3f
Compare
a1d32d7 to
c760beb
Compare
7bd9f3f to
32d8ced
Compare
c760beb to
ad41d35
Compare
ecv
left a comment
There was a problem hiding this comment.
Approve.
Safe as written because nothing in the tree calls Allocator.Power outside tests, and its guards hold when something does: ownership is checked in the allocator, then holder and allocation again by custody. Wiring it to the Machine controller is a separate step, and its ownership inputs need a review of their own.
- Cross-tenant:
Allocator.Powerrefuses (ErrConflict) unless the Machine's UID, namespace and name, the allocation name,ConsumerRef,MachineRefand both UID labels all match the owner.only the Machine that owns the allocation can request its powerruns eight cases, each differing in one field, and asserts that noDevicePowerOperationwas created. This is the negative cross-tenant test. - Released allocation: any phase other than Active returns ErrReleased. Custody backs that up: the provider row admits only holder Allocation, and a pending operation is cancelled with HolderMismatch once the holder becomes Release (
coordinator.go, preconditions 2 and 3). - Staff hold, commissioning, cleaning: the holder is then Service or Release, so the provider row never matches. A recovery hold queues provider power until staff apply a Retry, and the retry repeats only the held action (
a power hold reports Unknown...,after a Retry the provider repeats the held action, and only that action). - Power is not forced from an unknown state: nothing is created while observed power is missing or Unknown, and Off maps to ForceOff only once On or Off is observed.
Follow-ups:
- No test calls
Powerwith a Releasing or Released allocation. Add one, so the first line's phase check has a guard of its own and does not rest only on custody. - The caller must build
ownerfrom the authenticated consumer project, not from the Machine's own fields.Powerchecks thatownermatches the allocation and Machine, but a caller that fillsownerfrom the same Machine would pass. Pin that when the controller wiring lands. - A customer's Off is a ForceOff, a hard cut with no guest shutdown. That follows #173, but customer docs should say so.
kevwilliams
left a comment
There was a problem hiding this comment.
Hold: customer power can force-off a freshly installed server, and never re-converges within one Machine generation.
- powerState defaults to Off and an install ends with the server On, so once discovery reads On, Power issues ForceOff, possibly mid first boot. Nothing sets the desired state On after an install. Default to unset, or treat a completed install as satisfying On.
- The operation name is (allocation, generation), so after it succeeds an OS shutdown or staff power-off leaves spec On and status Off forever unless the field is toggled twice. Re-issue when observed differs and no operation for this generation is pending, or document it.
- Add tests for both.
32d8ced to
c4fc2ce
Compare
ad41d35 to
a9e58e5
Compare
kevwilliams
left a comment
There was a problem hiding this comment.
Hold: the rebase leaves both power issues in place, and standalone-smoke now fails in the synthetic lifecycle.
- internal/allocation/power.go is unchanged: the default Off still force-offs a freshly installed server, and an operation named by (allocation, generation) still never re-converges after an OS or staff power-off.
- Fix those two, and check whether the smoke failure comes from the Off default powering off a just-installed synthetic server.
c4fc2ce to
9f489d5
Compare
a9e58e5 to
8fbb0b5
Compare
ecv
left a comment
There was a problem hiding this comment.
Request changes.
The simulator and fixture deltas are correct, but kevwilliams's first hold is still open at this head: nothing in the request path changed, so the default-Off hazard he named remains.
- Agree with kevwilliams:
Machine.spec.powerStatedefaults toOffin the Metal CRD (config/base/crd/metal.datumapis.com.yaml:262), an install ends with the serverOn, andinternal/allocation/power.gois unchanged since his review, so once the projector observesOn,Powercreates aForceOff. The doc says no running provider calls this yet, so nothing is broken today, but wiring it is the stated next step and opens a force-off of every freshly installed customer server. Default to unset (no request) or treat a completed install as satisfyingOn, and add a test. - kevwilliams's second point (no re-convergence within one generation) is addressed by documenting it, in the
Powercomment and the Customer power table, which his review allowed. Fine as is. - His smoke-failure remark:
standalone-smokepasses at this head, so it is resolved. The acceptance runs are still pending. - Resume is correct. The reset step journals the pre-command read and send time under the operation key and fence. A resumed run, finished or not, reports the journaled values, sends nothing, and proves a restart against the journaled send time, so a server already on cannot be mistaken for "needed no command".
TestAResumedRunReportsTheJournaledCommandcovers unfinished power-on, unfinished restart and finished restart. - A failed observe can no longer report a stale
Onthat admits something:DiscoverPowerskips the write for that Device, so its inventoryobservedAtstops advancing and admission hitsDiscoveryNotCurrentafter twice the interval. Power settle also needs a read after the operation ended, which a skipped write cannot provide. The test checks both the unreadable and readable cases.
Follow-ups:
- A failed observe also skips the
IdentityMatchedcondition update for that Device, so a changed enrollment is not reflected until the next good read. Acceptable for a simulator.
ab6f505 to
7138838
Compare
|
The hold is resolved at 7138838 by removing the default, so a freshly installed server is never forced off.
All checks are green on this head, and the multi-plane acceptance run is in progress. |
ecv
left a comment
There was a problem hiding this comment.
Approve.
The delta since my hold (7138838) closes it: Machine.spec.powerState no longer defaults to Off, and an unset value leaves the Machine's power unmanaged, so a freshly installed server that discovery reads as on gets no operation. A Machine that asks for Off or On still converges once observed power differs. The new envtest walks the exact case from the hold (install, server on, discovery reads it, nothing created) and then shows asking for Off yields one ForceOff. The synthetic provider and standalone runner accept unset or Off and still refuse On, and the consumer UI no longer writes Off on create.
Follow-ups:
- Machines already stored with the old
Offdefault keep it, so once a provider is wired, any of those whose server is on gets forced off. ClearpowerStateon existing Machines, or confirm none outside synthetic staging carry it, before the provider is enabled.
9f489d5 to
4f64ad7
Compare
7138838 to
ab46cfe
Compare
Customer power needs a site that can run it without a BMC. The simulator site now registers a power worker for its simulated servers. Like the Redfish worker, it reads the server's power before it sends anything, sends at most one reset through the journal, and reports Succeeded only for the state it then reads. A restart is proven only by the server's reset time moving to the command. A test-only fault makes a server ignore resets, so the operation ends unknown. The reset step journals the read before the command and the send time, so a run resumed after a crash, finished or not, reports both, sends nothing again, and proves a restart against the journaled send time. The simulator's fixture discovery reports each server's power and offers every power action. Fixture discovery without an observer, as synthetic staging runs it, still reports power off and no reset types. A server the observer cannot read keeps its last discovery, so a running server is never reported off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Metal provider asks the allocator to apply a Machine's power intent. On is the action On and Off is ForceOff, named from the allocation and the Machine generation, so a refused request is not created again until the generation changes. A request is due when powerState differs from the Machine's observed power, or when this allocation's request for another action has not run yet, so the newer request replaces it. Observed power must be On or Off: every Machine defaults to Off, so power not yet observed, or Unknown, asks for nothing. During a power hold, nothing is created until staff apply a Retry; then the provider repeats the held operation under the foundation's retry name, and only while powerState still maps to the held action. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Discovery reads each server about hourly, so after a power change it reports the old state for a while. The power projector, still the only writer of Machine power, now reports the newer of discovery's state and the state custody's last succeeded power operation proved, a tie going to the operation. When any other operation except a recovery finished at or after discovery's read, power is Unknown until discovery reads it again, because that operation may have changed it. Power stays Unknown during any hold. The standalone smoke commissions the server just before it allocates, so it now waits for discovery to read the server after commissioning before it checks the Machine's power. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The customer power flow runs against a real API server with the coordinator, delivery and the simulator site behind its site API: - power under an allocation, and unknown after a later installation; - a change waiting behind an installation; - a newer request replacing a pending one, including an intent that returns to the observed state; - a hold reporting Unknown through release and settling with fresh discovery; - a retry that repeats only the held action; - a request waiting through a discovery lapse, sending nothing, and running once discovery returns. The allocator gets a capacity evaluator that offers every fixture server, since these tests cover power, not commissioning. The custody guide records customer power and two remaining gaps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Machine.spec.powerState defaulted to Off, and an install leaves the server on. Once a provider asked for power, the first discovery read after an install would have forced every freshly installed server off. powerState now has no default. Unset means Fleet does not manage the Machine's power: no power operation is created, whatever the server's state. A Machine that asks for Off or On still gets ForceOff or On when its observed power differs. A request created before powerState was cleared still runs, and Machines already stored with Off keep it. The synthetic provider and the standalone runner accept a claim whose power is unset or Off, and still refuse On. Fixtures that are not about power leave it unset, so they take that path. The consumer UI no longer creates Machines with power Off, and shows no requested power for an unmanaged Machine. Tests cover an unmanaged Machine after an install with its server on, which creates nothing until it asks for Off and then gets ForceOff; unset, Off and On claims through the synthetic provider; the standalone runner's fixture check; and the UI's create payload and power intent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4f64ad7 to
66a9d31
Compare
ab46cfe to
0205906
Compare
Related to #173. Stacked on #190.
The Metal provider can now turn a Machine's requested power into a power operation on its server, and the Machine reports the power that operation proved.
powerStateno longer defaults to Off: left unset, Fleet does not manage that Machine's power and creates no operation, so a freshly installed server that boots on is never forced off. No running provider asks for power yet, so no customer server changes power until one does.Three things change on merge, in every root that ships the Metal CRD:
powerStatekeep it unset, and the consumer UI no longer sets it. Machines already stored with Off keep it and stay managed. The synthetic provider and the standalone runner accept unset or Off, and still refuse On.Test plan
powerStateA Machine generation runs at most one power operation, so power that drifts after it succeeded is not corrected until the generation changes.
🤖 Generated with Claude Code