Skip to content
Merged
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
16 changes: 16 additions & 0 deletions src/aks-preview/azext_aks_preview/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 3 additions & 7 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)}')

Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)