Skip to content

[VM] Fix #34063: az vmss update: Clear the opposite zone placement filter when switching filters - #34164

Open
Aditya Pujara (a0x1ab) wants to merge 15 commits into
Azure:devfrom
a0x1ab:agent-assist/azure-azure-cli-issue-34063-338c19fac314
Open

Aditya Pujara (a0x1ab) wants to merge 15 commits into
Azure:devfrom
a0x1ab:agent-assist/azure-azure-cli-issue-34063-338c19fac314

Conversation

@a0x1ab

Copy link
Copy Markdown
Member

Related command

az vmss update

Description

Fixes #34063.

Clear the opposite zone placement filter when switching filters.

Testing Guide

  • Run az vmss update.
  • Focused regression coverage: src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py, src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py.
  • Repository CI and the authorized live-test workflow validate the published revision.

History Notes

[VM] az vmss update: Clear the opposite zone placement filter when switching filters


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

@x-engineering-agent x-engineering-agent Bot added the Request X Engineering Agent Request X Engineering Agent testing and review label Oct 4, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Auto-Assign Auto assign by bot label Oct 4, 2026
@a0x1ab

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@a0x1ab

Copy link
Copy Markdown
Member Author

@Azure/x-engineering-agent Please fix the PR-induced playback regression: the new --exclude-zones 3 step in test_vmss_update_zone_placement_policy has no matching cassette, so official full-test build 356730 fails with CannotOverwriteExistingCassetteException in both Python 3.12 and 3.14 instance 2. Preserve deterministic unit coverage for clearing the opposite zone filter, and restore the existing recorded scenario unless a complete successful live recording can be obtained. Live run 37219139154 separately failed because this test subscription is not eligible for VMSS Placement preview; do not change shared subscription configuration or publish the failed recording. Distinguish unrelated baseline ACS/SQL/core style findings from this PR regression, rerun affected playback tests, and complete the supported review cycle on the resulting head.

x-engineering-agent[bot]

This comment was marked as outdated.

@x-engineering-agent x-engineering-agent Bot added the X Engineering Agent Reviewed Pull request reviewed by X Engineering Agent label Oct 4, 2026
@a0x1ab
Aditya Pujara (a0x1ab) force-pushed the agent-assist/azure-azure-cli-issue-34063-338c19fac314 branch from ae90ef5 to 56dde0c Compare October 4, 2026 18:45
@a0x1ab

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

x-engineering-agent[bot]

This comment was marked as outdated.

@a0x1ab

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@x-engineering-agent
x-engineering-agent Bot marked this pull request as ready for review October 5, 2026 02:58
@x-engineering-agent
x-engineering-agent Bot requested a review from a team as a code owner October 5, 2026 02:58
Copilot AI balanced review requested due to automatic review settings October 5, 2026 02:58
@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.

Copilot review overview

🟢 Approval recommended

The narrow fix covers both transitions with focused regression tests and no unresolved findings; tests were not executed during review.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes #34063 by clearing the persisted opposite zone placement filter when az vmss update switches filters.

Changes:

  • Removes the stale filter when only the opposite filter is supplied.
  • Adds regression coverage for both transitions, unchanged placement, empty inputs, and mutually exclusive arguments.
File Description
src/​azure-cli/​azure/​cli/​command_modules/​vm/​tests/​latest/​test_custom_vm_commands.py Adds focused zone placement update tests.
src/​azure-cli/​azure/​cli/​command_modules/​vm/​custom.py Clears the opposite placement filter when switching.

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

@a0x1ab
Aditya Pujara (a0x1ab) force-pushed the agent-assist/azure-azure-cli-issue-34063-338c19fac314 branch from 821f963 to bc1e97a Compare October 5, 2026 04:53
x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

@yonzhan

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

@x-engineering-agent

Copy link
Copy Markdown
Contributor

Live test results — azdev test --live --series (changed test files only)

❌ FAIL (exit 1)

Selectors: vm.test_custom_vm_commands vm.test_vmss_update_zone_placement_policy (module)
PR head ref: agent-assist/azure-azure-cli-issue-34063-338c19fac314
PR head sha: 122930a22c59d52f4656999c97734ff7ec73d531
PR base ref: dev
New test files in PR: false

