[KT VM] Make vm boot and check more resilient - #87
Open
PlaidCat wants to merge 1 commit into
Open
Conversation
During Content Release lts-9.2 the VM process was more flakey about its state than during the vm testing for previous updates. This adds a little more failure or state oddities so that it responds better.
PlaidCat
requested review from
bmastbergen,
kerneltoast and
shreeya-patel98
and
a lite review from Copilot
August 26, 2026 17:53
There was a problem hiding this comment.
Pull request overview
Improves robustness of VM boot/cloud-init handling by adding additional wait-and-recover logic when SSH availability is flaky, and extends unit tests to cover reboot/shutoff recovery paths.
Changes:
- Add VM “start if not running” logic to
VmInstance._wait_for_ssh()to better recover when the domain is unexpectedly shut off. - Add reboot recovery handling in
VmInstance.wait_for_cloud_init()including an explicit reboot wait and conditional VM start. - Expand VM-related tests to validate reboot recovery and the new
_wait_for_ssh()start/skip-start behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
kt/ktlib/vm.py |
Adds resilience logic around SSH polling and cloud-init reboot recovery by conditionally starting the VM. |
tests/kt/ktlib/test_vm.py |
Adds new tests covering reboot recovery and _wait_for_ssh() start behavior under different VM running states. |
Suppressed comments (2)
tests/kt/ktlib/test_vm.py:357
- After removing the start() side_effect above, the test name/docstring should describe what is actually being validated (SSH retry after a transient failure), otherwise it’s misleading for future readers.
def test_wait_for_ssh_start_race_then_retry(mock_ssh_run, mock_sleep, mock_is_running, mock_start):
"""_wait_for_ssh swallows RuntimeError from VmCommand.start (race), retries SSH."""
tests/kt/ktlib/test_vm.py:377
- This assertion hard-codes "300s" even though the message is derived from Constants. If VM_POLL_MAX_ATTEMPTS / VM_POLL_INTERVAL_SECONDS changes, the test will fail for the wrong reason. Prefer building the expected seconds from Constants (and escape the IP dots since match uses regex).
with pytest.raises(RuntimeError, match="SSH to testuser@192.168.122.10 not available after 300s"):
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+396
to
+401
| if not VirtHelper.is_running(vm_name=self.name): | ||
| try: | ||
| VmCommand.start(vm_name=self.name) | ||
| except RuntimeError as e: | ||
| logging.warning(f"Failed to start VM {self.name}: {e}") | ||
| pass |
| mock_start.assert_not_called() | ||
|
|
||
|
|
||
| @patch("kt.ktlib.vm.VmCommand.start", side_effect=RuntimeError("Domain is already active")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
During Content Release lts-9.2 the VM process was more flakey about its state than during the vm testing for previous updates. This adds a little more failure or state oddities so that it responds better.
Coverage Report