Skip to content
Closed
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
5 changes: 5 additions & 0 deletions src/connectedk8s/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

Release History
===============
1.10.11
+++++++
* Removed hardcoded public ARM endpoint URL for Government clouds.
* Fixed incorrect MCR endpoint URLs for Government cloud environments.

1.10.10
+++++
* Deprecated '--app-id' and '--app-secret' RBAC parameters from the extension by adding them to _breaking_change.py.
Expand Down
2 changes: 0 additions & 2 deletions src/connectedk8s/azext_connectedk8s/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ def cf_connectedk8s_prev_2025_08_01(
KubernetesClient,
subscription_id=os.getenv("AZURE_SUBSCRIPTION_ID"),
credential=credential,
base_url="https://management.azure.com",
per_call_policies=[headers_policy],
)
return client

client = get_mgmt_service_client(
cli_ctx,
KubernetesClient,
base_url="https://management.azure.com",
per_call_policies=[headers_policy],
)
return client
Expand Down
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
12 changes: 8 additions & 4 deletions src/connectedk8s/azext_connectedk8s/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@
# 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]
# For US Government and China clouds, use public mcr
if active_directory_endpoint.endswith((".us", ".cn")):
return "mcr.microsoft.com"

# Default MCR postfix
mcr_postfix = "com"
# 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
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
23 changes: 23 additions & 0 deletions src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../..")))
from azext_connectedk8s._utils import (
get_mcr_path,
process_helm_error_detail,
redact_sensitive_fields_from_string,
remove_rsa_private_key,
Expand Down Expand Up @@ -76,5 +77,27 @@ def test_redact_sensitive_fields_from_string():
)


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 = "login.chinacloudapi.cn"
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


if __name__ == "__main__":
pytest.main()
2 changes: 1 addition & 1 deletion src/connectedk8s/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# TODO: Confirm this is the right version number you want and it matches your
# HISTORY.rst entry.

VERSION = "1.10.10"
VERSION = "1.10.11"

# The full list of classifiers is available at
# https://pypi.python.org/pypi?%3Aaction=list_classifiers
Expand Down
Loading