Skip to content

vm-repair: select a compatible repair VM disk controller - #10305

Merged
Julie Zhu (yanzhudd) merged 4 commits into
Azure:mainfrom
EdwinBernal1:edwin/vmrepair-disk-controller-type
Sep 7, 2026
Merged

vm-repair: select a compatible repair VM disk controller#10305
Julie Zhu (yanzhudd) merged 4 commits into
Azure:mainfrom
EdwinBernal1:edwin/vmrepair-disk-controller-type

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 create cmd vm repair create added parameter disk_controller_type

Summary

Select a compatible disk controller for VM Repair creation so repair scripts that expect SCSI-attached disks can reliably locate and repair the copied OS disk.

Related command

az vm repair create

Description

Problem

When the source VM uses NVMe, a repair VM size that supports both SCSI and NVMe can inherit an NVMe controller. Several repair scripts locate the attached OS disk by its SCSI model name; on an NVMe repair VM they can complete without repairing the intended disk.

Changes

  • Read the source VM disk-controller type, with an Azure CLI query fallback when the SDK model does not expose it.
  • Query the selected VM SKU DiskControllerTypes capability.
  • Pin the repair VM to SCSI when an NVMe source uses a size supporting both SCSI and NVMe.
  • Warn when the selected size supports only NVMe.
  • Add --disk-controller-type {SCSI,NVMe} as an explicit override.
  • Normalize the override case-insensitively and reject invalid values before network calls.
  • Add focused controller-selection and validation tests.
  • Bump VM Repair from 2.2.6 to 2.3.1 and add release history.

Design rationale

The automatic behavior changes only the problematic NVMe-source path. Existing SCSI-source behavior remains unchanged. An explicit override always wins, while unavailable SKU capability data falls back to the platform default rather than blocking repair creation.

Testing details

  • Focused disk-controller tests: 11 passed, exit code 0, isolated 64-bit Python 3.12.
  • python scripts/ci/test_index.py -q: 9 run, 7 passed, 2 skipped, exit code 0.
  • No live Azure tests were run; no Azure resources were created.
  • azdev style vm-repair was attempted in isolation. Flake8 passed, but Pylint could not resolve standard-library modules such as os, json, and datetime, indicating an isolated-environment configuration failure.

Risk assessment

Area Assessment
Overall Medium Risk 🟡
Scope Narrow; VM Repair creation and related metadata/tests
Production impact Changes controller selection for NVMe source VMs
Existing flows SCSI sources and unknown capabilities retain existing behavior
API/CLI contract Adds one optional parameter; no existing parameter changes
Dependencies None
Multi-cloud impact No hardcoded cloud endpoints

Additional information

The branch contains one focused commit based on current main; unrelated --no-cleanup changes were removed.


General Guidelines

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

src/index.json is intentionally unchanged; publication automation updates it after merge.
'@; gh pr create -R Azure/azure-cli-extensions --base main --head 'EdwinBernal1:edwin/vmrepair-disk-controller-type' --title 'vm-repair: select a compatible repair VM disk controller' --body $body

Detect the source VM and selected SKU disk controller capabilities, prefer SCSI when supported, and allow an explicit controller override.

Add focused tests, help text, release history, and version metadata.
Copilot AI lite review requested due to automatic review settings September 4, 2026 21:18
@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.

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

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 override path currently still performs additional CLI/ARM fetches that can fail or slow execution even when --disk-controller-type is provided, weakening the “override always wins” behavior.

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

Pull request overview

This PR updates the vm-repair extension to more reliably create repair VMs with a disk controller compatible with existing offline repair scripts (especially when the source VM uses NVMe), and introduces an explicit CLI override for controller selection.

Changes:

  • Adds disk-controller detection (SDK with CLI fallback), VM SKU capability lookup, and controller-selection logic to prefer SCSI where supported for NVMe-source scenarios.
  • Introduces --disk-controller-type {SCSI,NVMe} with case-insensitive normalization and early validation.
  • Adds focused unit tests for controller selection, parsing, and validation; bumps extension version and updates release history.
File summaries
File Description
src/vm-repair/setup.py Bumps extension version to 2.3.0.
src/vm-repair/HISTORY.rst Adds 2.3.0 release notes describing the controller-selection behavior and new parameter.
src/vm-repair/azext_vm_repair/tests/latest/test_disk_controller_type.py Adds unit tests covering selection behavior, SKU parsing, and validator normalization/rejection.
src/vm-repair/azext_vm_repair/repair_utils.py Adds helpers to fetch source controller type, fetch SKU controller capabilities, and select the repair controller with messaging.
src/vm-repair/azext_vm_repair/custom.py Integrates controller selection into the nested az vm create invocation.
src/vm-repair/azext_vm_repair/_validators.py Validates/normalizes --disk-controller-type before other network/version checks.
src/vm-repair/azext_vm_repair/_params.py Adds the disk_controller_type argument to vm repair create.
src/vm-repair/azext_vm_repair/_help.py Documents an example using --disk-controller-type NVMe.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 1
  • 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 Outdated
Edwin Bernal added 2 commits September 4, 2026 16:23
Skip source and SKU controller discovery when an explicit override is provided, and query SKU capabilities only for NVMe source VMs.
@yonzhan

Copy link
Copy Markdown
Collaborator

vm-repair

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

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 source disk controller detection currently mishandles SDK Enum values (breaking NVMe detection and the SCSI-pinning path), and the version bump is inconsistent with the PR description.

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

Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment thread src/vm-repair/azext_vm_repair/repair_utils.py
Comment thread src/vm-repair/setup.py
Handle enum-backed disk controller values and incomplete source VM models safely.

Add regression coverage for enum values, missing storage profiles, and missing VM IDs.
@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 ae56128 into Azure:main Sep 7, 2026
24 checks passed
@azclibot

Copy link
Copy Markdown
Collaborator

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants