diff --git a/src/aks-preview/azext_aks_preview/_helpers.py b/src/aks-preview/azext_aks_preview/_helpers.py index b9a9bebda6c..419859bc938 100644 --- a/src/aks-preview/azext_aks_preview/_helpers.py +++ b/src/aks-preview/azext_aks_preview/_helpers.py @@ -73,3 +73,19 @@ def _parse_comma_separated_list(text): if text == "": return [] return text.split(",") + + +def _trim_fqdn_name_containing_hcp(normalized_fqdn: str) -> str: + """ + Trims the storage blob name and takes everything prior to "-hcp-". + Currently it is displayed wrong: i.e. at time of creation cli has + following limitation: + https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/ + error-storage-account-name + + :param normalized_fqdn: storage blob name + :return: storage_name_without_hcp: Storage name without the hcp value + attached + """ + storage_name_without_hcp, _, _ = normalized_fqdn.partition('-hcp-') + return storage_name_without_hcp diff --git a/src/aks-preview/azext_aks_preview/custom.py b/src/aks-preview/azext_aks_preview/custom.py index 66fffead11a..ab07b9366e4 100644 --- a/src/aks-preview/azext_aks_preview/custom.py +++ b/src/aks-preview/azext_aks_preview/custom.py @@ -74,7 +74,8 @@ from ._helpers import (_populate_api_server_access_profile, _set_vm_set_type, - _set_outbound_type, _parse_comma_separated_list) + _set_outbound_type, _parse_comma_separated_list, + _trim_fqdn_name_containing_hcp) from ._loadbalancer import (set_load_balancer_sku, is_load_balancer_profile_provided, update_load_balancer_profile, create_load_balancer_profile) from ._consts import CONST_INGRESS_APPGW_ADDON_NAME @@ -834,9 +835,6 @@ def aks_create(cmd, # pylint: disable=too-many-locals,too-many-statements,to if no_wait: raise CLIError('When --attach-acr and --enable-managed-identity are both specified, ' '--no-wait is not allowed, please wait until the whole operation succeeds.') - else: - # Attach acr operation will be handled after the cluster is created - pass else: _ensure_aks_acr(cmd.cli_ctx, client_id=service_principal_profile.client_id, @@ -1483,7 +1481,7 @@ def aks_kollect(cmd, # pylint: disable=too-many-statements,too-many-locals normalized_fqdn = mc.fqdn.replace('.', '-') token_in_storage_account_url = readonly_sas_token if readonly_sas_token is not None else sas_token log_storage_account_url = f"https://{storage_account_name}.blob.core.windows.net/" \ - f"{normalized_fqdn}?{token_in_storage_account_url}" + f"{_trim_fqdn_name_containing_hcp(normalized_fqdn)}?{token_in_storage_account_url}" print(f'{colorama.Fore.GREEN}Your logs are being uploaded to storage account {format_bright(storage_account_name)}') @@ -1500,8 +1498,6 @@ def aks_kollect(cmd, # pylint: disable=too-many-statements,too-many-locals else: display_diagnostics_report(temp_kubeconfig_path) - return - def aks_kanalyze(cmd, client, resource_group_name, name): colorama.init() diff --git a/src/aks-preview/azext_aks_preview/tests/latest/test_helpers.py b/src/aks-preview/azext_aks_preview/tests/latest/test_helpers.py index 605421e559e..b5da71fd6fc 100644 --- a/src/aks-preview/azext_aks_preview/tests/latest/test_helpers.py +++ b/src/aks-preview/azext_aks_preview/tests/latest/test_helpers.py @@ -44,3 +44,11 @@ def test_casing_as(self): version = "1.15.0" vm_type = helpers._set_vm_set_type("Availabilityset", version) self.assertEqual(vm_type, "AvailabilitySet") + + +class TestTrimContainerName(unittest.TestCase): + def test_trim_fqdn_name_containing_hcp(self): + container_name = 'abcdef-dns-ed55ba6d-hcp-centralus-azmk8s-io' + expected_container_name = 'abcdef-dns-ed55ba6d' + trim_container_name = helpers._trim_fqdn_name_containing_hcp(container_name) + self.assertEqual(expected_container_name, trim_container_name)