Skip to content

{Compute} az vmss/vm: Update Open Capacity Reservation validation logic - #34045

Merged
Julie Zhu (yanzhudd) merged 1 commit into
Azure:devfrom
william051200:update-ocr
Sep 9, 2026
Merged

{Compute} az vmss/vm: Update Open Capacity Reservation validation logic#34045
Julie Zhu (yanzhudd) merged 1 commit into
Azure:devfrom
william051200:update-ocr

Conversation

@william051200

@william051200 William (william051200) commented Sep 8, 2026

Copy link
Copy Markdown
Member

🤖 PR Validation — ️✔️ All clear

Breaking Changes Tests
️✔️ None ️✔️ 130/130

Related command

az vm create/update
az vmss create/update

Description

Current validation:
Not allow --capacity-reservation-group + --disable-capacity-reservation-assignment

Change:
Only allow --capacity-reservation-group + --disable-capacity-reservation-assignment False

Testing Guide

History Notes


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

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 updated validation condition makes the existing error type/message misleading and still treats the documented --capacity-reservation-group None disassociation sentinel as conflicting with --disable-capacity-reservation-assignment true.

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

Pull request overview

Updates VM/VMSS argument validation for Open Capacity Reservation so that --capacity-reservation-group is only rejected when combined with --disable-capacity-reservation-assignment true (i.e., the combination is allowed when the disable flag is false).

Changes:

  • Adjusted capacity reservation validation logic to only block the “disable assignment” flag when it is explicitly true.
  • Preserved existing capacity reservation group normalization (name → resource ID) behavior.
File summaries
File Description
src/azure-cli/azure/cli/command_modules/vm/_validators.py Narrows the mutual-exclusion validation between capacity reservation group and disable-assignment to only the true case.
Review details

Suppressed comments (1)

src/azure-cli/azure/cli/command_modules/vm/_validators.py:2836

  • This change alters CLI validation behavior (now allowing --capacity-reservation-group with --disable-capacity-reservation-assignment false). There doesn’t appear to be a test covering the new allowed combination or the still-invalid case (group + disable true), so a regression could slip in unnoticed.
    if getattr(namespace, 'capacity_reservation_group', None) is not None and \
            getattr(namespace, 'disable_capacity_reservation_assignment', None) is True:
        raise MutuallyExclusiveArgumentError(
  • Files reviewed: 1/1 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 on lines 2834 to 2838
if getattr(namespace, 'capacity_reservation_group', None) is not None and \
getattr(namespace, 'disable_capacity_reservation_assignment', None) is not None:
getattr(namespace, 'disable_capacity_reservation_assignment', None) is True:
raise MutuallyExclusiveArgumentError(
"You can only specify one of --capacity-reservation-group and "
"--disable-capacity-reservation-assignment")
@yonzhan

Copy link
Copy Markdown
Collaborator

Compute

@yanzhudd
Julie Zhu (yanzhudd) merged commit b46fcf2 into Azure:dev Sep 9, 2026
52 checks passed
@william051200
William (william051200) deleted the update-ocr branch September 9, 2026 00:39
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