Skip to content

Commit fd6aa39

Browse files
authored
[AKS] az aks create/update: Support in place param updates for managed prom (#29273)
1 parent 6c2d859 commit fd6aa39

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/azure-cli/azure/cli/command_modules/acs/azuremonitormetrics/azuremonitorprofile.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,22 @@ def ensure_azure_monitor_profile_prerequisites(
8989
cluster_name
9090
)
9191
else:
92+
is_prometheus_enabled = False
9293
# Check if already onboarded
9394
if create_flow is False:
94-
check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resource_group_name, cluster_name)
95-
# Do RP registrations if required
96-
rp_registrations(cmd, cluster_subscription, raw_parameters)
97-
link_azure_monitor_profile_artifacts(
98-
cmd,
99-
cluster_subscription,
100-
cluster_resource_group_name,
101-
cluster_name,
102-
cluster_region,
103-
raw_parameters,
104-
create_flow
105-
)
95+
is_prometheus_enabled = check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resource_group_name, cluster_name)
96+
if is_prometheus_enabled:
97+
print("Azure Prometheus is already enabled : This command will only allow updates to the KSM parameters. All other parameters will be ignored")
98+
# Do RP registrations and artifact creation (DC*, rules, grafana link etc.) if not enabled already
99+
# Otherwise move forward so that the addon can be enabled with new KSM parameters
100+
if is_prometheus_enabled is False:
101+
rp_registrations(cmd, cluster_subscription, raw_parameters)
102+
link_azure_monitor_profile_artifacts(
103+
cmd,
104+
cluster_subscription,
105+
cluster_resource_group_name,
106+
cluster_name,
107+
cluster_region,
108+
raw_parameters,
109+
create_flow
110+
)

src/azure-cli/azure/cli/command_modules/acs/azuremonitormetrics/helper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,5 @@ def check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resourc
112112
if "azureMonitorProfile" in values_array:
113113
if "metrics" in values_array["azureMonitorProfile"]:
114114
if values_array["azureMonitorProfile"]["metrics"]["enabled"] is True:
115-
raise CLIError(f"Azure Monitor Metrics is already enabled for this cluster. Please use `az aks update --disable-azure-monitor-metrics -g {cluster_resource_group_name} -n {cluster_name}` and then try enabling.")
115+
return True
116+
return False

0 commit comments

Comments
 (0)