A few kt VM tweaks#66
Conversation
There was a problem hiding this comment.
Pull request overview
Adjusts VM provisioning and startup/test sequencing to be more configurable and better aligned with cloud-init completion, supporting Jenkins-driven workflows.
Changes:
- Add
vcpus/memoryparameters through the VM creation path and expose them viakt vm --vcpus/--memory. - Remove host-specific vCPU pinning/placement from the
virt-installinvocation. - Replace fixed “deps install” sleeps with
cloud-init status --waitbefore running tests.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| kt/ktlib/vm.py | Plumbs vCPU/memory sizing parameters into VM create/spin-up flow. |
| kt/ktlib/virt.py | Updates virt-install args to use configurable vCPU/memory and drops cpuset/placement. |
| kt/commands/vm/impl.py | Uses cloud-init completion check before running --test. |
| kt/commands/vm/command.py | Adds CLI flags for vCPU/memory sizing. |
| kt/commands/content_release/impl.py | Switches content release VM dependency wait from sleep to cloud-init wait. |
Comments suppressed due to low confidence (1)
kt/ktlib/vm.py:224
vcpus/memoryare only applied when the VM is created. If the VM already exists (even stopped),spin_up()ignores the requested sizing and just starts the domain, which can make the new CLI flags appear to “do nothing”. Consider either documenting/enforcing that changing sizing requiresoverride=True, or updating the existing domain’s resources before starting it.
def spin_up(self, config: Config, vcpus: int = 12, memory: int = 32768) -> VmInstance:
if not VirtHelper.exists(vm_name=self.name):
logging.info(f"VM {self.name} does not exist, creating from scratch...")
self._create_image(config=config, vcpus=vcpus, memory=memory)
return VmInstance(name=self.name, kernel_workspace=self.kernel_workspace)
logging.info(f"Vm {self.name} already exists")
if VirtHelper.is_running(vm_name=self.name):
logging.info(f"Vm {self.name} is running, nothing to do")
return VmInstance(name=self.name, kernel_workspace=self.kernel_workspace)
logging.info(f"Vm {self.name} is not running, starting it")
VmCommand.start(vm_name=self.name)
time.sleep(Constants.VM_STARTUP_WAIT_SECONDS)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| logging.info("Waiting for the deps to be installed") | ||
| time.sleep(Constants.VM_DEPS_INSTALL_WAIT_SECONDS) | ||
| logging.info("Waiting for cloud-init to finish...") | ||
| SshCommand.run(domain=vm_instance.domain, command=["sudo cloud-init status --wait || true"]) |
| # Wait for dependencies to be installed if VM was just created | ||
| logging.info("Waiting for VM dependencies to be installed...") | ||
| time.sleep(Constants.VM_DEPS_INSTALL_WAIT_SECONDS) | ||
| SshCommand.run(domain=vm_instance.domain, command=["sudo cloud-init status --wait || true"]) |
| # Wait for dependencies to be installed if VM was just created | ||
| logging.info("Waiting for VM dependencies to be installed...") |
|
|
||
| # Setup and spin up the VM (reuses common code from vm command) | ||
| vm_instance = Vm.setup_and_spinup(kernel_workspace_name=kernel_workspace) | ||
|
|
There was a problem hiding this comment.
I haven't landed on the ideal vcpu/memory setup for the content release yet. This PR gets the hooks in place. A future PR will set these values when they've been nailed down.
| @click.option("--vcpus", type=int, default=12, help="Number of virtual CPUs (default: 12)") | ||
| @click.option("--memory", type=int, default=32768, help="Memory in MiB (default: 32768)") |
roxanan1996
left a comment
There was a problem hiding this comment.
Great improvement. The sleep was indeed very annoying.
Can we also remove VM_DEPS_INSTALL_WAIT_SECONDS from util.py? Since it is not used anymore?
aa5f4e1 to
46077fd
Compare
46077fd to
804e598
Compare
Good call. Removed |
Replace fixed sleeps with 'sudo cloud-init status --wait' to wait for cloud-init to finish, rather than hoping a hardcoded timeout is long enough.
Drop the old cpuset/static placement that pinned VMs to specific cores. Defaults to 12 if not specified.
Defaults to 32768 MiB if not specified.
804e598 to
95afb97
Compare
| def spin_up(self, config: Config, vcpus: int = 12, memory: int = 32768) -> VmInstance: | ||
| if not VirtHelper.exists(vm_name=self.name): | ||
| logging.info(f"VM {self.name} does not exist, creating from scratch...") | ||
|
|
||
| self._create_image(config=config) | ||
| self._create_image(config=config, vcpus=vcpus, memory=memory) | ||
| return VmInstance(name=self.name, kernel_workspace=self.kernel_workspace) |
| @click.option("--vcpus", type=int, default=12, help="Number of virtual CPUs (default: 12)") | ||
| @click.option("--memory", type=int, default=32768, help="Memory in MiB (default: 32768)") |
This is very much my alderlake processor in my laptop were core 0-11 are performance cores and the other 8 are efficiency cores |
These came to light as I've been working on getting a kt based content release workflow running on jenkins.
,vcpu.cpuset=0-11,vcpu.placement=staticfrom the vcpu config as that seems very host specific for a general use tool like this.