Skip to content

Commit 35508b8

Browse files
authored
[AKS] az aks create/update: Support in place param updates for managed prom (Azure#7859)
1 parent d6b7c11 commit 35508b8

File tree

3 files changed

+23
-17
lines changed

3 files changed

+23
-17
lines changed

src/aks-preview/HISTORY.rst

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to
1111

1212
Pending
1313
+++++++
14+
* az aks create/update: Support in place param updates for managed prom
1415
* Vendor new SDK and bump API version to 2024-06-02-preview.
1516

1617
7.0.0b4

src/aks-preview/azext_aks_preview/azuremonitormetrics/azuremonitorprofile.py

+20-12
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
from azext_aks_preview.azuremonitormetrics.recordingrules.create import create_rules
1414
from azext_aks_preview.azuremonitormetrics.recordingrules.delete import delete_rules
1515
from knack.util import CLIError
16+
from knack.log import get_logger
1617
from azure.cli.core.azclierror import InvalidArgumentValueError
1718

19+
logger = get_logger(__name__)
20+
1821

1922
# pylint: disable=line-too-long
2023
def link_azure_monitor_profile_artifacts(
@@ -81,17 +84,22 @@ def ensure_azure_monitor_profile_prerequisites(
8184
cluster_name
8285
)
8386
else:
87+
is_prometheus_enabled = False
8488
# Check if already onboarded
8589
if create_flow is False:
86-
check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resource_group_name, cluster_name)
87-
# Do RP registrations if required
88-
rp_registrations(cmd, cluster_subscription)
89-
link_azure_monitor_profile_artifacts(
90-
cmd,
91-
cluster_subscription,
92-
cluster_resource_group_name,
93-
cluster_name,
94-
cluster_region,
95-
raw_parameters,
96-
create_flow
97-
)
90+
is_prometheus_enabled = check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resource_group_name, cluster_name)
91+
if is_prometheus_enabled:
92+
logger.info("Azure Prometheus is already enabled : This command will only allow updates to the KSM parameters. All other parameters will be ignored")
93+
# Do RP registrations and artifact creation (DC*, rules, grafana link etc.) if not enabled already
94+
# Otherwise move forward so that the addon can be enabled with new KSM parameters
95+
if is_prometheus_enabled is False:
96+
rp_registrations(cmd, cluster_subscription)
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+
)

src/aks-preview/azext_aks_preview/azuremonitormetrics/helper.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,5 @@ def check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resourc
106106
if "azureMonitorProfile" in values_array:
107107
if "metrics" in values_array["azureMonitorProfile"]:
108108
if values_array["azureMonitorProfile"]["metrics"]["enabled"] is True:
109-
raise CLIError(
110-
"Azure Monitor Metrics is already enabled for this cluster. Please use "
111-
f"`az aks update --disable-azuremonitormetrics -g {cluster_resource_group_name} -n {cluster_name}` "
112-
"and then try enabling."
113-
)
109+
return True
110+
return False

0 commit comments

Comments
 (0)