Repository navigation
[AKS] az aks nodepool update: Add --node-vm-size to resize VirtualMachineScaleSets node pools - #34319
Conversation
…lMachineScaleSets node pools Changing the VM size of a VMSS node pool makes AKS replace every node with a node of the new size, using the node pool's surge and drain settings. The command asks for confirmation unless --yes is passed, and does nothing when the requested size matches the current size. VirtualMachines node pools still change sizes through `az aks nodepool manual-scale/auto-scale update`. On those pools, --node-vm-size is accepted only together with --enable-cluster-autoscaler or --disable-cluster-autoscaler, matching the existing behavior. Co-Authored-By: Claude <noreply@anthropic.com>
|
Thank you for your contribution Alex Huang (@wenhug)! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
🟡 Changes recommended
During autoscaler transitions for VirtualMachines pools with populated scale profiles, --node-vm-size is silently ignored, allowing the command to succeed without applying the requested resize.
1 open issue
What changed in this PR
Adds VM-size changes to core az aks nodepool update, enabling rolling replacement of nodes in existing VirtualMachineScaleSets pools.
Changes:
- Exposes
--node-vm-size/-swith confirmation for size changes and case-insensitive no-op handling. - Adds VirtualMachines pool validation, help text, and a resize example.
- Adds unit coverage in both decorator modes and a live-only resize scenario that has not yet been run.
| File | Description |
|---|---|
src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py |
Adds a live-only VMSS resize scenario. |
src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_agentpool_decorator.py |
Tests resizing, confirmation, no-ops, and VirtualMachines handling. |
src/azure-cli/azure/cli/command_modules/acs/custom.py |
Accepts the VM-size argument in the update handler. |
src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py |
Implements size updates, confirmation, and pool-type validation. |
src/azure-cli/azure/cli/command_modules/acs/_params.py |
Registers --node-vm-size and -s. |
src/azure-cli/azure/cli/command_modules/acs/_help.py |
Documents resize behavior and adds an example. |
Review effort: Balanced
| if not ( | ||
| self.context.raw_param.get("enable_cluster_autoscaler") or | ||
| self.context.raw_param.get("disable_cluster_autoscaler") | ||
| ): |
…peration conflicts Right after a node pool is added, AKS can report it as Updating and still run cluster-level operations (e.g. addon reconciliation) that reject a new PUT with OperationNotAllowed or EtagMismatch. Wait for the pool to reach Succeeded, retry the resize on those conflicts, and verify the final state with `aks nodepool show`. Co-Authored-By: Claude <noreply@anthropic.com>
|
Please fix CI issues |
…utoscaler transitions When `--enable/--disable-cluster-autoscaler` converts an existing VirtualMachines scale profile, the new profile copies the existing sizes, so a requested `--node-vm-size` was silently ignored. Reject the option for VirtualMachines node pools in all cases and point to `az aks nodepool manual-scale/auto-scale update` instead. Co-Authored-By: Claude <noreply@anthropic.com>
|
Please provide the live-test result and tested SHA, and confirm stable-API resizing works in the default test subscription without preview registration or rollout overrides. The recording alone does not establish flag-free GA availability. |
| # update ssh access | ||
| agentpool = self.update_ssh_access(agentpool) | ||
| # update vm size | ||
| agentpool = self.update_vm_size(agentpool) |
There was a problem hiding this comment.
[P2] Combining --node-vm-size with an already-satisfied autoscaler flag returns success without resizing: the autoscaler step exits before the resize hook (reproduced: zero PUTs). Please continue the resize or reject the combination, and add handler-level tests for both autoscaler states.
|
Alex Huang (@wenhug) One confirmed command-behavior defect requires correction; resize regression coverage remains unverified. To addressTick each item as you address it.
Review detailsUpstream CIUpstream CI passed: 52 checks. Regression coverage for the required resize scenario remains unverified. Test validation
Risk assessment30/100 · Medium The Medium rating is driven by public CLI behavior, failure-handling behavior.
Ask the Agent Tick a box to queue an action. Requires write access to this repository.
|
There was a problem hiding this comment.
Review comments are inline on the changed lines. See the X Engineering Agent Report.
| # update ssh access | ||
| agentpool = self.update_ssh_access(agentpool) | ||
| # update vm size | ||
| agentpool = self.update_vm_size(agentpool) |
There was a problem hiding this comment.
Autoscaler no-op discards the resize
The new resize invocation is after update_auto_scaler_properties. For a VMSS pool with enable_auto_scaling false, a call accepting node_vm_size='Standard_D4s_v5', disable_cluster_autoscaler=True and yes=True takes custom.py:3675,3678,3683–3692 -> agentpool_decorator.py:3099,3110 -> 2739,2757 -> 951,1031–1035. DecoratorEarlyExitException is caught by custom.py:3693–3695, which returns before update_agentpool at 3697. Neither the size update nor the PUT occurs. The warning only says the autoscaler is already disabled. The equivalent already-enabled branch is agentpool_decorator.py:1016–1022 when enabling with valid min/max counts. This newly accepted resize input exposes the existing early-exit path.
Remediation: Preserve pending resize work when autoscaler state is already satisfied, or explicitly reject the combined request instead of returning success with only an autoscaler warning. Merely moving the resize mutation before the early exit would not ensure a PUT.
Focused verification: Add command-level mocked tests through aks_agentpool_update, using a D2s_v5 VMSS pool with autoscaling already disabled and a D4s_v5 resize plus --disable-cluster-autoscaler; also cover already-enabled with valid min/max counts. Assert a D4s_v5 request, or a clear unsupported-combination error and no request. Preserve deliberate resize-confirmation cancellation.
X Engineering Agent · Reviewer · React with +1 or -1 to train the reviewer
| self._ensure_agentpool(agentpool) | ||
|
|
||
| node_vm_size = self.context.raw_param.get("node_vm_size") | ||
| if not node_vm_size: |
There was a problem hiding this comment.
Empty size is silently ignored
_params.py:1377 registers --node-vm-size/-s without a nonempty validator. custom.py:3675–3686 carries it into raw parameters; agentpool_decorator.py:2690–2695 wraps them without coercion, and base_decorator.py:100–105 preserves ''. The new if not node_vm_size at agentpool_decorator.py:3047–3048 returns the old pool for an explicit empty string, before either the unsupported-pool rejection at 3050 or assignment at 3067. custom.py:3697 then submits the pool through agentpool_decorator.py:3163–3171 with the previous VM size. The new unit test only covers None, not ''.
Remediation: Use a None-only omission check and explicitly reject empty VM-size strings with InvalidArgumentValueError before request submission.
Focused verification: Cover omitted/None, empty string, and a valid size through the command/update controller. Empty input must fail on both VMSS and VirtualMachines pools with no PUT; None must preserve the pool and valid sizes must still map to properties.vmSize.
X Engineering Agent · Reviewer · React with +1 or -1 to train the reviewer
| ], | ||
| ) | ||
|
|
||
| @live_only() |
There was a problem hiding this comment.
Recorded scenario is excluded from playback
The new scenario is decorated with @live_only() at line 17434. The import at line 38 resolves through testsdk/init.py:6 and scenario_tests/init.py:15 to scenario_tests/decorators.py:13–16, which applies unittest.skipUnless(ENV_LIVE_TEST). Thus normal playback skips all newly added request/output checks despite the accompanying 2176-line recording. The source has meaningful size/state assertions at 17459,17471,17480–17481, but the recording is not consumed by this decorated scenario in playback.
Remediation: Make the recorded resize scenario playback-eligible, or add a separate playback scenario retaining the same request and final-state assertions; address any actual replay incompatibility rather than leaving the recording unexercised.
Focused verification: After enabling playback coverage, run test_aks_nodepool_update_vm_size in normal playback and confirm it is not skipped. Confirm a regression that leaves either the outgoing or returned vmSize at Standard_D2s_v5 fails the focused scenario. Any live re-recording remains a separately authorized author action.
X Engineering Agent · Reviewer · React with +1 or -1 to train the reviewer
…ect empty values - Reject `--node-vm-size` combined with --enable/--disable/--update-cluster-autoscaler. When the autoscaler was already in the requested state, the command exited early with only an autoscaler warning and the resize was never sent. - Reject an explicit empty `--node-vm-size`, which was silently treated as omitted. - Validate up front in update_agentpool_profile_default, before any step that can exit early, and add full-command tests through aks_agentpool_update. - Remove the accidentally committed live recording; the scenario stays live-only. Co-Authored-By: Claude <noreply@anthropic.com>
|
Thanks for checking. Live result: One caveat: I ran it on an AKS dev subscription, not the default CLI test subscription, because I don't have write access there. The committed recording was removed. It was added by mistake, and playback wouldn't exercise the rolling replacement, so the scenario stays live-only. Happy to have it run in your live pipeline if that helps. |
|
Addressed in e4d6d49:
|
|
Adding mansoor sarfraz (@msarfraz) to help review |
| # fetch the Agentpool object | ||
| agentpool = self.fetch_agentpool(agentpools) | ||
| # validate --node-vm-size before any step that may exit early (e.g. autoscaler already enabled) | ||
| self.context.get_node_vm_size_for_update() |
There was a problem hiding this comment.
Please ensure the new core behavior preserves existing aks-preview usage. I locally reproduced a VMSS resize + --update-cluster-autoscaler request reaching PUT with the previous head, but failing with MutuallyExclusiveArgumentError here. Please address this in core or coordinate an aks-preview adaptation, and add a controller-level compatibility test against both the latest released CLI (2.92.0) and this PR head.
…d be skipped e4d6d49 rejected `--node-vm-size` together with any --enable/--disable/--update-cluster-autoscaler flag. aks-preview reuses the core update flow, so that broke combinations it accepted before, e.g. a VMSS resize with --update-cluster-autoscaler. Only reject the two cases that actually drop the resize: --enable-cluster-autoscaler when the autoscaler is already enabled, and --disable-cluster-autoscaler when it is already disabled. Both exit early before the resize is applied. Every other combination sends one PUT with the new size and the autoscaler change, matching 2.92.0. The check runs in update_agentpool_profile_default after fetching the pool and before the autoscaler properties are updated, so it sees the pool's current autoscaler state. Co-Authored-By: Claude <noreply@anthropic.com>
| @live_only() | ||
| @AllowLargeResponse() | ||
| @AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2') | ||
| def test_aks_nodepool_update_vm_size(self, resource_group, resource_group_location): |
There was a problem hiding this comment.
Queued live test to validate the change, test passed!

🤖 PR Validation —⚠️ Review suggested
This PR adds warning or check suppressions. Fix the underlying warning where possible and justify each remaining suppression in a code comment or the PR description.
1 added suppression
src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.pyexcept Exception as ex: # pylint: disable=broad-exceptRelated command
az aks nodepool updateDescription
AKS can now resize an existing VirtualMachineScaleSets node pool in place. When a node pool PUT changes
vmSize, AKS adds surge nodes of the new size, then cordons, drains and deletes the old nodes, following the node pool's upgrade settings. The service accepts this through stable API versions. This PR adds the option to coreaz aks nodepool update. It is already available inaks-preview(Azure/azure-cli-extensions#9732).Changes:
--node-vm-size/-stoaz aks nodepool update.AKSAgentPoolUpdateDecorator.update_vm_sizeand call it fromupdate_agentpool_profile_default:vm_sizeto the requested size. Replacing every node is disruptive, so the command asks for confirmation unless--yesis passed (same pattern as--ssh-access). If the requested size already matches the current size (case-insensitive), nothing changes and there is no prompt.--node-vm-sizefails with anInvalidArgumentValueErrorthat points toaz aks nodepool manual-scale update/auto-scale update.--node-vm-sizecan be combined with--update-cluster-autoscaler, and with--enable/--disable-cluster-autoscalerwhen they change the autoscaler state; one PUT carries both changes, as in 2.92.0. The only rejected cases (MutuallyExclusiveArgumentError) are--enable-cluster-autoscalerwhen the autoscaler is already enabled and--disable-cluster-autoscalerwhen it is already disabled. Those requests exit early, which would otherwise drop the resize. The check runs inupdate_agentpool_profile_defaultafter the pool is fetched and before the autoscaler properties are updated.--node-vm-size ""is rejected instead of being treated as omitted.az aks update(managed cluster mode) does not take--node-vm-size, so it is unaffected.Testing Guide
test_update_vm_sizeruns in both standalone and managed-cluster decorator modes. It covers setting a new size with--yes, no-op when the flag is not passed, no-op for the same size, prompt accepted, prompt rejected, VirtualMachines pools, empty values, and the autoscaler check (rejects only the two no-op cases;--update-cluster-autoscalerand state-changing enable/disable are allowed).test_aks_agentpool_update_vm_sizegoes throughaks_agentpool_updateand checks the outgoing PUT: resize alone; resize +--update-cluster-autoscaler, +--enable(off→on), +--disable(on→off) each send one PUT with the new size and the expected autoscaler settings;--enablewhen already on and--disablewhen already off raise before any PUT; an empty value raises before any PUT; omitting the flag keeps the existing size. Removing the up-front check makes the two no-op cases fail.aks nodepool updatecases through aks-preview'supdate_agentpool_profile_preview(latestmain, 17c8c64) against core 2.92.0 and against this PR. Results are identical except three intended changes: VMSS resize with a no-op--enable/--disable-cluster-autoscalernow errors instead of silently exiting without a PUT, and--node-vm-size ""now errors instead of sending the unchanged size. VMSS resize +--update-cluster-autoscaler, resize + state-changing enable/disable, and the VirtualMachines-pool cases (including the aks-preview help example) all behave the same as 2.92.0.test_agentpool_decorator.py,test_managed_cluster_decorator.py,test_custom.py,test_validators.py,test_helpers.py: 1007 passed, 1 skipped.test_aks_nodepool_update_vm_size: create a cluster, add a D2s_v5 VMSS pool, resize it to D4s_v5. Passed live on e4d6d49 (westus2, 12 min) using stable API2026-08-01, with no extensions loaded, no AKS preview feature registration for resize on the subscription, and no toggle overrides. It ran on an AKS dev subscription, not the default CLI test subscription, which I don't have write access to. Right after a node pool is added, AKS can still be running cluster-level operations (addon reconciliation) that reject a new PUT withOperationNotAllowed/EtagMismatch, so the test waits for the pool to reachSucceededand retries the resize on those two errors. It stays live-only: playback would not exercise the rolling node replacement, so no recording is committed.Standard_D4s_v5, and its only instance was a new VM of that size (the original D2s_v5 instance was gone), so the nodes were replaced rather than the field just being updated.History Notes
[AKS]
az aks nodepool update: Add--node-vm-sizeto resize VirtualMachineScaleSets node poolsThis 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.
🤖 Generated with Claude Code