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 6 commits into
Azure:devfrom
a0x1ab:agent-assist/azure-azure-cli-issue-34063-338c19fac314
Open

Aditya Pujara (a0x1ab) wants to merge 6 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).

@x-engineering-agent

This comment has been minimized.

@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

This comment has been minimized.

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

This comment has been minimized.

@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

This comment has been minimized.

x-engineering-agent[bot]

This comment was marked as outdated.

@x-engineering-agent

This comment has been minimized.

x-engineering-agent[bot]

This comment was marked as outdated.

x-engineering-agent[bot]

This comment was marked as outdated.

@x-engineering-agent

This comment has been minimized.

x-engineering-agent[bot]

This comment was marked as outdated.

@x-engineering-agent

This comment has been minimized.

x-engineering-agent[bot]

This comment was marked as outdated.

@x-engineering-agent

This comment has been minimized.

@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: 754814a439227c15561a57b75e54b5fa3e086228
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/37411267882

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":"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/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_r67k5umvzazcz7stls3x6psuws35y62waunnrxi'

    @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_r67k5umvzazcz7stls3x6psuws35y62waunnrxi/providers/Microsoft.Resources/deployments/vmss_deploy_aSGPJRUqT3DkqCnDA3xg1VRNciIriv54","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 56.83s =========================

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

No PR-related failure found at 754814a43922. Failure attribution: 0 PR-related, 1 not PR-related, 0 uncertain. No source change is requested for the live-test environment failure.

Upstream CI

All 50 current-head checks passed. The requested playback correction is present: test_vmss_update_zone_placement_policy no longer adds an unrecorded cross-filter command; its only remaining diff is explanatory comments. The existing cassette is unchanged.

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.

The live-test result reports 22 passed, 1 failed. VMSSUpdateZonePlacementPolicyTest.test_vmss_update_zone_placement_policy fails at the initial vmss create in src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py:15481 with: Setting Placement on Virtual Machine Scale Sets is only allowed for preview customers. This occurs before any az vmss update, so the failure is not PR-related. The failed recording was not published and must not replace the existing cassette.

I manually inspected the source scenario in #34063. TestVMSSUpdateZonePlacement in src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_custom_vm_commands.py exercises both persisted-filter switching directions, null/empty filters, preservation of unrelated state, and the real generated PUT serializer's omission of the opposite filter. That is focused unit/serialization evidence, not proof of a successful service-side transition. No additional source defect was confirmed by the seven review-tool checks and changed-line inspection.

For additional live evidence, the workflow owner can rerun vm.test_custom_vm_commands and vm.test_vmss_update_zone_placement_policy through the authorized live-test workflow using an already preview-eligible test environment, or document the preview limitation for the VM owning squad. Do not change shared subscription configuration or publish this failed run's src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_update_zone_placement_policy.yaml. Keep the existing recorded scenario unless a complete successful recording and playback can be obtained.

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