Skip to content

Controller · manager

HostOperation controller

The HostOperation controller is the executor. It runs the steps of an approved HostOperation against the BMC, the Talos API and the Kubernetes API of the node. It is the only controller that changes a machine after a person approved it.

Reconciles
HostOperation (For). Controller name hostoperation.
Workers
4 passes at the same time, each on another Host and another BMC.
Writes
The operation status: Approved, Executed, baseline, steps, phase. It never writes the spec.
Talks to
The BMC (write session), the Talos API of the node, the Kubernetes API of the workload cluster, and the media service.
Pass budget
1 minute. 15 minutes with flashFirmware or stageFirmware. 35 minutes with talosUpgrade.
Requeue
5 seconds for a waiting step. 30 seconds while a guard holds. The next window opening while a window holds.
Source
hostoperation_controller.go
Kind Relation Why a change starts a pass
HostOperation For A person approved, aborted or annotated the operation.
HostOperation Watches, the other operations on the same Host A predecessor finished. The next one in the queue can start.
Host Watches, index .spec.hostRef.name The Host appeared, its paths changed, or maintenance ended.

Step through the figure, or use the arrow keys.

The executor: start gates and step loop

1 / 18

Nine start gates in a row, then the baseline, then a loop of four boxes: next step, cluster guard, run step and record. A pass leaves the loop to wait, to fail or to succeed.Start gates, in orderAbortasked?ApprovalapprovedByRolloutplanHashActionsall knownQueueone per hostLockshost, BMCMaint.annotationWindowopen?Guardsself, clusterStep loopRecordstatus.stepsNext stepabort? budget?Baselinebefore the first writeFailedStepFailed, no retryRun stepgoal met? actCluster guarddisruptive stepsSucceededExecuted=TrueWaitrequeue: settle, check-in, heldnone lefterrorwaitingheld

Read

A pass starts when the operation, a sibling operation or its Host changes. A finished operation only waits for its TTL.

kubectl get hostoperations -A
  1. Read. A pass starts when the operation, a sibling operation or its Host changes. A finished operation only waits for its TTL.

    kubectl get hostoperations -A
  2. Abort. If a person asked for an abort and the operation has no baseline, it ends at once. Nothing touched the machine.

    pk-metal abort <operation>
  3. Approval. If approval is required and approvedBy is empty, the pass stops. Approved is False with the reason AwaitingApproval.

    pk-metal approve <operation>
  4. Rollout. An operation that names a rollout starts only while the rollout approval covers its plan hash, node, host and actions. If not, it fails.

  5. Known actions. If this operator version does not run one of the actions, the operation fails before it starts.

  6. Queue. Only one operation runs on a Host. A started one goes first, then the oldest. The others wait with OperationQueued.

  7. Locks. A pass takes a lock on the Host and on each BMC of the Host. If a lock is busy, the pass comes back later. It changed nothing.

  8. Maintenance. If the Host has the maintenance annotation, an operation that did not start waits with HostInMaintenance.

    kubectl annotate host <host> metal.platform-kit.org/maintenance-
  9. Window. If a MaintenanceWindow covers the Host and no window is open, the operation waits until the next one opens. An install does not wait.

  10. Guards. A disruptive operation asks the self guard and the cluster guard. If either one holds it, it waits with SelfDisruption or ClusterDisruption.

  11. Baseline. The executor checks the queue again against the API server. It reads the BMC and writes the baseline before the first change to the machine.

  12. Next step. The pass continues after the last recorded step. Before each step it checks for an abort and for enough time left in the pass budget.

  13. Cluster guard. A step that takes a control plane down asks the cluster guard again, right before it acts. A drain before it can take a long time.

  14. Run step. The step first compares its goal with the machine. An image that is already inserted, or a power state already reached, is success.

  15. Record. The executor adds the step to status.steps and writes the status before the next step. A pass that stops continues from this record.

  16. Wait. A step that waits for the world, or a guard that holds, ends the pass. The next pass comes after the wait interval, 5 seconds by default.

  17. Failed. A step that fails ends the operation. Executed is False with StepFailed. The executor never retries. A person retries or deletes it.

    pk-metal retry <operation>
  18. Succeeded. When no step is left, the executor reads the reset time once more and sets Executed to True. The TTL then deletes the operation.

  1. Read the operation. If it is deleted, revoke its media grants and stop. If it finished, delete it when its TTL ends. A failed operation never expires.
  2. If a person asked for an abort before the start, end the operation with Aborted. Nothing touched the machine.
  3. If the operation needs approval and spec.approval.approvedBy is empty, set Approved to False with AwaitingApproval and stop.
  4. If the operation names a rollout, check that the approved plan of the TalosRollout covers it. If not, fail with RolloutRefused.
  5. If an action is not known to this operator version, fail the operation before it starts.
  6. If another operation holds the Host, wait with OperationQueued.
  7. Take the locks on the Host and on each BMC of the Host. If one is busy, try again after 5 seconds.
  8. Before the start only: hold for maintenance, for a closed maintenance window, and for the self guard.
  9. Start: check the queue against the API server, read the BMC baseline, and ask the self guard and the cluster guard again. Write the baseline last.
  10. Run the steps from the last recorded step. Before each step, check for an abort, the pass budget and, for a disruptive step, the cluster guard.
  11. Record each step in status.steps and write the status before the next step.
  12. After the last step, read the reset time again and set Executed to True with StepsSucceeded.
