Skip to content

Commit 7c4a49d

Browse files
Merge branch 'dev' into agent-assist/azure-azure-cli-issue-34186-f920502ff5cf
2 parents f69ef0e + fec1915 commit 7c4a49d

5 files changed

Lines changed: 116 additions & 3 deletions

File tree

‎src/azure-cli/azure/cli/command_modules/acs/_help.py‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,7 @@
21912191
- name: --enable-fips-image
21922192
type: bool
21932193
short-summary: Use FIPS-enabled OS on agent nodes.
2194+
long-summary: Automatically enabled for Windows2025 node pools because Windows2025 requires a FIPS-enabled OS image.
21942195
- name: --snapshot-id
21952196
type: string
21962197
short-summary: The source snapshot id used to create this nodepool.
@@ -2401,7 +2402,10 @@
24012402
short-summary: Enable Managed DRANET on the node pool.
24022403
- name: --os-sku
24032404
type: string
2404-
short-summary: The os-sku of the agent node pool.
2405+
short-summary: The OS SKU of the agent node pool.
2406+
long-summary: |
2407+
Windows2022 node pools can be upgraded to Windows2025. Specify --enable-fips-image when upgrading a non-FIPS node pool.
2408+
Downgrading from Windows2025 to Windows2022 is not supported.
24052409
- name: --enable-fips-image
24062410
type: bool
24072411
short-summary: Switch to use FIPS-enabled OS on agent nodes.
@@ -2447,6 +2451,11 @@
24472451
text: az aks nodepool update --disable-cluster-autoscaler -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster
24482452
- name: Update min-count or max-count for cluster autoscaler.
24492453
text: az aks nodepool update --update-cluster-autoscaler --min-count 1 --max-count 10 -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster
2454+
- name: Upgrade a Windows2022 node pool to Windows2025 with a FIPS-enabled OS image.
2455+
text: |
2456+
az aks nodepool update --resource-group MyResourceGroup \\
2457+
--cluster-name MyManagedCluster --name npwin \\
2458+
--os-sku Windows2025 --enable-fips-image
24502459
"""
24512460

24522461
helps["aks nodepool upgrade"] = """

‎src/azure-cli/azure/cli/command_modules/acs/_params.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@
202202
node_mode_types = [CONST_NODEPOOL_MODE_SYSTEM, CONST_NODEPOOL_MODE_USER, CONST_NODEPOOL_MODE_GATEWAY]
203203
node_os_skus_create = [CONST_OS_SKU_AZURELINUX, CONST_OS_SKU_AZURELINUX3, CONST_OS_SKU_AZURECONTAINERLINUX, CONST_OS_SKU_UBUNTU, CONST_OS_SKU_CBLMARINER, CONST_OS_SKU_MARINER, CONST_OS_SKU_UBUNTU2204, CONST_OS_SKU_UBUNTU2404]
204204
node_os_skus = node_os_skus_create + [CONST_OS_SKU_WINDOWS2019, CONST_OS_SKU_WINDOWS2022, CONST_OS_SKU_WINDOWS2025]
205-
node_os_skus_update = [CONST_OS_SKU_AZURELINUX, CONST_OS_SKU_AZURELINUX3, CONST_OS_SKU_AZURECONTAINERLINUX, CONST_OS_SKU_UBUNTU, CONST_OS_SKU_UBUNTU2204, CONST_OS_SKU_UBUNTU2404]
205+
node_os_skus_update = [CONST_OS_SKU_AZURELINUX, CONST_OS_SKU_AZURELINUX3, CONST_OS_SKU_AZURECONTAINERLINUX, CONST_OS_SKU_UBUNTU, CONST_OS_SKU_UBUNTU2204, CONST_OS_SKU_UBUNTU2404, CONST_OS_SKU_WINDOWS2022, CONST_OS_SKU_WINDOWS2025]
206206
scale_down_modes = [CONST_SCALE_DOWN_MODE_DELETE, CONST_SCALE_DOWN_MODE_DEALLOCATE]
207207
pod_ip_allocation_modes = [CONST_NETWORK_POD_IP_ALLOCATION_MODE_DYNAMIC_INDIVIDUAL, CONST_NETWORK_POD_IP_ALLOCATION_MODE_STATIC_BLOCK]
208208

‎src/azure-cli/azure/cli/command_modules/acs/agentpool_decorator.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1482,7 +1482,7 @@ def get_enable_ultra_ssd(self) -> bool:
14821482

14831483
# Mutable Fips now allows changes after create
14841484
def get_enable_fips_image(self) -> bool:
1485-
"""Obtain the value of enable_fips_image, default value is False.
1485+
"""Obtain enable_fips_image, defaulting to False except for new Windows2025 pools.
14861486
:return: bool
14871487
"""
14881488

@@ -1496,6 +1496,13 @@ def get_enable_fips_image(self) -> bool:
14961496
self.agentpool.enable_fips is not None
14971497
):
14981498
enable_fips_image = self.agentpool.enable_fips
1499+
elif self.get_os_sku() == CONST_OS_SKU_WINDOWS2025:
1500+
if self.get_disable_fips_image():
1501+
raise ArgumentUsageError(
1502+
'"--disable-fips-image" cannot be used with "--os-sku Windows2025", '
1503+
"which requires a FIPS-enabled OS image."
1504+
)
1505+
enable_fips_image = True
14991506

15001507
# Verify both flags have not been set
15011508
if enable_fips_image and self.get_disable_fips_image():

‎src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_agentpool_decorator.py‎

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,41 @@ def common_get_enable_fips_image(self):
14311431
# Update takes directly from flag value not from agentpool property
14321432
self.assertEqual(ctx_2.get_enable_fips_image(), False)
14331433

1434+
def common_get_enable_fips_image_windows2025(self):
1435+
cases = [
1436+
(DecoratorMode.CREATE, {"os_sku": CONST_OS_SKU_WINDOWS2025}, True),
1437+
(DecoratorMode.CREATE, {"os_sku": CONST_OS_SKU_WINDOWS2025, "enable_fips_image": True}, True),
1438+
(DecoratorMode.CREATE, {"os_sku": CONST_OS_SKU_WINDOWS2022}, False),
1439+
(DecoratorMode.CREATE, {"os_sku": "Ubuntu"}, False),
1440+
(DecoratorMode.CREATE, {"os_sku": "Ubuntu", "enable_fips_image": True}, True),
1441+
(DecoratorMode.UPDATE, {"os_sku": CONST_OS_SKU_WINDOWS2025}, False),
1442+
(DecoratorMode.UPDATE, {"os_sku": CONST_OS_SKU_WINDOWS2025, "enable_fips_image": True}, True),
1443+
]
1444+
for decorator_mode, raw_parameters, expected in cases:
1445+
with self.subTest(decorator_mode=decorator_mode, raw_parameters=raw_parameters):
1446+
ctx = AKSAgentPoolContext(
1447+
self.cmd,
1448+
AKSAgentPoolParamDict(raw_parameters),
1449+
self.models,
1450+
decorator_mode,
1451+
self.agentpool_decorator_mode,
1452+
)
1453+
self.assertEqual(ctx.get_enable_fips_image(), expected)
1454+
ctx.attach_agentpool(
1455+
self.create_initialized_agentpool_instance(os_sku=raw_parameters["os_sku"])
1456+
)
1457+
self.assertEqual(ctx.get_enable_fips_image(), expected)
1458+
1459+
ctx = AKSAgentPoolContext(
1460+
self.cmd,
1461+
AKSAgentPoolParamDict({"os_sku": CONST_OS_SKU_WINDOWS2025, "disable_fips_image": True}),
1462+
self.models,
1463+
DecoratorMode.CREATE,
1464+
self.agentpool_decorator_mode,
1465+
)
1466+
with self.assertRaisesRegex(ArgumentUsageError, "Windows2025"):
1467+
ctx.get_enable_fips_image()
1468+
14341469
def common_get_disable_fips_image(self):
14351470
# default
14361471
ctx_1 = AKSAgentPoolContext(
@@ -2108,6 +2143,9 @@ def test_get_enable_ultra_ssd(self):
21082143
def test_get_enable_fips_image(self):
21092144
self.common_get_enable_fips_image()
21102145

2146+
def test_get_enable_fips_image_windows2025(self):
2147+
self.common_get_enable_fips_image_windows2025()
2148+
21112149
def test_get_disable_fips_image(self):
21122150
self.common_get_disable_fips_image()
21132151

@@ -2319,6 +2357,9 @@ def test_get_enable_ultra_ssd(self):
23192357
def test_get_enable_fips_image(self):
23202358
self.common_get_enable_fips_image()
23212359

2360+
def test_get_enable_fips_image_windows2025(self):
2361+
self.common_get_enable_fips_image_windows2025()
2362+
23222363
def test_get_enable_artifact_streaming(self):
23232364
self.common_get_enable_artifact_streaming()
23242365

@@ -4093,6 +4134,53 @@ def test_update_agentpool(self):
40934134
headers={},
40944135
)
40954136

4137+
def test_update_agentpool_windows2025(self):
4138+
for current_fips, enable_fips_image, expected_fips in [
4139+
(False, True, True),
4140+
(True, False, True),
4141+
(False, False, False),
4142+
]:
4143+
with self.subTest(current_fips=current_fips, enable_fips_image=enable_fips_image):
4144+
dec = AKSAgentPoolUpdateDecorator(
4145+
self.cmd,
4146+
self.client,
4147+
{
4148+
"resource_group_name": "test_rg_name",
4149+
"cluster_name": "test_cluster_name",
4150+
"nodepool_name": "test_nodepool_name",
4151+
"os_sku": CONST_OS_SKU_WINDOWS2025,
4152+
"enable_fips_image": enable_fips_image,
4153+
},
4154+
self.resource_type,
4155+
self.agentpool_decorator_mode,
4156+
)
4157+
self.client.get = Mock(
4158+
return_value=self.create_initialized_agentpool_instance(
4159+
nodepool_name="test_nodepool_name",
4160+
os_type="Windows",
4161+
os_sku=CONST_OS_SKU_WINDOWS2022,
4162+
enable_fips=current_fips,
4163+
)
4164+
)
4165+
with patch(
4166+
"azure.cli.command_modules.acs.agentpool_decorator.cf_agent_pools",
4167+
return_value=Mock(list=Mock(return_value=[])),
4168+
):
4169+
agentpool = dec.update_agentpool_profile_default()
4170+
self.assertEqual(agentpool.os_sku, CONST_OS_SKU_WINDOWS2025)
4171+
self.assertEqual(agentpool.enable_fips, expected_fips)
4172+
with patch("azure.cli.command_modules.acs.agentpool_decorator.sdk_no_wait") as put_agentpool:
4173+
dec.update_agentpool(agentpool)
4174+
put_agentpool.assert_called_once_with(
4175+
False,
4176+
self.client.begin_create_or_update,
4177+
"test_rg_name",
4178+
"test_cluster_name",
4179+
"test_nodepool_name",
4180+
agentpool,
4181+
headers={},
4182+
)
4183+
40964184
def test_update_localdns_profile(self):
40974185
self.common_update_localdns_profile()
40984186

‎src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_validators.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,5 +2442,14 @@ def test_managed_ip_counts_and_byo_ips_mutually_exclusive(self):
24422442
validators.validate_nat_gateway_v2_params(self._ns(nat_gateway_outbound_ip_ids="/sub/ip", nat_gateway_outbound_ip_prefix_ids="/sub/pfx", outbound_type="managedNATGateway", nat_gateway_sku="StandardV2"))
24432443

24442444

2445+
class TestValidateOsSku(unittest.TestCase):
2446+
def test_nodepool_update_allows_windows2022_and_windows2025(self):
2447+
from azure.cli.command_modules.acs._params import node_os_skus_update
2448+
2449+
self.assertIn("Windows2022", node_os_skus_update)
2450+
self.assertIn("Windows2025", node_os_skus_update)
2451+
self.assertNotIn("Windows2019", node_os_skus_update)
2452+
2453+
24452454
if __name__ == "__main__":
24462455
unittest.main()

0 commit comments

Comments
 (0)