Skip to content

Commit 1ef7fdb

Browse files
authored
Merge branch 'main' into cdossa/natgatewayv2-aks-preview
2 parents 79a6d06 + c9666ae commit 1ef7fdb

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
* `az aks create/update`: Add `--outbound-type managedNATGatewayV2` support using Azure NAT Gateway Standard V2 SKU with IPv6, user-provided IPs, and IP prefixes.
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
@@ -7674,21 +7674,9 @@ def _setup_azure_monitor_logs(self, mc: ManagedCluster) -> None:
76747674
mc.addon_profiles = {}
76757675

76767676
CONST_MONITORING_ADDON_NAME = addon_consts.get("CONST_MONITORING_ADDON_NAME")
7677-
7678-
# Detect existing key (could be "omsagent" or "omsAgent" from Azure API)
7679-
existing_key = None
7680-
if CONST_MONITORING_ADDON_NAME in mc.addon_profiles:
7681-
existing_key = CONST_MONITORING_ADDON_NAME
7682-
elif CONST_MONITORING_ADDON_NAME_CAMELCASE in mc.addon_profiles:
7683-
existing_key = CONST_MONITORING_ADDON_NAME_CAMELCASE
7684-
7685-
if existing_key:
7686-
addon_profile = mc.addon_profiles[existing_key]
7687-
else:
7688-
addon_profile = self.models.ManagedClusterAddonProfile(enabled=False)
7689-
existing_key = CONST_MONITORING_ADDON_NAME
7690-
7691-
addon_profile.enabled = True
7677+
CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID = addon_consts.get(
7678+
"CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID")
7679+
CONST_MONITORING_USING_AAD_MSI_AUTH = addon_consts.get("CONST_MONITORING_USING_AAD_MSI_AUTH")
76927680

76937681
# Get or create workspace resource ID
76947682
workspace_resource_id = self.context.raw_param.get("workspace_resource_id")
@@ -7705,16 +7693,30 @@ def _setup_azure_monitor_logs(self, mc: ManagedCluster) -> None:
77057693
sanitize_func = self.context.external_functions.sanitize_loganalytics_ws_resource_id
77067694
workspace_resource_id = sanitize_func(workspace_resource_id)
77077695

7708-
CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID = addon_consts.get(
7709-
"CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID")
7710-
CONST_MONITORING_USING_AAD_MSI_AUTH = addon_consts.get("CONST_MONITORING_USING_AAD_MSI_AUTH")
7711-
7696+
# Call get_enable_msi_auth_for_monitoring BEFORE detecting the existing key,
7697+
# because the parent's implementation may normalize addon_profiles keys in-place
7698+
# (e.g., renaming "omsAgent" to "omsagent").
77127699
enable_msi_auth_bool = self.context.get_enable_msi_auth_for_monitoring()
77137700
if enable_msi_auth_bool:
77147701
enable_msi_auth = "true"
77157702
else:
77167703
enable_msi_auth = "false"
77177704

7705+
# Detect existing key (could be "omsagent" or "omsAgent" from Azure API)
7706+
existing_key = None
7707+
if CONST_MONITORING_ADDON_NAME in mc.addon_profiles:
7708+
existing_key = CONST_MONITORING_ADDON_NAME
7709+
elif CONST_MONITORING_ADDON_NAME_CAMELCASE in mc.addon_profiles:
7710+
existing_key = CONST_MONITORING_ADDON_NAME_CAMELCASE
7711+
7712+
if existing_key:
7713+
addon_profile = mc.addon_profiles[existing_key]
7714+
else:
7715+
addon_profile = self.models.ManagedClusterAddonProfile(enabled=False)
7716+
existing_key = CONST_MONITORING_ADDON_NAME
7717+
7718+
addon_profile.enabled = True
7719+
77187720
new_config = {
77197721
CONST_MONITORING_LOG_ANALYTICS_WORKSPACE_RESOURCE_ID: workspace_resource_id,
77207722
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)