Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -2366,13 +2366,21 @@ def get_sku_name(self) -> str:
skuName = CONST_MANAGED_CLUSTER_SKU_NAME_BASE
return skuName

@staticmethod
def _raise_missing_vnet_subnet_for_outbound_type(outbound_type: str, sku_name: str) -> None:
def _raise_missing_vnet_subnet_for_outbound_type(self, outbound_type: str, sku_name: str) -> None:
if outbound_type == CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING:
subnet_requirement = "a route table with egress rules"
else:
subnet_requirement = "a NAT gateway with outbound ips"

if self.decorator_mode == DecoratorMode.UPDATE:
raise InvalidArgumentValueError(
f"Updating outbound type to {outbound_type} is only supported for clusters created with "
"--vnet-subnet-id. Clusters using an AKS-managed VNet can't be updated to this outbound type. "
"Please refer to "
"https://learn.microsoft.com/en-us/azure/aks/egress-outboundtype#updating-outboundtype-after-cluster-creation " # pylint:disable=line-too-long
"for more details."
)

if sku_name == CONST_MANAGED_CLUSTER_SKU_NAME_AUTOMATIC:
raise RequiredArgumentMissingError(
"--vnet-subnet-id must be specified for {outbound_type}. For an Automatic cluster "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,24 @@ def test_get_outbound_type(self):
ctx_1.attach_mc(mc)
self.assertEqual(ctx_1.get_outbound_type(), "test_outbound_type")

ctx_1_1 = AKSManagedClusterContext(
self.cmd,
AKSManagedClusterParamDict(
{
"outbound_type": CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING,
}
),
self.models,
DecoratorMode.UPDATE,
)
ctx_1_1.agentpool_context = mock.MagicMock()
ctx_1_1.agentpool_context.get_vnet_subnet_id.return_value = None
with self.assertRaisesRegex(
InvalidArgumentValueError,
"only supported for clusters created with --vnet-subnet-id",
):
ctx_1_1.get_outbound_type()

# invalid parameter
ctx_2 = AKSManagedClusterContext(
self.cmd,
Expand Down