Skip to content

[Compute] Fix #34069: az vm update: Fix conflicting Capacity Reservation state transitions - #34070

Open
WhaleTech (ryo-whaletech) wants to merge 1 commit into
Azure:devfrom
ryo-whaletech:fix/vm-capacity-reservation-transitions
Open

WhaleTech (ryo-whaletech) wants to merge 1 commit into
Azure:devfrom
ryo-whaletech:fix/vm-capacity-reservation-transitions

Conversation

@ryo-whaletech

Copy link
Copy Markdown

Related command

az vm update

Description

Fixes #34069

az vm update starts from the existing VM state before applying command-specific update arguments. When switching Capacity Reservation assignment modes, the persisted opposite state could therefore remain in the outgoing request.

This change removes only the conflicting persisted value:

  • assigning a real Capacity Reservation Group removes disableCapacityReservationAssignment only when its persisted value is true;
  • explicitly setting --disable-capacity-reservation-assignment true removes a persisted Capacity Reservation Group.

Valid persisted or explicit false is preserved. Omitted arguments, unrelated VM updates, the existing "None" Capacity Reservation Group disassociation behavior, and the current same-invocation validation remain unchanged.

The fix is limited to the standalone VM update customization and focused regression tests. Generated AAZ files are unchanged because they correctly serialize the state provided by the update layer.

Testing Guide

Added regression coverage for both conflicting transitions and compatibility coverage for false, omitted arguments, unrelated updates, and the "None" sentinel.

Validation:

  • Regression test reproduced both conflicting transitions against the unmodified upstream implementation.
  • Capacity Reservation transition matrix: 17 cases passed after the fix.
  • test_custom_vm_commands.py: 9 passed.
  • Relevant Capacity Reservation / generic VM update tests: 3 passed, with 1 expected live-only test skipped.
  • azdev style vm: passed.
  • azdev linter vm: passed.
  • git diff --check: passed.

Full upstream CI remains pending on the PR.

History Notes

[Compute] az vm update: Fix conflicting Capacity Reservation state when switching assignment modes


This checklist is used to make sure that common guidelines for a pull request are followed.

@azure-pipelines

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

@microsoft-github-policy-service microsoft-github-policy-service Bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Sep 13, 2026
@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution WhaleTech (@ryo-whaletech)! We will review the pull request and get back to you soon.

@microsoft-github-policy-service microsoft-github-policy-service Bot added the Auto-Assign Auto assign by bot label Sep 13, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added Compute az vm/vmss/image/disk/snapshot act-observability-squad Reservations az reservations labels Sep 13, 2026
@ryo-whaletech
WhaleTech (ryo-whaletech) marked this pull request as ready for review September 14, 2026 00:00
@ryo-whaletech
WhaleTech (ryo-whaletech) requested a review from a team as a code owner September 14, 2026 00:00
Copilot AI lite review requested due to automatic review settings September 14, 2026 00:00
@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.

🟢 Approval recommended

Focused changes have regression coverage with no unresolved blocking issues.

Pull request overview

Fixes conflicting Capacity Reservation state transitions in az vm update by removing stale opposing values while preserving valid states.

Changes:

  • Reconciles Capacity Reservation assignment updates.
  • Adds focused transition and compatibility regression tests.
File summaries
File Description
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py Adds transition, compatibility, and validation coverage.
src/azure-cli/azure/cli/command_modules/vm/custom.py Reconciles persisted Capacity Reservation state.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

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

@yonzhan

Copy link
Copy Markdown
Collaborator

Compute

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

Labels

act-observability-squad Auto-Assign Auto assign by bot Compute az vm/vmss/image/disk/snapshot customer-reported Issues that are reported by GitHub users external to the Azure organization. Reservations az reservations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az vm update retains conflicting Capacity Reservation state when switching assignment modes

4 participants