Approval is admission
The executor only reads the approval. The admission policy checks who approved. The executor RBAC has no patch on operations, so it cannot approve.
One operation per Host
A started operation goes first, then the oldest. The executor checks the queue in the cache, then again against the API server before the start.
Resumable steps
Each step compares its goal with the world before it acts. A pass that stops halfway re-enters the step safely.
No retry
A step that fails ends the operation for good. A person reads why, then uses pk-metal retry or deletes it.
A network error is a wait
If the BMC or the cluster API does not answer this pass, the step waits. It does not fail.
Running work finishes
Maintenance, a closed window and the self guard hold only an operation that did not start. Stopping between a mount and its boot leaves the machine worse off.
Abort undoes what it can
An abort between steps ejects media that a step mounted and clears a boot override. It uncordons a node that this operation cordoned. A reboot or a removed etcd member stays.
Media grants
For a config medium or an embedded installer, the executor issues a grant on the media service. The grant checks the digest that the person approved. It ends with the operation.
Step Wait limit
PowerCycle, PowerOff and the other BMC steps that wait 5 minutes. A graceful power-off adds its graceful window.
AwaitCheckIn timeoutSeconds, default 30 minutes (--checkin-timeout for a boot)
Drain timeoutSeconds, default 900 seconds
WaitNodeReady timeoutSeconds, default 1800 seconds
WaitEtcdHealthy timeoutSeconds, default 900 seconds
TalosUpgrade 45 minutes
TalosReboot, TalosShutdown, TalosReset, TalosApplyConfig 20 minutes
Object or field When Field manager
Operation status (Approved, Executed, baseline, steps, observedResetTime, phase) Before the first change, and after each step manager (status update)
Host annotation metal.platform-kit.org/release-power-off Before a boot of a claim starts manager (merge patch)
TalosNode annotation that asks for a check now After a reboot step manager (patch)
Delete of the operation TTL ended after success manager
Events StepFailed, StepsSucceeded, Aborted On each outcome pk-metal event source
Condition Status Reasons
Approved True Approved, ApprovalNotRequired
Approved False AwaitingApproval
Executed Unknown Executing, OperationQueued, HostNotFound, HostInMaintenance, OutsideMaintenanceWindow, SelfDisruption, ClusterDisruption, NoReachablePath
Executed False StepFailed, RolloutRefused, HostNotClaimed, Aborted
Executed True StepsSucceeded

An Unknown reason other than Executing is the blockedOn of the operation. The phase stays Proposed while it holds.

You see Cause Do this
Phase Failed, StepFailed A step failed or its wait ran out. Use Operation failed.
Waits with OutsideMaintenanceWindow A window covers the Host and is closed. Wait, or set metal.platform-kit.org/ignore-window. See MaintenanceWindow controller.
Waits with ClusterDisruption Etcd would not stay healthy. Use etcd unhealthy or quorum lost.
Waits with OperationQueued Another operation holds the Host. Approve or delete that one first. See Approve, hold, retry and abort.
API groupResourcesVerbsScopeMarker in
metal.platform-kit.orghostoperationsgetlistwatchdeleteclusterhostoperation_controller.go
metal.platform-kit.orghostoperations/statusupdateclusterhostoperation_controller.go
metal.platform-kit.orghostsgetlistwatchpatchclusterhostoperation_controller.go
metal.platform-kit.orghostclaimsgetclusterhostoperation_controller.go
metal.platform-kit.orgmanagementendpointsgetlistwatchclusterhostoperation_controller.go
metal.platform-kit.orgbiossettingsgetlistwatchclusterhostoperation_controller.go
os.platform-kit.orgbootassetstalosnodestalosclustersgetlistwatchclusterhostoperation_controller.go
coresecretsgetlistwatchnamespace pk-metalhostoperation_controller.go
coreconfigmapsgetlistwatchnamespace pk-metalhostoperation_controller.go
events.k8s.ioeventscreatepatchclusterhostoperation_controller.go
os.platform-kit.orgtalosrolloutsgetlistwatchclusterhostoperation_rollout.go
os.platform-kit.orgtalosnodesgetlistwatchpatchclusterhostoperation_reinstall.go
os.platform-kit.orgtalosclusterstalosnodesetcdsnapshotsgetlistwatchclusterhostoperation_etcdrecover.go
metal.platform-kit.orgmaintenancewindowsgetlistwatchclusterwindow.go
metal.platform-kit.orgmaintenancewindows/statusupdateclusterwindow.go

The maintenancewindows/status row belongs to the MaintenanceWindow controller, whose markers are in the same file.

Protocol model explains the model test.