-
Notifications
You must be signed in to change notification settings - Fork 1.5k
aks-preview: Support VMSS agent pool VM size resize via nodepool update #9732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1848,6 +1848,30 @@ def update_fips_image(self, agentpool: AgentPool) -> AgentPool: | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| return agentpool | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| def update_vm_size(self, agentpool: AgentPool) -> AgentPool: | ||||||||||||||||||||||||||||||||||||||||||||||||
| """Update VM size for the AgentPool object. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Allows changing the VM size (SKU) of an existing VMSS-based agent pool. | ||||||||||||||||||||||||||||||||||||||||||||||||
| The RP will perform a rolling upgrade (surge new nodes, drain old, delete old) | ||||||||||||||||||||||||||||||||||||||||||||||||
| to replace nodes with the new VM size. | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| Note: This is only for VMSS pools. VMs pools handle VM size changes through | ||||||||||||||||||||||||||||||||||||||||||||||||
| the autoscaler update path (update_auto_scaler_properties_vms). | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| :return: the AgentPool object | ||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||
| self._ensure_agentpool(agentpool) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # 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 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1865
to
+1871
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # 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 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2650,6 +2650,69 @@ def common_update_fips_image(self): | |||||||||||||||||||||||||||||||||||||||||||||||
| with self.assertRaises(MutuallyExclusiveArgumentError): | ||||||||||||||||||||||||||||||||||||||||||||||||
| dec_3.update_fips_image(agentpool_2) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| def common_update_vm_size(self): | ||||||||||||||||||||||||||||||||||||||||||||||||
| # Test case 1: No node_vm_size provided (should not change agentpool) | ||||||||||||||||||||||||||||||||||||||||||||||||
| dec_1 = AKSPreviewAgentPoolUpdateDecorator( | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.cmd, | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.client, | ||||||||||||||||||||||||||||||||||||||||||||||||
| {"node_vm_size": None}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.resource_type, | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.agentpool_decorator_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| # fail on passing the wrong agentpool object | ||||||||||||||||||||||||||||||||||||||||||||||||
| with self.assertRaises(CLIInternalError): | ||||||||||||||||||||||||||||||||||||||||||||||||
| dec_1.update_vm_size(None) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| agentpool_1 = self.create_initialized_agentpool_instance( | ||||||||||||||||||||||||||||||||||||||||||||||||
| vm_size="Standard_D2s_v3" | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| dec_1.context.attach_agentpool(agentpool_1) | ||||||||||||||||||||||||||||||||||||||||||||||||
| dec_agentpool_1 = dec_1.update_vm_size(agentpool_1) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ground_truth_agentpool_1 = self.create_initialized_agentpool_instance( | ||||||||||||||||||||||||||||||||||||||||||||||||
| vm_size="Standard_D2s_v3" | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.assertEqual(dec_agentpool_1, ground_truth_agentpool_1) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # Test case 2: node_vm_size provided (should update agentpool) | ||||||||||||||||||||||||||||||||||||||||||||||||
| dec_2 = AKSPreviewAgentPoolUpdateDecorator( | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.cmd, | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.client, | ||||||||||||||||||||||||||||||||||||||||||||||||
| {"node_vm_size": "Standard_D4s_v3"}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.resource_type, | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.agentpool_decorator_mode, | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| agentpool_2 = self.create_initialized_agentpool_instance( | ||||||||||||||||||||||||||||||||||||||||||||||||
| vm_size="Standard_D2s_v3" | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| dec_2.context.attach_agentpool(agentpool_2) | ||||||||||||||||||||||||||||||||||||||||||||||||
| dec_agentpool_2 = dec_2.update_vm_size(agentpool_2) | ||||||||||||||||||||||||||||||||||||||||||||||||
| ground_truth_agentpool_2 = self.create_initialized_agentpool_instance( | ||||||||||||||||||||||||||||||||||||||||||||||||
| vm_size="Standard_D4s_v3" | ||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||
| self.assertEqual(dec_agentpool_2, ground_truth_agentpool_2) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||
| # 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.