Skip to content
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

[AKS] Fix for app routing CLI #6968

Merged
merged 17 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 14 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
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Pending
* Vendor new SDK and bump API version to 2023-10-02-preview.
* Update the enum for `--os-sku` in command `az aks nodepool update` to only accept the expected Ubuntu and AzureLinux OSSKUs.

0.5.172
bosesuneha marked this conversation as resolved.
Show resolved Hide resolved
+++++++
* Fix for regression issue with `az aks create --enable-addon` command for enabling App Routing

0.5.171
+++++++
* Fix the issue that the value passed by option `--os-sku` in command `az aks nodepool update` is not processed.
Expand Down
27 changes: 7 additions & 20 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2750,14 +2750,14 @@ def set_up_ingress_web_app_routing(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

addons = self.context.get_enable_addons()
if "web_application_routing" in addons:
if "web_application_routing" in addons or self.context.get_enable_app_routing():
if mc.ingress_profile is None:
mc.ingress_profile = self.models.ManagedClusterIngressProfile()
dns_zone_resource_ids = self.context.get_dns_zone_resource_ids()
mc.ingress_profile.web_app_routing = self.models.ManagedClusterIngressProfileWebAppRouting(
enabled=True,
dns_zone_resource_ids=dns_zone_resource_ids,
)
mc.ingress_profile.web_app_routing = self.models.ManagedClusterIngressProfileWebAppRouting(enabled=True)
if "web_application_routing" in addons:
dns_zone_resource_ids = self.context.get_dns_zone_resource_ids()
mc.ingress_profile.web_app_routing.dns_zone_resource_ids = dns_zone_resource_ids

return mc

def set_up_workload_auto_scaler_profile(self, mc: ManagedCluster) -> ManagedCluster:
Expand Down Expand Up @@ -3023,19 +3023,6 @@ def set_up_metrics_profile(self, mc: ManagedCluster) -> ManagedCluster:

return mc

def set_up_app_routing_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Set up app routing profile for the ManagedCluster object.

:return: the ManagedCluster object
"""
self._ensure_mc(mc)

if self.context.get_enable_app_routing():
if mc.ingress_profile is None:
mc.ingress_profile = self.models.ManagedClusterIngressProfile()
mc.ingress_profile.web_app_routing = self.models.ManagedClusterIngressProfileWebAppRouting(enabled=True)
return mc

def set_up_node_provisioning_mode(self, mc: ManagedCluster) -> ManagedCluster:
self._ensure_mc(mc)

Expand Down Expand Up @@ -3082,7 +3069,7 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
# set up cluster snapshot
mc = self.set_up_creationdata_of_cluster_snapshot(mc)
# set up app routing profile
mc = self.set_up_app_routing_profile(mc)
mc = self.set_up_ingress_web_app_routing(mc)
# set up workload auto scaler profile
mc = self.set_up_workload_auto_scaler_profile(mc)
# set up vpa
Expand Down
602 changes: 303 additions & 299 deletions ...preview/azext_aks_preview/tests/latest/recordings/test_aks_approuting_enable_disable.yaml
100755 → 100644

Large diffs are not rendered by default.

441 changes: 198 additions & 243 deletions ...ts/latest/recordings/test_aks_approuting_enable_with_keyvault_secrets_provider_addon.yaml
100755 → 100644

Large diffs are not rendered by default.

1,028 changes: 293 additions & 735 deletions src/aks-preview/azext_aks_preview/tests/latest/recordings/test_aks_approuting_update.yaml
100755 → 100644

Large diffs are not rendered by default.

852 changes: 384 additions & 468 deletions ...w/azext_aks_preview/tests/latest/recordings/test_aks_approuting_zone_add_delete_list.yaml
100755 → 100644

Large diffs are not rendered by default.

592 changes: 277 additions & 315 deletions ...ks-preview/azext_aks_preview/tests/latest/recordings/test_aks_approuting_zone_update.yaml
100755 → 100644

Large diffs are not rendered by default.

Large diffs are not rendered by default.

208 changes: 128 additions & 80 deletions ...w/azext_aks_preview/tests/latest/recordings/test_aks_create_with_app_routing_enabled.yaml
100755 → 100644

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ def test_aks_machine_cmds(self, resource_group, resource_group_location):
'node_pool_name': node_pool_name,
'ssh_key_value': self.generate_ssh_keys(),
'machine_name': machine_name,
})
})
show_cmd = 'aks machine show '\
'--resource-group={resource_group} --cluster-name={name} ' \
'--nodepool-name={node_pool_name} --machine-name={machine_name} -o json'
Expand Down Expand Up @@ -4681,7 +4681,7 @@ def test_aks_migrate_cluster_to_cilium_dataplane(self, resource_group, resource_
create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} ' \
'--network-plugin azure --ssh-key-value={ssh_key_value} --kubernetes-version {k8s_version} ' \
'--network-plugin-mode=overlay'

self.cmd(create_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('networkProfile.networkPlugin', 'azure'),
Expand Down Expand Up @@ -6398,28 +6398,34 @@ def test_aks_create_with_web_application_routing(self, resource_group, resource_

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
def test_aks_create_web_application_routing_dns_zone_not_exist(self, resource_group, resource_group_location):
def test_aks_create_web_application_routing_with_private_dns_zone(self, resource_group, resource_group_location):
bosesuneha marked this conversation as resolved.
Show resolved Hide resolved
# Test creation failure when using an non-existing dns zone resource ID.
aks_name = self.create_random_name('cliakstest', 16)
private_dns_zone_name = self.create_random_name('cliakstest', 16) + ".xyz"
self.kwargs.update({
'resource_group': resource_group,
'name': aks_name,
'ssh_key_value': self.generate_ssh_keys()
'ssh_key_value': self.generate_ssh_keys(),
'private_dns_zone_name': private_dns_zone_name
})

create_private_dns_zone_cmd = 'network private-dns zone create -g {resource_group} -n {private_dns_zone_name}'
private_dns_zone_id = self.cmd(create_private_dns_zone_cmd, checks=[
self.check('name', private_dns_zone_name),
]).get_output_in_json()['id']

self.kwargs.update({ 'private_dns_zone_id': private_dns_zone_id })

create_cmd = 'aks create --resource-group={resource_group} --name={name} ' \
'--enable-addons web_application_routing ' \
'--dns-zone-resource-ids "/subscriptions/8ecadfc9-d1a3-4ea4-b844-0d9f87e4d7c8/resourcegroups/notexist/providers/Microsoft.Network/dnsZones/notexist.com" ' \
'--dns-zone-resource-ids={private_dns_zone_id} ' \
'--ssh-key-value={ssh_key_value} -o json'
try:
self.cmd(create_cmd, checks=[])
raise Exception("didn't get expected failure")
except (HttpResponseError, BadRequestError, AzureInternalError):
# expected failure
# HttpResponseError for without error mapping
# BadRequestError for not a valid dns zone resource
# AzureInternalError for requesting from a different tenant
pass

self.cmd(create_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('ingressProfile.webAppRouting.enabled', True),
self.check('ingressProfile.webAppRouting.dnsZoneResourceIds[0]', private_dns_zone_id),
])

@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
Expand Down Expand Up @@ -8025,8 +8031,8 @@ def test_aks_create_with_premium_sku(self, resource_group, resource_group_locati
# delete
self.cmd(
'aks delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()])


@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
def test_aks_update_with_premium_sku(self, resource_group, resource_group_location):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -899,7 +899,7 @@ def test_mc_get_enable_network_observability(self):
# fail on get_enable_network_observability mutual exclusive error
with self.assertRaises(MutuallyExclusiveArgumentError):
ctx_4.get_enable_network_observability()

# Flag set to False.
ctx_5 = AKSPreviewManagedClusterContext(
self.cmd,
Expand Down Expand Up @@ -4385,7 +4385,7 @@ def test_set_up_app_routing_profile(self):
)
mc_1 = self.models.ManagedCluster(location="test_location")
dec_1.context.attach_mc(mc_1)
dec_mc_1 = dec_1.set_up_app_routing_profile(mc_1)
dec_mc_1 = dec_1.set_up_ingress_web_app_routing(mc_1)
ground_truth_ingress_profile_1 = self.models.ManagedClusterIngressProfile(
web_app_routing=self.models.ManagedClusterIngressProfileWebAppRouting(
enabled=True,
Expand Down Expand Up @@ -7205,7 +7205,7 @@ def test_setup_supportPlan(self):
name="Base",
tier="Premium")
premiumCluster = self.models.ManagedCluster(
location="test_location",
location="test_location",
support_plan=None,
sku=premiumSKU,
)
Expand Down Expand Up @@ -7253,7 +7253,7 @@ def test_update_supportPlan(self):
name="Base",
tier="Premium")
ltsCluster = self.models.ManagedCluster(
location="test_location",
location="test_location",
sku=premiumSKU,
support_plan="AKSLongTermSupport",
)
Expand Down Expand Up @@ -7284,7 +7284,7 @@ def test_update_supportPlan(self):
self.assertEqual(nonLTSClusterCalculated, expectedNonLTSCluster)

normalCluster = self.models.ManagedCluster(
location="test_location",
location="test_location",
sku=self.models.ManagedClusterSKU(
name="Base",
tier="Standard"),
Expand Down