Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3167,6 +3167,8 @@ def aks_agentpool_upgrade(cmd, client, resource_group_name, cluster_name,
instance.upgrade_settings.node_soak_duration_in_minutes = node_soak_duration
if undrainable_node_behavior:
instance.upgrade_settings.undrainable_node_behavior = undrainable_node_behavior
if max_unavailable:
instance.upgrade_settings.max_unavailable = max_unavailable
Comment thread
Jenniferyingni marked this conversation as resolved.

# custom headers
aks_custom_headers = extract_comma_separated_string(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from azure.cli.command_modules.acs.custom import (
_get_command_context,
_update_addons,
aks_agentpool_upgrade,
aks_enable_addons,
aks_stop,
is_monitoring_addon_enabled,
Expand Down Expand Up @@ -1455,5 +1456,41 @@ def test_hlsm_not_auto_enabled_when_cnl_false(self, _mock_sub, mock_update, mock
self.assertIsNone(kwargs.get("enable_high_log_scale_mode"))


class AksAgentpoolUpgradeTest(unittest.TestCase):
def setUp(self):
self.cli = MockCLI()
self.cmd = MockCmd(self.cli)
self.models = AKSManagedClusterModels(self.cmd, ResourceType.MGMT_CONTAINERSERVICE)

@mock.patch("azure.cli.command_modules.acs.custom.sdk_no_wait")
def test_aks_agentpool_upgrade_sets_max_unavailable(self, mock_sdk_no_wait):
"""Test that max_unavailable is set on upgrade_settings during agentpool upgrade."""
AgentPoolUpgradeSettings = self.cmd.get_models(
"AgentPoolUpgradeSettings",
resource_type=ResourceType.MGMT_CONTAINERSERVICE,
operation_group="managed_clusters",
)
instance = mock.Mock()
instance.orchestrator_version = "1.32.0"
instance.provisioning_state = "Succeeded"
instance.upgrade_settings = AgentPoolUpgradeSettings()

client = mock.Mock()
client.get.return_value = instance

aks_agentpool_upgrade(
self.cmd,
client,
resource_group_name="rg",
cluster_name="cluster",
nodepool_name="nodepool1",
kubernetes_version="1.33.0",
max_unavailable="5",
yes=True,
)

self.assertEqual(instance.upgrade_settings.max_unavailable, "5")
mock_sdk_no_wait.assert_called_once()

if __name__ == "__main__":
unittest.main()
Loading