[KT] Fix VM ssh auth and CentOS7 content-release - #82
Open
PlaidCat wants to merge 4 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the VM tooling to use SSH/user settings from Config (instead of defaulting to $USER) and improves VM readiness behavior to better support CentOS 7 content releases (NFS mountpoint creation, cloud-init reboot handling, and skipping kselftests where unavailable).
Changes:
- Use config-provided SSH username/key when connecting to VMs and add an SSH readiness wait.
- Make VM IP discovery more reliable by polling
virsh domifaddruntil an IPv4 address is found. - Add CentOS 7 cloud-init boot-time mountpoint creation and adjust content-release test logic for CentOS 7 (yum + skip kselftests).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| kt/ktlib/vm.py | Pass Config into VmInstance, build SSH domain from config.user, derive ssh key path, and wait for SSH readiness; CentOS7 cloud-init tweak for NFS mountpoint. |
| kt/ktlib/virt.py | Improve reliability of VM IP address discovery by polling for a valid IPv4 address. |
| kt/ktlib/ssh.py | Allow specifying an SSH key and run SSH in batch mode with explicit options. |
| kt/data/cloud_init_centos7.yaml | Add bootcmd to create the mountpoint before the mounts module runs. |
| kt/commands/vm/impl.py | Handle VM reboot during cloud-init by waiting for SSH to return. |
| kt/commands/content_release/impl.py | Determine yum vs dnf for installs, handle cloud-init reboots, and skip kselftests on CentOS 7. |
Suppressed comments (1)
kt/ktlib/vm.py:394
VmInstance._wait_for_sshis called from other modules; the leading underscore indicates a private API. Expose this as a public method (wait_for_ssh) and update the internal call site accordingly.
self._wait_for_ssh()
def _wait_for_ssh(self):
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
bmastbergen
reviewed
Aug 7, 2026
VmInstance was using os.environ["USER"] instead of config.user and not passing the configured SSH key. Fix SshCommand to properly split -o arguments, add BatchMode=yes to prevent interactive prompts, and pass -i with the private key derived from config.ssh_key. Thread ssh_key through all SshCommand call sites in vm.py, content_release, and vm commands.
VirtHelper.ip_addr() now polls virsh domifaddr with regex-based IP validation instead of blindly parsing output that may contain separator lines before DHCP assigns an address. VmInstance constructor waits for SSH readiness after resolving the IP, preventing "No route to host" errors when the VM network stack isn't fully up yet.
Add bootcmd to cloud_init_centos7.yaml so the NFS mount point exists before cloud-init's mounts module runs. Detect CentOS 7 via os_variant and switch to yum for RPM installation. Handle cloud-init triggered reboots (power_state: reboot) by catching the SSH disconnect and reconnecting. Skip kselftests on CentOS 7 where they are not available.
The cloud-init wait + reboot recovery pattern was duplicated in both content_release and vm command implementations. Extract it into VmInstance.wait_for_cloud_init() and add tests covering the success, reboot-recovery, and error-propagation paths.
PlaidCat
force-pushed
the
{jmaple}_centos7_content_release
branch
from
August 7, 2026 22:17
3d51a33 to
df9940a
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.
Suppressed comments (2)
tests/kt/ktlib/test_vm.py:276
- If
wait_for_cloud_init()is updated to retry the cloud-init status check after a reboot (so it truly waits for completion), this test should assert the additional post-reboot status call (status -> true -> status) rather than only 2 SSH invocations.
def test_wait_for_cloud_init_reboot_recovery(mock_ssh_run, mock_sleep):
"""cloud-init reboots the VM, then SSH comes back."""
mock_ssh_run.side_effect = [
RuntimeError("Connection to 192.168.122.10 closed by remote host."),
None, # _wait_for_ssh -> "true" succeeds
kt/ktlib/vm.py:423
wait_for_cloud_init()claims to block until cloud-init completes, but if the SSH session is dropped due to a reboot it only waits for SSH to return and then exits without re-checkingcloud-init status --wait. That can allow subsequent steps to run while cloud-init is still finishing after reboot. Also the docstring has an extra quote (""" "Wait ...). Consider looping: on "closed by remote host" wait for SSH and then retry the cloud-init status check until it completes.
def wait_for_cloud_init(self):
""" "Wait for cloud-init to finish on the VM. This method will block until cloud-init has completed its tasks."""
try:
SshCommand.run(
domain=self.domain,
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.
In order to do the full content release for CentOS7 the tooling needs to use the SSH details from the configs rather than defaulting to USER. In addition there where VM and SSH readiness improvements. CentOS7 needed some NFS and reliability updates that worked fine for just general vm creation but caused issues during content release. Skip Kselftess for CentOS7.
was used todo current release.
V2
Addressed feed back and had claude restructure the commits to force push
Coverage Report