Repository navigation
fix(server): a power-off is never deferred by a pending ISO import, and withdraws a deferred power-on - #37
Conversation
Every power action was deferred while the importing label was on the VM, including ForceOff and GracefulShutdown. When an import could not finish (the VM held the ISO volume, or the helper pod never ran) the label stayed and Ironic's power-off was deferred as well, so the host could not be recovered through Redfish. Only an action that starts the VM (On, ForceRestart, GracefulRestart) now waits for the import. A power-off runs immediately and withdraws a deferred power-on: the host was told to be off, so it must not start when the import completes. Signed-off-by: itayherzberg <itayherzberg@gmail.com>
|
Hi @itayherzberg. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MarSik The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Problem
While a virtual media import is in progress (
importing.redfish/<device>label on the VM) everyComputerSystem.Resetis deferred,ForceOffandGracefulShutdownincluded:Two consequences:
202, and the VM keeps running. The host cannot be recovered through its BMC, only by stopping the VM by hand.ForceOff, the VM is left as it is, and whatever was recorded last runs when the import ends. Ironic asked for the host to be off; a host that starts on its own afterwards is a surprise.Cause
handlePowerActionasksIsImportInProgressand, if true, records the reset type inpower-after-import.redfishand answers202for any reset type. The deferral exists so that a VM is not started before its CD-ROM has an image; stopping a VM has nothing to wait for.Fix
On,ForceRestart,GracefulRestart(powerStateStartsVM). Everything else runs immediately.ClearPowerAfterImportLabel, a new metadata-only patch next toSetPowerAfterImportLabel). The withdrawal comes before the stop: if it failed afterwards the VM would still start when the import ends, which is the worse outcome. A failed withdrawal is a500; the deferred command is then still recorded and nothing has changed.PauseandResumealso run immediately; they act on a running VMI and have nothing to do with the import.Behaviour changes:
ForceOffandGracefulShutdownare never deferred; while an import is pending they answer200and remove apower-after-import.redfishlabel (logged asWithdrew deferred power command On from VM ...).On/ForceRestart/GracefulRestartare deferred as before.Verification on the cluster
OpenShift 4.22 / OpenShift Virtualization 4.22, the bridge built from fork
mainwith #36 and this branch, an ISO served from an in-cluster nginx rate-limited to 1.5 MB/s (about 60 s per import). Against a halted VM:InsertMedia, thenOnonce the importing label is on the VM, thenForceOff:Bridge log:
No
executed deferred power commandline followed the label removal; the VM stayed halted with the finished ISO in its CD-ROM.Tests
pkg/server/power_off_while_importing_test.go, with a halted VM that carries the importing label:On,ForceRestartandGracefulRestartanswer202deferred and record themselves;ForceOffandGracefulShutdownanswer200, record nothing and leave the VM halted; after a deferredOn, aForceOfforGracefulShutdownremovespower-after-import.redfishand leaves the importing label alone. On currentmainboth tests fail withForceOff: status 202 ... "Power action ForceOff deferred until ISO import completes".pkg/kubevirt/power_after_import_test.go:ClearPowerAfterImportLabelremoves only that label, is a no-op without it, and errors on a missing VM.go build ./...,go vet ./...,go test ./...,gofmt,go mod tidy(no change) pass.Related
InsertMediais answered, so the deferral starts earlier; this PR decides which actions the deferral applies to. Independent hunks; a tree with both merges cleanly, and the run above used one.