Skip to content

vm-repair: allow preserving repair resources with --no-cleanup - #10304

Merged
Julie Zhu (yanzhudd) merged 3 commits into
Azure:mainfrom
EdwinBernal1:edwin/vmrepair-no-cleanup
Sep 8, 2026
Merged

Julie Zhu (yanzhudd) merged 3 commits into
Azure:mainfrom
EdwinBernal1:edwin/vmrepair-no-cleanup

Conversation

@EdwinBernal1

@EdwinBernal1 Edwin Bernal Microsoft (EdwinBernal1) commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes
⚠️ None
⚠️Azure CLI Extensions Breaking Change Test
⚠️vm-repair
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd vm repair repair-and-restore cmd vm repair repair-and-restore added parameter no_cleanup
⚠️ 1006 - ParaAdd vm repair repair-button cmd vm repair repair-button added parameter no_cleanup
⚠️ 1006 - ParaAdd vm repair restore cmd vm repair restore added parameter no_cleanup

Add --no-cleanup to restore and automated repair flows, validate conflicting flags, document the behavior, and add regression coverage.

Related command

az vm repair restore
az vm repair repair-and-restore
az vm repair repair-button

Summary

Adds --no-cleanup with the --no alias so unattended VM repair workflows can preserve repair resources for inspection instead of deleting them.

Description

Previously, unattended repair workflows had no way to decline resource cleanup:

  • Omitting --yes could block on an interactive confirmation.
  • Passing --yes deleted the repair VM, copied disk, and repair resource group.
  • Automated and multi-VM workflows could therefore block or lose resources needed for post-repair investigation.

This change introduces --no-cleanup and its --no alias for:

  • az vm repair restore
  • az vm repair repair-and-restore
  • az vm repair repair-button

When enabled:

  • The repaired disk is still restored to the source VM.
  • The repair VM, copied disk, and repair resource group are retained.
  • Cleanup prompts and resource-group deletion are skipped.
  • The command reports which resource group was retained and reminds the user to delete it later to avoid unnecessary costs.
  • Failure cleanup in the automated repair commands also honors the option, allowing failed repairs to be inspected.

For az vm repair restore, --yes and --no-cleanup are mutually exclusive because they request opposite cleanup behavior. Validation fails before network operations when both are provided.

Existing behavior remains unchanged when --no-cleanup is omitted.

Testing

The complete non-live VM Repair test suite was executed on both Windows Python architectures:

Runtime Result
Python 3.12.10, 64-bit 104 passed, 35 skipped
Python 3.14.7, 32-bit 104 passed, 35 skipped

The 35 skipped tests are live-only scenarios that require Azure resources. No live or billable Azure tests were executed.

Test coverage includes:

  • Cleanup is skipped without prompting when --no-cleanup is used.
  • Retained resource groups are identified in user-facing messages.
  • Existing default cleanup behavior remains unchanged.
  • Existing declined-confirmation behavior remains unchanged.
  • --yes and --no-cleanup are rejected when combined.
  • Automated repair flows propagate --no-cleanup.
  • Existing --yes behavior remains unchanged.

Risk assessment

Area Assessment
Scope Limited to VM Repair cleanup behavior
Production impact Opt-in; existing behavior remains unchanged by default
Existing flows Restore and automated repair flows
API compatibility Backward compatible; optional parameters added at the end of function signatures
New dependencies None
Multi-cloud impact None; no endpoints or cloud-specific behavior changed
Resource-cost risk Retained resources can incur costs; commands emit an explicit cleanup reminder
Overall risk Medium Risk 🟡 — touches cleanup behavior, but only changes it when explicitly requested

General Guidelines

  • Have you run azdev style vm-repair locally?
  • Have you run python scripts/ci/test_index.py -q locally?
  • My extension version conforms to the Extension version schema.

Additional information

  • Extension version updated to 2.3.2.
  • Release history updated with the new behavior.
  • Command help includes examples for deleting resources with --yes and preserving them with --no-cleanup.
  • No changes were made to src/index.json; the publication automation will update it after merge.

Add --no-cleanup to restore and automated repair flows, validate conflicting flags, document the behavior, and add regression coverage.
Copilot AI lite review requested due to automatic review settings September 4, 2026 20:20
@azure-client-tools-bot-prd

Copy link
Copy Markdown

Hi Edwin Bernal Microsoft (@EdwinBernal1),
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in pyproject.toml (or setup.py, if the extension has not migrated yet) as well.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new user-facing “delete later” instructions omit --yes/--no-wait, which undermines the intended unattended-safe workflow and should be corrected before merge.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a --no-cleanup switch to vm-repair restore and automated repair flows so callers can preserve the repair resource group (repair VM/disk copy) for later inspection, while keeping existing interactive behavior intact.

Changes:

  • Add --no-cleanup/--no arguments to az vm repair restore, az vm repair repair-and-restore, and az vm repair repair-button, and thread the flag through cleanup logic.
  • Add early validation to reject --yes and --no-cleanup together on az vm repair restore.
  • Document the new behavior and add regression/unit coverage around cleanup skipping and validator behavior.
File summaries
File Description
src/vm-repair/setup.py Bumps extension version to 2.3.0.
src/vm-repair/HISTORY.rst Documents the new --no-cleanup behavior and mutual exclusion with --yes.
src/vm-repair/azext_vm_repair/tests/latest/test_restore_no_cleanup.py Adds unit/regression tests for skip-cleanup and validator mutual exclusion.
src/vm-repair/azext_vm_repair/repair_utils.py Extends _clean_up_resources with skip_cleanup short-circuit and warning.
src/vm-repair/azext_vm_repair/custom.py Plumbs no_cleanup through restore / automated flows and updates success messaging.
src/vm-repair/azext_vm_repair/_validators.py Adds mutual exclusion validation for --yes + --no-cleanup on restore.
src/vm-repair/azext_vm_repair/_params.py Registers the new CLI arguments for the affected commands.
src/vm-repair/azext_vm_repair/_help.py Adds restore examples for --yes and --no-cleanup.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vm-repair/azext_vm_repair/custom.py
Comment thread src/vm-repair/azext_vm_repair/repair_utils.py
@EdwinBernal1 Edwin Bernal Microsoft (EdwinBernal1) changed the title feat(vm-repair): allow preserving repair resources vm-repair: allow preserving repair resources with --no-cleanup Sep 4, 2026
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@yonzhan

Copy link
Copy Markdown
Collaborator

vm-repair

@yanzhudd

Copy link
Copy Markdown
Contributor

please resolve the code conflicts

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@yanzhudd
Julie Zhu (yanzhudd) merged commit ce69dcc into Azure:main Sep 8, 2026
24 checks passed
@azclibot

Copy link
Copy Markdown
Collaborator

[Release] Update index.json for extension [ vm-repair-2.3.2 ] : https://dev.azure.com/msazure/One/_build/results?buildId=180062922&view=results

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.

6 participants