{Compute} az vmss/vm: Update Open Capacity Reservation validation logic - #34045
Conversation
There was a problem hiding this comment.
🟡 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-groupwith--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.
| 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") |
|
Compute |
🤖 PR Validation — ️✔️ All clear
Related command
az vm create/updateaz vmss create/updateDescription
Current validation:
Not allow
--capacity-reservation-group+--disable-capacity-reservation-assignmentChange:
Only allow
--capacity-reservation-group+--disable-capacity-reservation-assignment FalseTesting Guide
History Notes
This checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.