Changed test files run
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py
src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py

Workflow run: https://github.com/Azure/issue-sentinel/actions/runs/37917505675

Live-test recordings: 1 regenerated — archived in workflow artifact live-test-pr-34164 (recordings/).

⚠️ The recording was not committed because the live test failed. Fix the test failure before publishing its regenerated cassette.

Recording files
src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_update_zone_placement_policy.yaml
Last 80 lines of azdev output
           ^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

ex = DeploymentError('{"status":"Failed","error":{"code":"DeploymentFailed","target":"/subscriptions/f758ac53-3e63-4317-a95...":"BadRequest","message":"Setting Placement on Virtual Machine Scale Sets is only allowed for preview customers."}]}}')
args = (), kwargs = {}

    def _handle_main_exception(ex, *args, **kwargs):  # pylint: disable=unused-argument
        if isinstance(ex, CannotOverwriteExistingCassetteException):
            # This exception usually caused by a no match HTTP request. This is a product error
            # that is caused by change of SDK invocation.
            raise ex
    
>       raise CliExecutionError(ex)
E       azure.cli.testsdk.exceptions.CliExecutionError: The CLI throws exception DeploymentError during execution and fails the command.

azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/patches.py:35: CliExecutionError

During handling of the above exception, another exception occurred:

self = <latest.test_vm_commands.VMSSUpdateZonePlacementPolicyTest testMethod=test_vmss_update_zone_placement_policy>
resource_group = 'cli_test_vmss_update_zone_placement_gcwvgefxbnvgxdab6hkbeqncbm7o55gnkwvrrgx'

    @ResourceGroupPreparer(name_prefix='cli_test_vmss_update_zone_placement_', location='eastus2')
    def test_vmss_update_zone_placement_policy(self, resource_group):
        self.kwargs.update({
            'vmss_include': 'vmss-update-include-zones',
            'vmss_exclude': 'vmss-update-exclude-zones',
            'location': 'eastus2',
            'image': 'MicrosoftWindowsServer:WindowsServer:2022-datacenter-g2:latest',
            'admin_username': 'testadmin',
            'admin_password': 'testPassword0!@#',
            'vm_sku': 'Standard_D2s_v7'
        })
    
        # Cross-filter transitions are covered by TestVMSSUpdateZonePlacement; adding
        # them here requires a successful live recording with VMSS Placement preview.
        # create a vmss (with no instances so no zones are in use) and update its include zones
>       self.cmd('vmss create -g {rg} -n {vmss_include} -l {location} --image {image} '
                 '--admin-username {admin_username} --admin-password {admin_password} --upgrade-policy-mode Manual '
                 '--zone-placement-policy Auto --instance-count 0 --vm-sku {vm_sku} ')

