[AKS] az aks nodepool update, az aks nodepool auto-scale, --enable-cluster-autoscaler: Add CAS support for VMS agent pools - #33801
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
This PR brings mixed-SKU cluster autoscaler (CAS) support for VirtualMachines (VMS) agent pools into azure-cli mainline AKS commands, including a new az aks nodepool auto-scale command group and VMS-specific manual↔autoscale conversion behavior in aks nodepool update.
Changes:
- Added
az aks nodepool auto-scale add|update|deletecommands for managingvirtualMachinesProfile.scale.autoscaleprofiles on VMS pools. - Implemented VMS autoscaler conversion logic in the agentpool decorator for
--enable-cluster-autoscaler/--disable-cluster-autoscaler, and blocked--update-cluster-autoscalerfor VMS pools with guidance to useauto-scale update. - Added/updated unit and scenario tests covering the new commands and conversion behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/acs/custom.py | Adds the aks_agentpool_auto_scale_* custom command implementations for VMS autoscale profile CRUD. |
| src/azure-cli/azure/cli/command_modules/acs/commands.py | Registers the new aks nodepool auto-scale command group and its commands. |
| src/azure-cli/azure/cli/command_modules/acs/_params.py | Wires CLI parameters for the new auto-scale commands. |
| src/azure-cli/azure/cli/command_modules/acs/_help.py | Updates help text for autoscaler flags and documents the new auto-scale commands. |
| src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py | Adds VMS-specific autoscaler validation/guardrails and manual↔autoscale conversion logic. |
| src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py | Adds unit tests for the new aks_agentpool_auto_scale_* functions. |
| src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py | Adds scenario tests validating end-to-end behavior for VMS autoscale commands and conversions. |
| src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_agentpool_decorator.py | Adds unit tests for VMS conversion and guardrail behavior in the decorator/context. |
Comments suppressed due to low confidence (2)
src/azure-cli/azure/cli/command_modules/acs/custom.py:3710
aks_agentpool_auto_scale_updatematches autoscale profiles with a case-sensitivea.size == current_node_vm_sizecomparison and does not validate the resulting min/max counts (or prevent renaming to a size that already exists). This can cause updates to fail unexpectedly (case mismatch) or create duplicate sizes/invalid min>max configurations.
autoscale_exists = False
for a in instance.virtual_machines_profile.scale.autoscale or []:
if a.size == current_node_vm_size:
autoscale_exists = True
if node_vm_size is not None:
src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py:1095
- When enabling autoscaler on a VirtualMachines pool,
vm_sizecan remainNoneif the pool has no manual profiles and the user doesn't pass--node-vm-size, which later leads to creating an autoscale profile withsize=None. This should fail fast with a clear RequiredArgumentMissingError.
# default vm_size for backward compatibility when no manual/autoscale profile exists
if vm_size is None and manual_scale_profile:
vm_size = manual_scale_profile[0].size
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…unts_in_autoscaler, correct help property path
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
FumingZhang
left a comment
There was a problem hiding this comment.
- the PR title needs to be updated. Since this is a complicated change, you can include multiple lines of history notes by writing them in the corresponding section of the PR description.
- there's also a need to commit the recording files to pass CI checks.
| @@ -15321,6 +15321,237 @@ def test_vms_agentpool_type(self, resource_group, resource_group_location): | |||
| ], | |||
| ) | |||
|
|
|||
| @AllowLargeResponse() | |||
| @AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix="clitest", location="westus2") | |||
| def test_vms_cluster_create_and_add_autoscale_mode(self, resource_group, resource_group_location): | |||
There was a problem hiding this comment.
Got an error, fixing it now
There was a problem hiding this comment.
az aks --enable-cluster-autoscaler az aks nodepool auto-scale: Add CAS support for VMS agent pool commandsaz aks nodepool update, az aks nodepool auto-scale, --enable-cluster-autoscaler: Add CAS support for VMS agent pools
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
|
/azp run |
|
Azure Pipelines: Successfully started running 3 pipeline(s). |
🤖 PR Validation —⚠️ Review suggested
Related command
Description
This PR ports mixed-SKU cluster autoscaler (CAS) support for VirtualMachines (VMS) agent pools from aks-preview into azure-cli mainline ACS commands.
What is changed:
Effect:
Testing Guide
Example commands to validate behavior:
az aks create
--resource-group
--name
--vm-set-type VirtualMachines
--node-vm-size Standard_D4s_v3
--enable-cluster-autoscaler
--min-count 2
--max-count 5
Expected: agentPoolProfiles[0].virtualMachinesProfile.scale.autoscale is populated.
az aks nodepool add
--resource-group
--cluster-name
--name
--vm-set-type VirtualMachines
--node-vm-size Standard_D4s_v3
--enable-cluster-autoscaler
--min-count 2
--max-count 5
Expected: nodepool virtualMachinesProfile.scale.autoscale[0] exists.
az aks nodepool update
--resource-group
--cluster-name
--name
--enable-cluster-autoscaler
--min-count 2
--max-count 5
Expected: all manual profiles are converted into autoscale profiles.
az aks nodepool update
--resource-group
--cluster-name
--name
--disable-cluster-autoscaler
Expected: autoscale profiles are converted to manual profiles; manual count defaults from minCount.
az aks nodepool auto-scale add
--resource-group
--cluster-name
--name
--node-vm-size Standard_D2s_v3
--min-count 3
--max-count 5
az aks nodepool auto-scale update
--resource-group
--cluster-name
--name
--current-node-vm-size Standard_D2s_v3
--node-vm-size Standard_D8s_v3
--min-count 2
--max-count 4
az aks nodepool auto-scale delete
--resource-group
--cluster-name
--name
--current-node-vm-size Standard_D8s_v3
Expected: add/update/delete mutate virtualMachinesProfile.scale.autoscale as requested.
az aks nodepool update
--resource-group
--cluster-name
--name
--update-cluster-autoscaler
--min-count 2
--max-count 5
Expected: validation failure for VMS pools directing to az aks nodepool auto-scale update.
Automated tests added/updated:
History Notes
[AKS]
az aks create,az aks nodepool add: Support--enable-cluster-autoscalerfor VirtualMachines agent pools to create pools in autoscale mode[AKS]
az aks nodepool update: Support--enable-cluster-autoscalerfor VirtualMachines agent pools by converting manual scale profiles to autoscale profiles[AKS]
az aks nodepool update: Support--disable-cluster-autoscalerfor VirtualMachines agent pools by converting autoscale profiles back to manual profiles[AKS]
az aks nodepool update: Block--update-cluster-autoscalerfor VirtualMachines agent pools and direct toaz aks nodepool auto-scale update[AKS]
az aks nodepool auto-scale add: Add command to add an autoscale profile to a VirtualMachines agent pool[AKS]
az aks nodepool auto-scale update: Add command to update an autoscale profile of a VirtualMachines agent pool[AKS]
az aks nodepool auto-scale delete: Add command to delete an autoscale profile from a VirtualMachines agent poolThis 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.