Skip to content

{Compute} az vmss/vm: Update Open Capacity Reservation validation to support 'None' - #34072

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

Julie Zhu (yanzhudd) merged 1 commit into
Azure:devfrom
william051200:update-ocr-validation

Conversation

@william051200

@william051200 William (william051200) commented Sep 14, 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

Update the command to support None as input, eg:
capacity reservation group is None + disable capacity reservation group is True = Allowed

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 VM update path must omit the capacity reservation group when None is used with disabled assignment.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Updates VM and VMSS capacity reservation validation and payload construction to support None when assignment is disabled.

Changes:

  • Relaxes validation for the None sentinel.
  • Centralizes capacity reservation profile construction.
  • Omits capacity reservation groups when appropriate.
File summaries
File Summary and review findings
src/azure-cli/azure/cli/command_modules/vm/_validators.py Updates validation rules. Missing command-level regression coverage (nit, 1 vote). VM update still emits an empty capacity reservation group for None with disabled assignment (moderate, 1 vote).
src/azure-cli/azure/cli/command_modules/vm/_template_builder.py Adds shared profile construction. Missing focused unit coverage for sentinel, boolean, and omitted-value cases (nit, 3 votes).
Review details

Suppressed comments (2)

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

  • This changes the acceptance rule for all four create/update commands, but the repository has no regression test for the newly allowed combination (--capacity-reservation-group None with --disable-capacity-reservation-assignment true) or for rejecting a real group with the flag. The existing open-capacity scenario only exercises the flag without the group. Please add command-level coverage for both the accepted sentinel case and the still-invalid real-group case.
    if (namespace.disable_capacity_reservation_assignment is True and
            namespace.capacity_reservation_group is not None and
            namespace.capacity_reservation_group != 'None'):

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

  • This newly permits vm update --capacity-reservation-group None --disable-capacity-reservation-assignment true, but the VM update path still converts None into capacity_reservation_group: {"id": None} and does not remove that field (the VMSS update path does). The generated PUT therefore contains an empty capacityReservationGroup alongside disableCapacityReservationAssignment=true, so the advertised combination can still be rejected by Compute. Mirror the VMSS cleanup so the group object is omitted when disable is true.
    if (namespace.disable_capacity_reservation_assignment is True and
            namespace.capacity_reservation_group is not None and
            namespace.capacity_reservation_group != 'None'):
  • Files reviewed: 2/2 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 +296 to +301
def _build_capacity_reservation_profile(capacity_reservation_group, disable_assignment):
profile = {}
if capacity_reservation_group and capacity_reservation_group != 'None':
profile['capacityReservationGroup'] = {'id': capacity_reservation_group}
if disable_assignment is not None:
profile['disableCapacityReservationAssignment'] = disable_assignment
@yonzhan

Copy link
Copy Markdown
Collaborator

Compute

@yanzhudd
Julie Zhu (yanzhudd) merged commit 5e5a8b1 into Azure:dev Sep 14, 2026
64 checks passed
@william051200
William (william051200) deleted the update-ocr-validation branch September 14, 2026 03:57
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 Reservations az reservations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants