Skip to content

Commit

Permalink
[AKS] az aks create/update: Support in place param updates for mana…
Browse files Browse the repository at this point in the history
…ged prom (Azure#7859)
  • Loading branch information
bragi92 authored Aug 8, 2024
1 parent d6b7c11 commit 35508b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to

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

7.0.0b4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
from azext_aks_preview.azuremonitormetrics.recordingrules.create import create_rules
from azext_aks_preview.azuremonitormetrics.recordingrules.delete import delete_rules
from knack.util import CLIError
from knack.log import get_logger
from azure.cli.core.azclierror import InvalidArgumentValueError

logger = get_logger(__name__)


# pylint: disable=line-too-long
def link_azure_monitor_profile_artifacts(
Expand Down Expand Up @@ -81,17 +84,22 @@ def ensure_azure_monitor_profile_prerequisites(
cluster_name
)
else:
is_prometheus_enabled = False
# Check if already onboarded
if create_flow is False:
check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resource_group_name, cluster_name)
# Do RP registrations if required
rp_registrations(cmd, cluster_subscription)
link_azure_monitor_profile_artifacts(
cmd,
cluster_subscription,
cluster_resource_group_name,
cluster_name,
cluster_region,
raw_parameters,
create_flow
)
is_prometheus_enabled = check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resource_group_name, cluster_name)
if is_prometheus_enabled:
logger.info("Azure Prometheus is already enabled : This command will only allow updates to the KSM parameters. All other parameters will be ignored")
# Do RP registrations and artifact creation (DC*, rules, grafana link etc.) if not enabled already
# Otherwise move forward so that the addon can be enabled with new KSM parameters
if is_prometheus_enabled is False:
rp_registrations(cmd, cluster_subscription)
link_azure_monitor_profile_artifacts(
cmd,
cluster_subscription,
cluster_resource_group_name,
cluster_name,
cluster_region,
raw_parameters,
create_flow
)
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,5 @@ def check_azuremonitormetrics_profile(cmd, cluster_subscription, cluster_resourc
if "azureMonitorProfile" in values_array:
if "metrics" in values_array["azureMonitorProfile"]:
if values_array["azureMonitorProfile"]["metrics"]["enabled"] is True:
raise CLIError(
"Azure Monitor Metrics is already enabled for this cluster. Please use "
f"`az aks update --disable-azuremonitormetrics -g {cluster_resource_group_name} -n {cluster_name}` "
"and then try enabling."
)
return True
return False

0 comments on commit 35508b8

Please sign in to comment.