Skip to content

[KT] Fix VM ssh auth and CentOS7 content-release - #82

Open
PlaidCat wants to merge 4 commits into
mainlinefrom
{jmaple}_centos7_content_release
Open

[KT] Fix VM ssh auth and CentOS7 content-release#82
PlaidCat wants to merge 4 commits into
mainlinefrom
{jmaple}_centos7_content_release

Conversation

@PlaidCat

@PlaidCat PlaidCat commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

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.

(.venv) [jmaple@devbox kernel-src-tree]$ kt checkout --cleanup cbr-7.9 && kt checkout cbr-7.9 && kt vm --destroy cbr-7.9 && kt vm cbr-7.9 -c && sleep 60  && virsh start cbr-7.9 && sleep 300 &&  kt content-release cbr-7.9 | tee cbr-7.9_content_release.log

V2

Addressed feed back and had claude restructure the commits to force push

Coverage Report

Name Stmts Miss Branch BrPart Cover Missing
check_fips_changes.py 42 42 12 0 0% 8-67
check_kernel_commits.py 179 179 76 0 0% 3-371
ciq-cherry-pick.py 190 190 50 0 0% 1-426
ciq-tag.py 146 146 16 0 0% 3-378
ciq_tag.py 232 232 54 0 0% 1-464
jira_pr_check.py 180 180 80 0 0% 3-381
kt/ktlib/command_runner.py 33 20 6 0 33% 16, 20-33, 37-61, 65-66
kt/ktlib/config.py 54 0 12 0 100%
kt/ktlib/kernel_workspace.py 111 77 18 0 26% 22-35, 49-66, 73-76, 80-91, 94-100, 113-124, 135-145, 162-165, 169-202, 210-213, 216-220
kt/ktlib/kernels.py 85 13 14 1 84% 57-65, 119, 135-142
kt/ktlib/local.py 5 1 0 0 80% 12
kt/ktlib/repo.py 29 15 2 0 45% 30-31, 34-35, 43-55
kt/ktlib/ssh.py 12 5 2 0 50% 9-12, 16
kt/ktlib/util.py 17 0 0 0 100%
kt/ktlib/virt.py 80 39 10 0 46% 26, 34-37, 51-78, 82-88, 92-93, 97, 101, 105, 109, 119-127, 133-138, 142-147
kt/ktlib/vm.py 302 152 52 4 47% 127-144, 177-186, 194-205, 234-238, 253->264, 281->287, 292-302, 305-306, 319-323, 326, 329-345, 350-367, 370-377, 386-392, 400-405, 426-437, 440-441, 444, 448-453, 465-478, 491-498, 507, 516-528, 531-538, 541-550, 553
release_config.py 2 2 0 0 0% 7-27
rolling-release-update.py 264 264 106 0 0% 1-412
run_interdiff.py 165 165 56 0 0% 3-244
update_lt_spec.py 219 219 46 0 0% 9-411
TOTAL 2347 1941 612 5 15%

@PlaidCat PlaidCat self-assigned this Aug 7, 2026
Copilot AI lite review requested due to automatic review settings August 7, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 domifaddr until 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_ssh is 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.

Comment thread kt/ktlib/vm.py Outdated
Comment thread kt/ktlib/vm.py
Comment thread kt/commands/content_release/impl.py Outdated
Comment thread kt/commands/content_release/impl.py Outdated
Comment thread kt/commands/vm/impl.py Outdated
Comment thread kt/commands/vm/impl.py Outdated
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.
Copilot AI review requested due to automatic review settings August 7, 2026 22:17
@PlaidCat
PlaidCat force-pushed the {jmaple}_centos7_content_release branch from 3d51a33 to df9940a Compare August 7, 2026 22:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-checking cloud-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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants