aks-preview: Support VMSS agent pool VM size resize via nodepool update#9732
aks-preview: Support VMSS agent pool VM size resize via nodepool update#9732wenhug wants to merge 2 commits intoAzure:mainfrom
Conversation
Enable changing the VM size (SKU) of an existing VMSS-based agent pool via `az aks nodepool update --node-vm-size <new-size>`. The RP performs a rolling upgrade (surge new nodes, drain old, delete old) to replace nodes with the new VM size. This preview feature requires: - AFEC registration: Microsoft.ContainerService/AgentPoolVMSSResize - RP internal toggle: enable-agentpool-vmsize-resize Changes: - agentpool_decorator.py: add update_vm_size() for VMSS pools and call it in update_agentpool_profile_preview() - _params.py: mark --node-vm-size as is_preview for nodepool update - _help.py: update help text and add VMSS resize example - test_agentpool_decorator.py: add unit tests for update_vm_size
❌Azure CLI Extensions Breaking Change Test
|
|
Hi @wenhug, |
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
CodeGen Tools Feedback CollectionThank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey |
|
Hi @wenhug Release SuggestionsModule: aks-preview
Notes
|
There was a problem hiding this comment.
Pull request overview
This PR extends az aks nodepool update --node-vm-size to support resizing VMSS-based agent pools (preview), aligning CLI behavior with the RP’s rolling-replacement resize flow.
Changes:
- Add a VMSS-aware
update_vm_size()path to the nodepool update decorator and wire it intoupdate_agentpool_profile_preview(). - Mark
--node-vm-sizeas a preview parameter foraks nodepool updateand update CLI help text/examples accordingly. - Add unit tests validating
update_vm_size()behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/aks-preview/azext_aks_preview/agentpool_decorator.py |
Adds update_vm_size() and invokes it during preview nodepool update assembly. |
src/aks-preview/azext_aks_preview/_params.py |
Marks --node-vm-size as preview for aks nodepool update. |
src/aks-preview/azext_aks_preview/_help.py |
Updates help text and adds a VMSS resize example. |
src/aks-preview/azext_aks_preview/tests/latest/test_agentpool_decorator.py |
Adds unit tests for update_vm_size(). |
| # Skip for VirtualMachines pools - they handle VM size via autoscaler path | ||
| if self.context.get_vm_set_type() == CONST_VIRTUAL_MACHINES: | ||
| return agentpool | ||
|
|
||
| node_vm_size = self.context.raw_param.get("node_vm_size") | ||
| if node_vm_size: | ||
| agentpool.vm_size = node_vm_size |
There was a problem hiding this comment.
update_auto_scaler_properties() in this same decorator still raises InvalidArgumentValueError whenever raw_param['node_vm_size'] is not None for VMSS pools ("Updating VM size is not supported for virtual machine scale set agentpools."). With VMSS resize now supported via --node-vm-size, this guard will block the new behavior if update_auto_scaler_properties() is invoked as part of the update flow (e.g., by the default update profile). Consider removing or narrowing that validation so VMSS pools can accept --node-vm-size without throwing.
| # Skip for VirtualMachines pools - they handle VM size via autoscaler path | |
| if self.context.get_vm_set_type() == CONST_VIRTUAL_MACHINES: | |
| return agentpool | |
| node_vm_size = self.context.raw_param.get("node_vm_size") | |
| if node_vm_size: | |
| agentpool.vm_size = node_vm_size | |
| vm_set_type = self.context.get_vm_set_type() | |
| # Skip for VirtualMachines pools - they handle VM size via autoscaler path | |
| if vm_set_type == CONST_VIRTUAL_MACHINES: | |
| return agentpool | |
| # Only apply direct VM size changes for VMSS pools | |
| if vm_set_type == CONST_VIRTUAL_MACHINE_SCALE_SETS: | |
| node_vm_size = self.context.raw_param.get("node_vm_size") | |
| if node_vm_size: | |
| # Apply the new VM size to the agent pool | |
| agentpool.vm_size = node_vm_size | |
| # Clear the raw_param value so downstream autoscaler validation | |
| # (which still checks node_vm_size for VMSS) does not reject | |
| # this supported VM size update. | |
| self.context.raw_param["node_vm_size"] = None |
| vm_size="Standard_D4s_v3" | ||
| ) | ||
| self.assertEqual(dec_agentpool_2, ground_truth_agentpool_2) | ||
|
|
There was a problem hiding this comment.
The new unit tests cover VMSS behavior, but they don't cover the VirtualMachines pool branch where update_vm_size() should be a no-op (VM size changes are handled via the autoscaler update path). Add a test case with type=CONST_VIRTUAL_MACHINES and node_vm_size set to ensure update_vm_size() does not mutate agentpool.vm_size for VMs pools.
| # Test case 3: VirtualMachines pool with node_vm_size provided (should be no-op) | |
| dec_3 = AKSPreviewAgentPoolUpdateDecorator( | |
| self.cmd, | |
| self.client, | |
| {"node_vm_size": "Standard_D4s_v3"}, | |
| self.resource_type, | |
| self.agentpool_decorator_mode, | |
| ) | |
| agentpool_3 = self.create_initialized_agentpool_instance( | |
| vm_size="Standard_D2s_v3" | |
| ) | |
| # For VirtualMachines pools, update_vm_size should be a no-op; VM size changes are | |
| # handled via the autoscaler update path. | |
| agentpool_3.type = CONST_VIRTUAL_MACHINES | |
| dec_3.context.attach_agentpool(agentpool_3) | |
| dec_agentpool_3 = dec_3.update_vm_size(agentpool_3) | |
| ground_truth_agentpool_3 = self.create_initialized_agentpool_instance( | |
| vm_size="Standard_D2s_v3" | |
| ) | |
| ground_truth_agentpool_3.type = CONST_VIRTUAL_MACHINES | |
| self.assertEqual(dec_agentpool_3, ground_truth_agentpool_3) |
Address review comments: 1. Remove the InvalidArgumentValueError in update_auto_scaler_properties() that blocked --node-vm-size for VMSS pools. This check was added when --node-vm-size only supported VirtualMachines pools, but now VMSS pools support VM size resize via rolling upgrade. 2. Add test case for VirtualMachines pool to verify update_vm_size() is a no-op (VMs pools handle VM size via the autoscaler update path). 3. Add HISTORY.rst entry for the new feature.
|
Addressed the two Copilot review comments: Comment 1 (blocker in Comment 2 (VMs pool test): Added a third test case verifying Also added a |
|
/azp run |
|
Azure Pipelines successfully started running 2 pipeline(s). |
|
|
||
| Pending | ||
| +++++++ | ||
| * `az aks nodepool update`: Support `--node-vm-size` to resize VM size of an existing VMSS-based agent pool (preview). Requires AFEC registration `Microsoft.ContainerService/AgentPoolVMSSResize`. |
There was a problem hiding this comment.
Is it possible to bypass the feature flag validation via custom header? If so, please add a scenario test to ensure the change works as expected.
|
Please resolve merge conflict and rebase/merge from main to pass the CI checks, @wenhug |
Summary
Enable changing the VM size (SKU) of an existing VMSS-based agent pool via
az aks nodepool update --node-vm-size <new-size>.When the user changes the VM size of a VMSS node pool, the AKS RP performs a rolling upgrade:
This is a preview feature that requires:
Microsoft.ContainerService/AgentPoolVMSSResizeenable-agentpool-vmsize-resize(currently enabled for E2E + Canary)The
--node-vm-sizeparameter already existed onnodepool updatefor VirtualMachines pool autoscaler updates. This PR extends it to also work for VMSS pools.Usage
# Resize VM size for a VMSS node pool az aks nodepool update \ -g MyResourceGroup \ -n nodepool1 \ --cluster-name MyManagedCluster \ --node-vm-size Standard_D4s_v3RP-side validation
The RP validates the resize request and blocks incompatible combinations:
Changes
update_vm_size()method for VMSS pools and integrate it intoupdate_agentpool_profile_preview()--node-vm-sizeasis_preview=Truefornodepool updateupdate_vm_sizeTest plan
update_vm_size(both Standalone and ManagedCluster modes)Scenario_VMSS_VMSize_Resize)