Skip to content

[AKS] az aks nodepool update, az aks nodepool auto-scale, --enable-cluster-autoscaler: Add CAS support for VMS agent pools - #33801

Open
reneeli123 wants to merge 7 commits into
Azure:devfrom
reneeli123:reneel/cas-vms-ga
Open

[AKS] az aks nodepool update, az aks nodepool auto-scale, --enable-cluster-autoscaler: Add CAS support for VMS agent pools#33801
reneeli123 wants to merge 7 commits into
Azure:devfrom
reneeli123:reneel/cas-vms-ga

Conversation

@reneeli123

@reneeli123 reneeli123 commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Tests
⚠️ None ️✔️ 130/130
⚠️AzureCLI-BreakingChangeTest
⚠️acs
rule cmd_name rule_message suggest_message
⚠️ 1011 - SubgroupAdd aks nodepool auto-scale sub group aks nodepool auto-scale added

Related command

  • az aks create --vm-set-type VirtualMachines --node-vm-size --enable-cluster-autoscaler --min-count --max-count
  • az aks nodepool add --vm-set-type VirtualMachines --node-vm-size --enable-cluster-autoscaler --min-count --max-count
  • az aks nodepool update --enable-cluster-autoscaler --min-count --max-count
  • az aks nodepool update --disable-cluster-autoscaler
  • az aks nodepool update --update-cluster-autoscaler (now blocked for VirtualMachines pools; use auto-scale update)
  • az aks nodepool auto-scale add
  • az aks nodepool auto-scale update
  • az aks nodepool auto-scale delete

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:

  • Add new command group:
    • az aks nodepool auto-scale add
    • az aks nodepool auto-scale update
    • az aks nodepool auto-scale delete
  • Add parameter wiring and help for the new auto-scale commands.
  • Add VMS-specific autoscaler behavior in nodepool update:
    • --enable-cluster-autoscaler converts all manual scale profiles to autoscale profiles using the same min/max values.
    • --disable-cluster-autoscaler converts all autoscale profiles back to manual profiles, defaulting manual count from autoscale minCount.
    • --update-cluster-autoscaler is rejected for VMS pools with a clear guidance message to use az aks nodepool auto-scale update.
  • Keep existing VMSS autoscaler behavior unchanged.
  • Add scenario and unit tests in ACS test suites to validate command behavior and conversion logic.

Effect:

  • Customers using VMS pools can now manage autoscale profiles directly (add/update/delete) and switch between manual and autoscale modes using supported commands.

Testing Guide

Example commands to validate behavior:

  1. Create VMS cluster in autoscale mode

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.

  1. Add autoscaled VMS nodepool

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.

  1. Manual -> auto conversion

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.

  1. Auto -> manual conversion

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.

  1. Manage individual autoscale profiles

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.

  1. Guardrail behavior

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:

  • src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py
  • src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_custom.py
  • src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_agentpool_decorator.py

History Notes

[AKS] az aks create, az aks nodepool add: Support --enable-cluster-autoscaler for VirtualMachines agent pools to create pools in autoscale mode
[AKS] az aks nodepool update: Support --enable-cluster-autoscaler for VirtualMachines agent pools by converting manual scale profiles to autoscale profiles
[AKS] az aks nodepool update: Support --disable-cluster-autoscaler for VirtualMachines agent pools by converting autoscale profiles back to manual profiles
[AKS] az aks nodepool update: Block --update-cluster-autoscaler for VirtualMachines agent pools and direct to az 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 pool


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

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@a0x1ab

a0x1ab commented Jul 28, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@reneeli123
reneeli123 marked this pull request as ready for review July 28, 2026 04:04
@reneeli123
reneeli123 requested a review from a team as a code owner July 28, 2026 04:04
Copilot AI review requested due to automatic review settings July 28, 2026 04:04
@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.

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|delete commands for managing virtualMachinesProfile.scale.autoscale profiles on VMS pools.
  • Implemented VMS autoscaler conversion logic in the agentpool decorator for --enable-cluster-autoscaler / --disable-cluster-autoscaler, and blocked --update-cluster-autoscaler for VMS pools with guidance to use auto-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_update matches autoscale profiles with a case-sensitive a.size == current_node_vm_size comparison 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_size can remain None if the pool has no manual profiles and the user doesn't pass --node-vm-size, which later leads to creating an autoscale profile with size=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.

Comment thread src/azure-cli/azure/cli/command_modules/acs/custom.py
Comment thread src/azure-cli/azure/cli/command_modules/acs/custom.py
Comment thread src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py Outdated
Comment thread src/azure-cli/azure/cli/command_modules/acs/_help.py Outdated
…unts_in_autoscaler, correct help property path
@a0x1ab

a0x1ab commented Jul 28, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@FumingZhang FumingZhang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 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.
  2. 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):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Queued live test to validate the change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got an error, fixing it now

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@reneeli123 reneeli123 changed the title [AKS] az aks --enable-cluster-autoscaler az aks nodepool auto-scale: Add CAS support for VMS agent pool commands [AKS] az aks nodepool update, az aks nodepool auto-scale, --enable-cluster-autoscaler: Add CAS support for VMS agent pools Jul 28, 2026
@a0x1ab

a0x1ab commented Jul 28, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@a0x1ab

a0x1ab commented Jul 28, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@a0x1ab

a0x1ab commented Jul 28, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@a0x1ab

a0x1ab commented Jul 28, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

@a0x1ab

a0x1ab commented Jul 28, 2026

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

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

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

Labels

act-observability-squad AKS az aks/acs/openshift Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants