Skip to content

[Compute] Fix #34063: az vmss update: Clear the stale zone placement filter when switching filters - #34064

Open
WhaleTech (ryo-whaletech) wants to merge 1 commit into
Azure:devfrom
ryo-whaletech:investigate-vmss-placement-filter-transition
Open

WhaleTech (ryo-whaletech) wants to merge 1 commit into
Azure:devfrom
ryo-whaletech:investigate-vmss-placement-filter-transition

Conversation

@ryo-whaletech

Copy link
Copy Markdown

Related command

az vmss update

Description

Fixes #34063

When a VMSS already contains placement.includeZones or placement.excludeZones, generic update loads and preserves that existing property.

If the user supplies the opposite argument, the existing implementation adds the new filter without removing the old one. The complete model passed to the AAZ VMSS create-or-update operation therefore contains both mutually exclusive properties, which Compute rejects.

This change normalizes placement state in the legacy update_vmss customization:

  • Supplying --include-zones removes a persisted excludeZones.
  • Supplying --exclude-zones removes a persisted includeZones.
  • Supplying neither continues to preserve the existing filter.
  • Supplying both in one invocation remains rejected by the existing validator.

The regression test exercises both transition directions and inspects the exact model passed to VMSSCreate.

The fix belongs in the Azure CLI custom update handler because it depends on distinguishing persisted generic-update state from an explicitly supplied CLI argument. The generated AAZ schema and PUT serializer correctly represent both service properties and do not require modification.

Feature-introduction context: #33639.

Testing Guide

Focused regression:

VIRTUAL_ENV="$PWD/.venv" \
AZURE_CONFIG_DIR=/private/tmp/azure-cli-vmss-test \
AZDEV_CONFIG_DIR=/private/tmp/azure-cli-azdev \
.venv/bin/azdev test test_update_vmss_switches_zone_placement_filter --discover

Result: 1 passed, 2 subtests passed.

Relevant unit module:

VIRTUAL_ENV="$PWD/.venv" \
AZURE_CONFIG_DIR=/private/tmp/azure-cli-vmss-test \
AZDEV_CONFIG_DIR=/private/tmp/azure-cli-azdev \
.venv/bin/azdev test test_custom_vm_commands --discover

Result: 8 passed, 2 subtests passed.

Existing update playback:

VIRTUAL_ENV="$PWD/.venv" \
AZURE_CONFIG_DIR=/private/tmp/azure-cli-vmss-test \
AZDEV_CONFIG_DIR=/private/tmp/azure-cli-azdev \
.venv/bin/azdev test test_vmss_update_zone_placement_policy --discover

Result: 1 passed.

Related include/exclude/conflict playback tests:

VIRTUAL_ENV="$PWD/.venv" \
AZURE_CONFIG_DIR=/private/tmp/azure-cli-vmss-test \
AZDEV_CONFIG_DIR=/private/tmp/azure-cli-azdev \
.venv/bin/azdev test \
test_vmss_zone_placement_policy_with_include_zones \
test_vmss_zone_placement_policy_with_exclude_zones \
test_vmss_zone_placement_policy_validation_zones_conflict \
--discover --series

Result: 3 passed.

VIRTUAL_ENV="$PWD/.venv" \
AZDEV_CONFIG_DIR=/private/tmp/azure-cli-azdev \
.venv/bin/azdev style vm

Result: Pylint and Flake8 passed.

VIRTUAL_ENV="$PWD/.venv" \
AZDEV_CONFIG_DIR=/private/tmp/azure-cli-azdev \
.venv/bin/azdev linter vm

Result: passed with no violations.

git diff --check origin/dev...HEAD

Result: passed.

The full azdev test vm suite and a live Azure VMSS transition were not run. No recordings were regenerated.

History Notes

[Compute] az vmss update: Fix switching between --include-zones and --exclude-zones when the opposite zone placement filter is already configured


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

Copilot AI lite review requested due to automatic review settings September 11, 2026 06:45
@ryo-whaletech
WhaleTech (ryo-whaletech) requested a review from a team as a code owner September 11, 2026 06:45
@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 11, 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.

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

The implementation and regression coverage address both filter-switching directions with no unresolved blocking issues.

Pull request overview

Fixes az vmss update so switching VMSS zone placement filters clears stale, mutually exclusive state.

Changes:

  • Normalize include/exclude zone filter updates.
  • Add regression coverage for both transition directions.
File summaries
File Summary
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py Verifies both filter-switching scenarios.
src/azure-cli/azure/cli/command_modules/vm/custom.py Clears the opposite placement filter before updating.
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

az vmss update retains the previous zone placement filter when switching between --include-zones and --exclude-zones

4 participants