From 55c2945c41722d9a35daa42264504dcec620ced0 Mon Sep 17 00:00:00 2001 From: hapate Date: Mon, 6 Oct 2025 10:19:25 -0700 Subject: [PATCH 01/15] bug fix for ffx ffx pointing to mcr.us - this needs to be defaulted to .com --- src/k8s-extension/azext_k8s_extension/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k8s-extension/azext_k8s_extension/utils.py b/src/k8s-extension/azext_k8s_extension/utils.py index 767550ccef8..c0917de8ea3 100644 --- a/src/k8s-extension/azext_k8s_extension/utils.py +++ b/src/k8s-extension/azext_k8s_extension/utils.py @@ -365,7 +365,7 @@ def get_mcr_path(cmd: CLICommand) -> str: active_directory_array = cmd.cli_ctx.cloud.endpoints.active_directory.split(".") # default for public, mc, ff clouds - mcr_postfix = active_directory_array[2] + 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] From 138a0a5223b305aff0c951b41efe4ceb4494a629 Mon Sep 17 00:00:00 2001 From: hapate Date: Sun, 12 Oct 2025 14:43:17 -0700 Subject: [PATCH 02/15] Updated get_mcr_path updated method to input endpoint. Refactor needed to allow for better testing. --- src/k8s-extension/azext_k8s_extension/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/utils.py b/src/k8s-extension/azext_k8s_extension/utils.py index c0917de8ea3..627a870f957 100644 --- a/src/k8s-extension/azext_k8s_extension/utils.py +++ b/src/k8s-extension/azext_k8s_extension/utils.py @@ -361,8 +361,8 @@ 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 = ".com" From da75dc586c81792000789364b35b2ceb375c9f4f Mon Sep 17 00:00:00 2001 From: hapate Date: Sun, 12 Oct 2025 14:48:02 -0700 Subject: [PATCH 03/15] update get_mcr method invoke --- src/connectedk8s/azext_connectedk8s/_precheckutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connectedk8s/azext_connectedk8s/_precheckutils.py b/src/connectedk8s/azext_connectedk8s/_precheckutils.py index b10c9a22241..231f2b4c659 100644 --- a/src/connectedk8s/azext_connectedk8s/_precheckutils.py +++ b/src/connectedk8s/azext_connectedk8s/_precheckutils.py @@ -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}", From 28ce51a1fc66a0ebbe7f9d9c4ceedd28ef997649 Mon Sep 17 00:00:00 2001 From: hapate Date: Sun, 12 Oct 2025 14:55:03 -0700 Subject: [PATCH 04/15] update get_mcr_path helper method to remove aad endpoint resolve --- src/connectedk8s/azext_connectedk8s/_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/connectedk8s/azext_connectedk8s/_utils.py b/src/connectedk8s/azext_connectedk8s/_utils.py index 6717ed907c1..923b9a428d4 100644 --- a/src/connectedk8s/azext_connectedk8s/_utils.py +++ b/src/connectedk8s/azext_connectedk8s/_utils.py @@ -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] From f1159ec28cbfa08d8454d9cc51c748a6a270c20b Mon Sep 17 00:00:00 2001 From: hapate Date: Sun, 12 Oct 2025 14:56:42 -0700 Subject: [PATCH 05/15] Update get_mcr_path invoke --- src/k8s-extension/azext_k8s_extension/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k8s-extension/azext_k8s_extension/custom.py b/src/k8s-extension/azext_k8s_extension/custom.py index f7626d06e58..6122ea61224 100644 --- a/src/k8s-extension/azext_k8s_extension/custom.py +++ b/src/k8s-extension/azext_k8s_extension/custom.py @@ -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 From 4c6096e6756a6a807e68f8b7bdf27652155e1d93 Mon Sep 17 00:00:00 2001 From: hapate Date: Sun, 12 Oct 2025 14:59:04 -0700 Subject: [PATCH 06/15] Update get_mcr_path invoke --- .../azext_connectedk8s/clientproxyhelper/_binaryutils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connectedk8s/azext_connectedk8s/clientproxyhelper/_binaryutils.py b/src/connectedk8s/azext_connectedk8s/clientproxyhelper/_binaryutils.py index c655b4269de..5097fb952cc 100644 --- a/src/connectedk8s/azext_connectedk8s/clientproxyhelper/_binaryutils.py +++ b/src/connectedk8s/azext_connectedk8s/clientproxyhelper/_binaryutils.py @@ -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( From 67771c25515ea40a4a8c48bde060de1a2a4a1ffb Mon Sep 17 00:00:00 2001 From: hapate Date: Sun, 12 Oct 2025 14:59:55 -0700 Subject: [PATCH 07/15] Update get_mcr_path invoke --- src/connectedk8s/azext_connectedk8s/custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connectedk8s/azext_connectedk8s/custom.py b/src/connectedk8s/azext_connectedk8s/custom.py index c5ed8ed8ec9..d90c0c760c0 100644 --- a/src/connectedk8s/azext_connectedk8s/custom.py +++ b/src/connectedk8s/azext_connectedk8s/custom.py @@ -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 From 4fb62dd6c87a30e8de558c0a8c4a25367ff3fcbc Mon Sep 17 00:00:00 2001 From: hapate Date: Sun, 12 Oct 2025 15:18:35 -0700 Subject: [PATCH 08/15] Add unit test for geT_mcr_path --- .../tests/unittests/test_utils_.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py b/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py index 768290b902a..ca82620ed79 100644 --- a/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py +++ b/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py @@ -13,6 +13,7 @@ redact_sensitive_fields_from_string, remove_rsa_private_key, scrub_proxy_url, + get_mcr_path, ) @@ -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.bar" + assert(get_mcr_path(input_active_directory) == expected_output) if __name__ == "__main__": pytest.main() From b5db13e502bc75384cd17cd33090f4564c943668 Mon Sep 17 00:00:00 2001 From: hapate Date: Sun, 12 Oct 2025 15:54:28 -0700 Subject: [PATCH 09/15] fix test for agc cloud --- .../azext_connectedk8s/tests/unittests/test_utils_.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py b/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py index ca82620ed79..02aaf5211d3 100644 --- a/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py +++ b/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py @@ -90,7 +90,7 @@ def test_get_mcr_path(): assert(get_mcr_path(input_active_directory) == expected_output) input_active_directory = "https://login.microsoftonline.some.cloud.bar" - expected_output = "mcr.microsoft.bar" + expected_output = "mcr.microsoft.some.cloud.bar" assert(get_mcr_path(input_active_directory) == expected_output) if __name__ == "__main__": From 710936361b147ced4eb1cc7596a9b02cf055f89b Mon Sep 17 00:00:00 2001 From: hapate Date: Wed, 15 Oct 2025 08:33:48 -0700 Subject: [PATCH 10/15] addition test for mc cloud --- .../azext_connectedk8s/tests/unittests/test_utils_.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py b/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py index 02aaf5211d3..cbc52394589 100644 --- a/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py +++ b/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py @@ -84,6 +84,10 @@ def test_get_mcr_path(): 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" From 5fbdd63a25186329788138250c0d1f94bf8b0693 Mon Sep 17 00:00:00 2001 From: Bavneet Singh Date: Wed, 15 Oct 2025 14:12:52 -0700 Subject: [PATCH 11/15] fix CI test issues- ruff formatting, linting and delete regex match --- .../tests/unittests/test_utils_.py | 16 +++++++++------- .../EnableDisableFeatures.Tests.ps1 | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py b/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py index cbc52394589..32d1da1e3b4 100644 --- a/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py +++ b/src/connectedk8s/azext_connectedk8s/tests/unittests/test_utils_.py @@ -9,11 +9,11 @@ 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, scrub_proxy_url, - get_mcr_path, ) @@ -76,26 +76,28 @@ 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) + 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) + 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) - + 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) + 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) + assert get_mcr_path(input_active_directory) == expected_output + if __name__ == "__main__": pytest.main() diff --git a/testing/test/configurations/EnableDisableFeatures.Tests.ps1 b/testing/test/configurations/EnableDisableFeatures.Tests.ps1 index ce5ff9bd367..8c6f1f5d1f3 100644 --- a/testing/test/configurations/EnableDisableFeatures.Tests.ps1 +++ b/testing/test/configurations/EnableDisableFeatures.Tests.ps1 @@ -106,6 +106,6 @@ Describe 'ConnectedK8s Enable Disable Features Scenario' { # Configuration should be removed from the resource model - expect ResourceNotFound error $output = Invoke-AzCommand "az connectedk8s show -n $($ENVCONFIG.arcClusterName) -g $($ENVCONFIG.resourceGroup)" 2>&1 - $output | Should -Match "ResourceNotFound" + $output | Should -Match "(ResourceNotFound|could not be found|not found)" } } \ No newline at end of file From dd3c1f60beaca3ee1dccd33c67375b845cb4c22e Mon Sep 17 00:00:00 2001 From: hapate Date: Wed, 15 Oct 2025 14:37:59 -0700 Subject: [PATCH 12/15] Fix MCR postfix to always use '.com' --- src/connectedk8s/azext_connectedk8s/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/connectedk8s/azext_connectedk8s/_utils.py b/src/connectedk8s/azext_connectedk8s/_utils.py index 923b9a428d4..260ea672b29 100644 --- a/src/connectedk8s/azext_connectedk8s/_utils.py +++ b/src/connectedk8s/azext_connectedk8s/_utils.py @@ -62,7 +62,7 @@ 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" # 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] From f79ffd92656fd9d1089d6b9365633d0632937345 Mon Sep 17 00:00:00 2001 From: Bavneet Singh Date: Wed, 15 Oct 2025 15:03:05 -0700 Subject: [PATCH 13/15] fix CI testcase for mcr path --- src/connectedk8s/azext_connectedk8s/_utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/connectedk8s/azext_connectedk8s/_utils.py b/src/connectedk8s/azext_connectedk8s/_utils.py index 260ea672b29..d2a746156d9 100644 --- a/src/connectedk8s/azext_connectedk8s/_utils.py +++ b/src/connectedk8s/azext_connectedk8s/_utils.py @@ -61,8 +61,13 @@ def get_mcr_path(active_directory_endpoint: str) -> str: active_directory_array = active_directory_endpoint.split(".") - # default for public, mc, ff clouds - mcr_postfix = ".com" + # For US Government and China clouds, use public mcr + if (active_directory_endpoint.endswith(".us") or + active_directory_endpoint.endswith(".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] From b62c8dc2d562d2f6de10a450bcdb5e3ae85f1d97 Mon Sep 17 00:00:00 2001 From: Bavneet Singh Date: Wed, 15 Oct 2025 15:21:43 -0700 Subject: [PATCH 14/15] fix ruff formatting --- src/connectedk8s/azext_connectedk8s/_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/connectedk8s/azext_connectedk8s/_utils.py b/src/connectedk8s/azext_connectedk8s/_utils.py index d2a746156d9..e3268806f7b 100644 --- a/src/connectedk8s/azext_connectedk8s/_utils.py +++ b/src/connectedk8s/azext_connectedk8s/_utils.py @@ -62,8 +62,7 @@ def get_mcr_path(active_directory_endpoint: str) -> str: active_directory_array = active_directory_endpoint.split(".") # For US Government and China clouds, use public mcr - if (active_directory_endpoint.endswith(".us") or - active_directory_endpoint.endswith(".cn")): + if active_directory_endpoint.endswith((".us", ".cn")): return "mcr.microsoft.com" # Default MCR postfix From 4013540e3c52eaf60561e3138edc21d3528b945b Mon Sep 17 00:00:00 2001 From: hapate Date: Wed, 15 Oct 2025 15:29:51 -0700 Subject: [PATCH 15/15] Update get_mcr_path for cloud-specific handling Added handling for US Government and China clouds in MCR path. --- src/k8s-extension/azext_k8s_extension/utils.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/k8s-extension/azext_k8s_extension/utils.py b/src/k8s-extension/azext_k8s_extension/utils.py index 627a870f957..345d92f9016 100644 --- a/src/k8s-extension/azext_k8s_extension/utils.py +++ b/src/k8s-extension/azext_k8s_extension/utils.py @@ -364,8 +364,12 @@ def create_folder_diagnosticlogs(folder_name: str, base_folder_name: str) -> tup def get_mcr_path(active_directory_endpoint: str) -> str: active_directory_array = active_directory_endpoint.split(".") - # default for public, mc, ff clouds - mcr_postfix = ".com" + # 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]