azure-cli/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:15481: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:177: in cmd
    return execute(self.cli_ctx, command, expect_failure=expect_failure).assert_with_checks(checks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:252: in __init__
    self._in_process_execute(cli_ctx, command, expect_failure=expect_failure)
azure-cli/src/azure-cli-testsdk/azure/cli/testsdk/base.py:315: in _in_process_execute
    raise ex.exception
.venv/lib/python3.12/site-packages/knack/cli.py:233: in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py:677: in execute
    raise ex
azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py:820: in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure-cli/src/azure-cli-core/azure/cli/core/commands/__init__.py:812: in _run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
azure-cli/src/azure-cli-core/azure/cli/core/commands/arm.py:112: in handle_template_based_exception
    raise_subdivision_deployment_error(ex.response.internal_response.text, ex.error.code if ex.error else None)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

error_message = '{"status":"Failed","error":{"code":"DeploymentFailed","target":"/subscriptions/f758ac53-3e63-4317-a956-0997793808d7/r...e":"BadRequest","message":"Setting Placement on Virtual Machine Scale Sets is only allowed for preview customers."}]}}'
error_code = 'DeploymentFailed'

    def raise_subdivision_deployment_error(error_message, error_code=None):
        from azure.cli.core.azclierror import InvalidTemplateError, DeploymentError
    
        if error_code == 'InvalidTemplateDeployment':
            raise InvalidTemplateError(error_message)
    
>       raise DeploymentError(error_message)
E       azure.cli.core.azclierror.DeploymentError: {"status":"Failed","error":{"code":"DeploymentFailed","target":"/subscriptions/f758ac53-3e63-4317-a956-0997793808d7/resourceGroups/cli_test_vmss_update_zone_placement_gcwvgefxbnvgxdab6hkbeqncbm7o55gnkwvrrgx/providers/Microsoft.Resources/deployments/vmss_deploy_ZW5u9qa5GDO6HEPz1wMxmuxXTLsVgIKk","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"BadRequest","message":"Setting Placement on Virtual Machine Scale Sets is only allowed for preview customers."}]}}

azure-cli/src/azure-cli-core/azure/cli/core/commands/arm.py:104: DeploymentError
!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!
======================== 1 failed, 22 passed in 57.17s =========================

Posted by the X Engineering Agent live-test workflow.

@x-engineering-agent x-engineering-agent Bot 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.

Aditya Pujara (@a0x1ab)

Review

Upstream CI passed. No PR-related defect was found; the failed live test is a preview-access prerequisite, not the filter-normalization change. Live cross-filter transitions remain unverified; this is not an all-clear for human approval.

Upstream CI

All 50/50 checks passed at 122930a22c59d52f4656999c97734ff7ec73d531; the current-head snapshot last completed at 2026-10-09T10:40:41Z.

Test validation

  • Live test: Failed with conclusion failure. Workflow run
  • Regression coverage: For vm: 2 focused test file(s) changed. Scenario coverage is unverified; review the issue's required conditions, test setup, and assertions before approval. No linked issue was found in the PR timeline; inspect the source issue and its required scenario manually.

Live failure - not PR-related: Job 113777176689 reports 1 failed, 22 passed in 57.17s and stops after the first failure. VMSSUpdateZonePlacementPolicyTest::test_vmss_update_zone_placement_policy fails during its initial vmss create, before reaching vmss update. The service returns BadRequest:

Setting Placement on Virtual Machine Scale Sets is only allowed for preview customers.

Scenario evidence and limitation: I inspected the body-linked issue #34063 separately from the timeline lookup. The change at custom.py:5158-5166 removes the persisted opposite filter when only one filter is supplied. The submitted unit assertions exercise the complete handler arguments and generated outgoing placement body in both directions, including populated, empty and null persisted filters. This is author-supplied regression evidence, not proof of live service acceptance.

The scenario-file change is comments only. The existing tests/latest/recordings/test_vmss_update_zone_placement_policy.yaml contains independent include-only and exclude-only PUTs, not cross-filter transitions. No recording changed in this PR; neither the recording nor the failed Agent run proves live switching.

Next action: The workflow/subscription owner should arrange Compute VMSS Placement preview access and rerun the failed Agent workflow; no CLI source change is requested to resolve that environment failure. Before human approval, verify include-to-exclude and exclude-to-include transitions and their resulting placement output in src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py::VMSSUpdateZonePlacementPolicyTest::test_vmss_update_zone_placement_policy, adding transition assertions and refreshing the recording above as needed. Confirm the outgoing body omits the previous filter. If preview access remains unavailable, escalate to the Compute preview and issue-sentinel workflow owners rather than treating the existing independent PUTs as transition coverage.

Risk assessment

16/100 · Low · High confidence

The Low rating is driven by public CLI behavior.

  • Change scope: 3 changed files, 181 changed lines (+180 / -1), including 1 production file.
  • Affected components: vm
  • Risk drivers: public CLI behavior (+18)
  • Regression evidence: Changed regression tests are included, reducing risk.
  • Confidence: High because changed-line patches were available for every production file.
  • Required review: Owning-squad review is recommended for vm before merge.

Posted by x-engineering-agent (Reviewer)

This branch has not been deployed

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

Labels

Auto-Assign Auto assign by bot Request X Engineering Agent Request X Engineering Agent testing and review X Engineering Agent Reviewed Pull request reviewed by X Engineering Agent

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