Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
2 changes: 1 addition & 1 deletion src/connectedk8s/azext_connectedk8s/_precheckutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def executing_cluster_diagnostic_checks_job(
)
return None

mcr_url = azext_utils.get_mcr_path(cmd)
mcr_url = azext_utils.get_mcr_path(cmd.cli_ctx.cloud.endpoints.active_directory)

chart_path = azext_utils.get_chart_path(
f"{mcr_url}/{consts.Cluster_Diagnostic_Checks_Job_Registry_Path}",
Expand Down
4 changes: 2 additions & 2 deletions src/connectedk8s/azext_connectedk8s/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@
# pylint: disable=bare-except


def get_mcr_path(cmd: CLICommand) -> str:
active_directory_array = cmd.cli_ctx.cloud.endpoints.active_directory.split(".")
def get_mcr_path(active_directory_endpoint: str) -> str:
active_directory_array = active_directory_endpoint.split(".")

# default for public, mc, ff clouds
mcr_postfix = active_directory_array[2]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _download_proxy_from_MCR(
operating_system: str,
architecture: str,
) -> None:
mcr_url = utils.get_mcr_path(cmd)
mcr_url = utils.get_mcr_path(cmd.cli_ctx.cloud.endpoints.active_directory)

mar_target = f"{mcr_url}/{consts.CLIENT_PROXY_MCR_TARGET}/{operating_system.lower()}/{architecture}/arc-proxy"
logger.debug(
Expand Down
2 changes: 1 addition & 1 deletion src/connectedk8s/azext_connectedk8s/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,7 @@ def install_helm_client(cmd: CLICommand) -> str:
"Downloading helm client for first time. This can take few minutes..."
)

mcr_url = utils.get_mcr_path(cmd)
mcr_url = utils.get_mcr_path(cmd.cli_ctx.cloud.endpoints.active_directory)

client = oras.client.OrasClient(hostname=mcr_url)
retry_count = 3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
redact_sensitive_fields_from_string,
remove_rsa_private_key,
scrub_proxy_url,
get_mcr_path,
)


Expand Down Expand Up @@ -75,6 +76,22 @@ def test_redact_sensitive_fields_from_string():
== expected_output_partial
)

def test_get_mcr_path():
input_active_directory = "login.microsoftonline.com"
expected_output = "mcr.microsoft.com"
assert(get_mcr_path(input_active_directory) == expected_output)

input_active_directory = "login.microsoftonline.us"
expected_output = "mcr.microsoft.com"
assert(get_mcr_path(input_active_directory) == expected_output)

input_active_directory = "https://login.microsoftonline.microsoft.foo"
expected_output = "mcr.microsoft.foo"
assert(get_mcr_path(input_active_directory) == expected_output)

input_active_directory = "https://login.microsoftonline.some.cloud.bar"
expected_output = "mcr.microsoft.some.cloud.bar"
assert(get_mcr_path(input_active_directory) == expected_output)

@atchutbarli atchutbarli Oct 13, 2025

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a combination for mooncake endpoint - https://login.partner.microsoftonline.cn as well.
it will cover an extra case where the length is 4 but not microsoft at the second index


if __name__ == "__main__":
pytest.main()
2 changes: 1 addition & 1 deletion src/k8s-extension/azext_k8s_extension/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ def install_helm_client(cmd: CLICommand) -> str:
"Downloading helm client for first time. This can take few minutes..."
)

mcr_url = utils.get_mcr_path(cmd)
mcr_url = utils.get_mcr_path(cmd.cli_ctx.cloud.endpoints.active_directory)

client = oras.client.OrasClient(hostname=mcr_url)
retry_count = 3
Expand Down
6 changes: 3 additions & 3 deletions src/k8s-extension/azext_k8s_extension/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,11 @@ def create_folder_diagnosticlogs(folder_name: str, base_folder_name: str) -> tup
)
return "", False

def get_mcr_path(cmd: CLICommand) -> str:
active_directory_array = cmd.cli_ctx.cloud.endpoints.active_directory.split(".")
def get_mcr_path(active_directory_endpoint: str) -> str:
active_directory_array = active_directory_endpoint.split(".")

# default for public, mc, ff clouds
mcr_postfix = active_directory_array[2]
mcr_postfix = ".com"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it applicable for mooncake as well?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it is.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

verified too,thanks

# special cases for USSec, exclude part of suffix
if len(active_directory_array) == 4 and active_directory_array[2] == "microsoft":
mcr_postfix = active_directory_array[3]
Expand Down
Loading