Skip to content

Commit

Permalink
{AKS} Fix several tests (#4919)
Browse files Browse the repository at this point in the history
  • Loading branch information
FumingZhang authored Jun 2, 2022
1 parent 38f1124 commit d9ab65a
Show file tree
Hide file tree
Showing 8 changed files with 1,900 additions and 1,436 deletions.
2 changes: 2 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

* Fix `az aks addon list`, `az aks addon list-available` and `az aks addon show` commands when dealing with the web application routing addon.

0.5.78
++++++

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@
"test_aks_create_with_crg_id",
"test_aks_create_and_update_with_http_proxy_config",
"test_aks_snapshot",
"test_aks_custom_kubelet_identity",
"test_aks_nodepool_add_with_ossku_windows2022",
"test_list_trustedaccess_roles",
"test_aks_custom_ca_trust_flow"
"test_aks_custom_ca_trust_flow",
"test_aks_create_with_csi_driver_v2",
"test_aks_create_and_update_csi_driver_to_v2"
],
"fixed, waiting for rp rollout": [
"test_aks_create_with_azurekeyvaultkms",
"test_aks_update_with_azurekeyvaultkms"
]
}
}
12 changes: 8 additions & 4 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@
# gitops
CONST_GITOPS_ADDON_NAME = "gitops"

# web application routing
# only used as the key of the corresponding description, not to map to the key name in addonProfiles,
# since its configuration is actually stored in a separate ingress profile
CONST_WEB_APPLICATION_ROUTING_KEY_NAME = "ingress/webApplicationRouting"

# all supported addons
ADDONS = {
'http_application_routing': CONST_HTTP_APPLICATION_ROUTING_ADDON_NAME,
Expand All @@ -141,9 +146,7 @@
'open-service-mesh': CONST_OPEN_SERVICE_MESH_ADDON_NAME,
'azure-keyvault-secrets-provider': CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME,
'gitops': CONST_GITOPS_ADDON_NAME,
# web_application_routing key has no mapping to a name since ingress profile, not addon profile, is
# used to contain settings for web_application_routing
'web_application_routing': ""
'web_application_routing': CONST_WEB_APPLICATION_ROUTING_KEY_NAME
}

ADDONS_DESCRIPTIONS = {
Expand All @@ -156,7 +159,8 @@
CONST_CONFCOM_ADDON_NAME: '- enable confcom addon, this will enable SGX device plugin by default (PREVIEW).',
CONST_OPEN_SERVICE_MESH_ADDON_NAME: '- enable Open Service Mesh addon (PREVIEW).',
CONST_AZURE_KEYVAULT_SECRETS_PROVIDER_ADDON_NAME: '- enable Azure Keyvault Secrets Provider addon (PREVIEW).',
CONST_GITOPS_ADDON_NAME: '- enable GitOps (PREVIEW).'
CONST_GITOPS_ADDON_NAME: '- enable GitOps (PREVIEW).',
CONST_WEB_APPLICATION_ROUTING_KEY_NAME: '- enable web application routing (PREVIEW).'
}

# consts for credential
Expand Down
63 changes: 42 additions & 21 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2064,40 +2064,61 @@ def aks_addon_list_available():
return available_addons


def aks_addon_list(cmd, client, resource_group_name, name): # pylint: disable=unused-argument
addon_profiles = client.get(resource_group_name, name).addon_profiles

# pylint: disable=unused-argument
def aks_addon_list(cmd, client, resource_group_name, name):
mc = client.get(resource_group_name, name)
current_addons = []

for name, addon in ADDONS.items():
if not addon_profiles or addon not in addon_profiles:
current_addons.append({
"name": name,
"api_key": addon,
"enabled": False
})
for name, addon_key in ADDONS.items():
# web_application_routing is a special case, the configuration is stored in a separate profile
if name == "web_application_routing":
enabled = (
True
if mc.ingress_profile and
mc.ingress_profile.web_app_routing and
mc.ingress_profile.web_app_routing.enabled
else False
)
else:
current_addons.append({
"name": name,
"api_key": addon,
"enabled": addon_profiles[addon].enabled
})
enabled = (
True
if mc.addon_profiles and
addon_key in mc.addon_profiles and
mc.addon_profiles[addon_key].enabled
else False
)
current_addons.append({
"name": name,
"api_key": addon_key,
"enabled": enabled
})

return current_addons


def aks_addon_show(cmd, client, resource_group_name, name, addon): # pylint: disable=unused-argument
addon_profiles = client.get(resource_group_name, name).addon_profiles
# pylint: disable=unused-argument
def aks_addon_show(cmd, client, resource_group_name, name, addon):
mc = client.get(resource_group_name, name)
addon_key = ADDONS[addon]

if not addon_profiles or addon_key not in addon_profiles or not addon_profiles[addon_key].enabled:
raise CLIError(f'Addon "{addon}" is not enabled in this cluster.')
# web_application_routing is a special case, the configuration is stored in a separate profile
if addon == "web_application_routing":
if not mc.ingress_profile and not mc.ingress_profile.web_app_routing and not mc.ingress_profile.web_app_routing.enabled:
raise InvalidArgumentValueError(f'Addon "{addon}" is not enabled in this cluster.')
return {
"name": addon,
"api_key": addon_key,
"config": mc.ingress_profile.web_app_routing,
}

# normal addons
if not mc.addon_profiles or addon_key not in mc.addon_profiles or not mc.addon_profiles[addon_key].enabled:
raise InvalidArgumentValueError(f'Addon "{addon}" is not enabled in this cluster.')
return {
"name": addon,
"api_key": addon_key,
"config": addon_profiles[addon_key].config,
"identity": addon_profiles[addon_key].identity
"config": mc.addon_profiles[addon_key].config,
"identity": mc.addon_profiles[addon_key].identity
}


Expand Down
Loading

0 comments on commit d9ab65a

Please sign in to comment.