Skip to content

Commit

Permalink
Fix issues for az aks kollect on private clusters (#1685)
Browse files Browse the repository at this point in the history
  • Loading branch information
feiskyer authored May 18, 2020
1 parent da97509 commit a2bdac4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/aks-preview/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

Release History
===============
0.4.46
+++++
* Fix issues for az aks kollect on private clusters

0.4.45
+++++
* Add "--aks-custom-headers" for "az aks nodepool add" and "az aks update"

0.4.43
0.4.44
+++++
* Fix issues with monitoring addon enabling with CLI versions 2.4.0+

Expand Down
4 changes: 4 additions & 0 deletions src/aks-preview/azext_aks_preview/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,7 @@

CONST_NODEPOOL_MODE_SYSTEM = "System"
CONST_NODEPOOL_MODE_USER = "User"

# refer https://docs.microsoft.com/en-us/rest/api/storageservices/
# naming-and-referencing-containers--blobs--and-metadata#container-names
CONST_CONTAINER_NAME_MAX_LENGTH = 63
3 changes: 3 additions & 0 deletions src/aks-preview/azext_aks_preview/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

# pylint: disable=no-name-in-module,import-error
from .vendored_sdks.azure_mgmt_preview_aks.v2020_03_01.models import ManagedClusterAPIServerAccessProfile
from ._consts import CONST_CONTAINER_NAME_MAX_LENGTH
from ._consts import CONST_OUTBOUND_TYPE_LOAD_BALANCER, CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING


Expand Down Expand Up @@ -88,4 +89,6 @@ def _trim_fqdn_name_containing_hcp(normalized_fqdn: str) -> str:
attached
"""
storage_name_without_hcp, _, _ = normalized_fqdn.partition('-hcp-')
if len(storage_name_without_hcp) > CONST_CONTAINER_NAME_MAX_LENGTH:
return storage_name_without_hcp[:CONST_CONTAINER_NAME_MAX_LENGTH]
return storage_name_without_hcp
3 changes: 2 additions & 1 deletion src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,7 +1472,8 @@ def aks_kollect(cmd, # pylint: disable=too-many-statements,too-many-locals
os.remove(temp_yaml_path)

print()
normalized_fqdn = mc.fqdn.replace('.', '-')
fqdn = mc.fqdn if mc.fqdn is not None else mc.private_fqdn
normalized_fqdn = 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"{_trim_fqdn_name_containing_hcp(normalized_fqdn)}?{token_in_storage_account_url}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,9 @@ def test_trim_fqdn_name_containing_hcp(self):
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)

def test_trim_fqdn_name_not_containing_hcp(self):
container_name = 'abcdef-dns-ed55ba6d-e48fe2bd-b4bc-4aac-bc23-29bc44154fe1-privatelink-centralus-azmk8s-io'
expected_container_name = 'abcdef-dns-ed55ba6d-e48fe2bd-b4bc-4aac-bc23-29bc44154fe1-privat'
trim_container_name = helpers._trim_fqdn_name_containing_hcp(container_name)
self.assertEqual(expected_container_name, trim_container_name)

0 comments on commit a2bdac4

Please sign in to comment.