Skip to content

Commit c0a78e8

Browse files
authored
Merge branch 'main' into zheweihu/c/gateway-api-without-asm-test
2 parents 0e59424 + c9666ae commit c0a78e8

File tree

3 files changed

+28
-24
lines changed

3 files changed

+28
-24
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ To release a new version, please select a new version number (usually plus 1 to
1212
Pending
1313
+++++++
1414
* Add a test case for Gateway API enablement without Azure Service Mesh addon.
15+
* Fix monitoring addon key casing compatibility with azure-cli/acs
1516

1617
19.0.0b28
1718
+++++++

src/aks-preview/azext_aks_preview/managed_cluster_decorator.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7597,21 +7597,9 @@ def _setup_azure_monitor_logs(self, mc: ManagedCluster) -> None:
75977597
mc.addon_profiles = {}
75987598

75997599
CONST_MONITORING_ADDON_NAME = addon_consts.get("CONST_MONITORING_ADDON_NAME")
7600-
7601-
# Detect existing key (could be "omsagent" or "omsAgent" from Azure API)
7602-
existing_key = None
7603-
if CONST_MONITORING_ADDON_NAME in mc.addon_profiles:
7604-
existing_key = CONST_MONITORING_ADDON_NAME
7605-
elif CONST_MONITORING_ADDON_NAME_CAMELCASE in mc.addon_profiles:
7606-
existing_key = CONST_MONITORING_ADDON_NAME_CAMELCASE
7607-
7608-
if existing_key:
7609-
addon_profile = mc.addon_profiles[existing_key]
7610-
else:
7611-
addon_profile = self.models.ManagedClusterAddonProfile(enabled=False)
7612-
existing_key = CONST_MONITORING_ADDON_NAME
7613-
7614-
addon_profile.enabled = True
7600+
CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID = addon_consts.get(
7601+
"CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID")
7602+
CONST_MONITORING_USING_AAD_MSI_AUTH = addon_consts.get("CONST_MONITORING_USING_AAD_MSI_AUTH")
76157603

76167604
# Get or create workspace resource ID
76177605
workspace_resource_id = self.context.raw_param.get("workspace_resource_id")
@@ -7628,16 +7616,30 @@ def _setup_azure_monitor_logs(self, mc: ManagedCluster) -> None:
76287616
sanitize_func = self.context.external_functions.sanitize_loganalytics_ws_resource_id
76297617
workspace_resource_id = sanitize_func(workspace_resource_id)
76307618

7631-
CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID = addon_consts.get(
7632-
"CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID")
7633-
CONST_MONITORING_USING_AAD_MSI_AUTH = addon_consts.get("CONST_MONITORING_USING_AAD_MSI_AUTH")
7634-
7619+
# Call get_enable_msi_auth_for_monitoring BEFORE detecting the existing key,
7620+
# because the parent's implementation may normalize addon_profiles keys in-place
7621+
# (e.g., renaming "omsAgent" to "omsagent").
76357622
enable_msi_auth_bool = self.context.get_enable_msi_auth_for_monitoring()
76367623
if enable_msi_auth_bool:
76377624
enable_msi_auth = "true"
76387625
else:
76397626
enable_msi_auth = "false"
76407627

7628+
# Detect existing key (could be "omsagent" or "omsAgent" from Azure API)
7629+
existing_key = None
7630+
if CONST_MONITORING_ADDON_NAME in mc.addon_profiles:
7631+
existing_key = CONST_MONITORING_ADDON_NAME
7632+
elif CONST_MONITORING_ADDON_NAME_CAMELCASE in mc.addon_profiles:
7633+
existing_key = CONST_MONITORING_ADDON_NAME_CAMELCASE
7634+
7635+
if existing_key:
7636+
addon_profile = mc.addon_profiles[existing_key]
7637+
else:
7638+
addon_profile = self.models.ManagedClusterAddonProfile(enabled=False)
7639+
existing_key = CONST_MONITORING_ADDON_NAME
7640+
7641+
addon_profile.enabled = True
7642+
76417643
new_config = {
76427644
CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID: workspace_resource_id,
76437645
CONST_MONITORING_USING_AAD_MSI_AUTH: enable_msi_auth

src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10922,12 +10922,13 @@ def test_setup_azure_monitor_logs_with_omsagent_camelcase(self):
1092210922
# Call _setup_azure_monitor_logs
1092310923
dec_1._setup_azure_monitor_logs(mc_1)
1092410924

10925-
# Verify: Should update existing omsAgent key (not create omsagent lowercase)
10926-
self.assertIn("omsAgent", mc_1.addon_profiles)
10927-
self.assertNotIn("omsagent", mc_1.addon_profiles) # Should NOT create duplicate
10928-
self.assertTrue(mc_1.addon_profiles["omsAgent"].enabled)
10925+
# Verify: The parent class normalizes addon keys to lowercase in-place,
10926+
# so "omsAgent" becomes "omsagent". The key point is no duplicate is created.
10927+
self.assertIn("omsagent", mc_1.addon_profiles)
10928+
self.assertEqual(len([k for k in mc_1.addon_profiles if k.lower() == "omsagent"]), 1) # No duplicate
10929+
self.assertTrue(mc_1.addon_profiles["omsagent"].enabled)
1092910930
self.assertEqual(
10930-
mc_1.addon_profiles["omsAgent"].config["logAnalyticsWorkspaceResourceID"],
10931+
mc_1.addon_profiles["omsagent"].config["logAnalyticsWorkspaceResourceID"],
1093110932
"/subscriptions/test/resourceGroups/test/providers/Microsoft.OperationalInsights/workspaces/test-workspace"
1093210933
)
1093310934

0 commit comments

Comments
 (0)