Skip to content

hyperv: avoid stale VMs in case of VM setup failures#4373

Merged
anirudhrb merged 1 commit intomicrosoft:mainfrom
anirudhrb:hvplat_vm_setup_failures
Mar 30, 2026
Merged

hyperv: avoid stale VMs in case of VM setup failures#4373
anirudhrb merged 1 commit intomicrosoft:mainfrom
anirudhrb:hvplat_vm_setup_failures

Conversation

@anirudhrb
Copy link
Copy Markdown
Collaborator

Description

Failures during initial VM setup steps such as adding NAT mapping, getting IP address, resizing partition, setting up device passthrough etc. would currently result in a stale VM left behind on the host. Catch these failures and clean up the VMs before returning/raising from _deploy_environment().

Related Issue

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Refactoring
  • Documentation update

Checklist

  • Description is filled in above
  • No credentials, secrets, or internal details are included
  • Peer review requested (if not, add required peer reviewers after raising PR)
  • Tests executed and results posted below

Test Validation

Key Test Cases:

Impacted LISA Features:

Tested Azure Marketplace Images:

Test Results

Image VM Size Result
PASSED / FAILED / SKIPPED

@anirudhrb anirudhrb requested a review from SRIKKANTH as a code owner March 21, 2026 05:29
Copilot AI review requested due to automatic review settings March 21, 2026 05:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 improves Hyper-V environment deployment robustness by ensuring partially created VMs are cleaned up when VM setup steps fail, preventing stale VMs from being left on the host.

Changes:

  • Moves device passthrough setup and post-boot configuration steps (IP/NAT mapping, SSH connection info, partition expansion) into a guarded block.
  • On any setup exception, triggers VM cleanup via _delete_node() before re-raising the error.

@anirudhrb anirudhrb force-pushed the hvplat_vm_setup_failures branch from 8a56691 to 9293f96 Compare March 21, 2026 05:43
Failures during initial VM setup steps such as adding NAT mapping,
getting IP address, resizing partition, setting up device passthrough
etc. would currently result in a stale VM left behind on the host. Catch
these failures and clean up the VMs before returning/raising from
_deploy_environment().

Signed-off-by: Anirudh Rayabharam <anrayabh@microsoft.com>
Copilot AI review requested due to automatic review settings March 21, 2026 07:09
@anirudhrb anirudhrb force-pushed the hvplat_vm_setup_failures branch from 9293f96 to 5fd9141 Compare March 21, 2026 07:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 1 out of 1 changed files in this pull request and generated 1 comment.

@anirudhrb anirudhrb requested a review from pupacha March 25, 2026 05:18
@SRIKKANTH
Copy link
Copy Markdown
Collaborator

LGTM

@anirudhrb anirudhrb merged commit 38e2715 into microsoft:main Mar 30, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants