Skip to content

Commit 14d28f4

Browse files
aks-preview: Fix managedNATGatewayV2 outbound type being overwritten to loadBalancer
The dynamic completion logic in _get_outbound_type() did not include managedNATGatewayV2 in its list of known outbound types. When a user specified --outbound-type managedNATGatewayV2, the CLI treated it as an unrecognized value and silently overwrote it to loadBalancer before sending the request to the RP. Fixed in 3 places: - Dynamic completion list: preserve managedNATGatewayV2 instead of overwriting to loadBalancer - Basic LB SKU validation: reject managedNATGatewayV2 with basic SKU - Multi-zone warning: show zone-redundancy warning for V2 on update
1 parent efcf6e1 commit 14d28f4

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,7 @@ def _get_outbound_type(
561561
not read_from_mc and
562562
outbound_type not in [
563563
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
564+
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY_V2,
564565
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
565566
CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING,
566567
CONST_OUTBOUND_TYPE_NONE,
@@ -580,6 +581,7 @@ def _get_outbound_type(
580581
if outbound_type in [
581582
CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING,
582583
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
584+
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY_V2,
583585
CONST_OUTBOUND_TYPE_USER_ASSIGNED_NAT_GATEWAY,
584586
]:
585587
if safe_lower(self._get_load_balancer_sku(enable_validation=False)) == CONST_LOAD_BALANCER_SKU_BASIC:
@@ -622,7 +624,10 @@ def _get_outbound_type(
622624
a standard load balancer with IP addresses"
623625
)
624626
if self.decorator_mode == DecoratorMode.UPDATE:
625-
if outbound_type == CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY:
627+
if outbound_type in [
628+
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY,
629+
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY_V2,
630+
]:
626631
if self.mc.agent_pool_profiles is not None and len(self.mc.agent_pool_profiles) > 1:
627632
multizoned = False
628633
for ap in self.mc.agent_pool_profiles:

src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
DecoratorEarlyExitException,
103103
DecoratorMode,
104104
)
105+
from azext_aks_preview._consts import (
106+
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY_V2,
107+
)
105108
from dateutil.parser import parse
106109
from deepdiff import DeepDiff
107110

@@ -4686,6 +4689,22 @@ def test_get_outbound_type(self):
46864689
expect_outbound_type_4 = CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY
46874690
self.assertEqual(outbound_type_4,expect_outbound_type_4)
46884691

4692+
# managedNATGatewayV2 should be preserved, not overwritten to loadBalancer
4693+
ctx5 = AKSPreviewManagedClusterContext(
4694+
self.cmd,
4695+
AKSManagedClusterParamDict(
4696+
{"outbound_type": "managedNATGatewayV2"}
4697+
),
4698+
self.models,
4699+
decorator_mode=DecoratorMode.CREATE,
4700+
)
4701+
self.create_attach_agentpool_context(ctx5)
4702+
outbound_type_5 = ctx5._get_outbound_type(False, False, None)
4703+
self.assertEqual(
4704+
outbound_type_5,
4705+
CONST_OUTBOUND_TYPE_MANAGED_NAT_GATEWAY_V2,
4706+
)
4707+
46894708
def test_get_enable_gateway_api(self):
46904709
# default value
46914710
ctx_1 = AKSPreviewManagedClusterContext(

0 commit comments

Comments
 (0)