|
13 | 13 | from azext_aks_preview.azuremonitormetrics.recordingrules.create import create_rules
|
14 | 14 | from azext_aks_preview.azuremonitormetrics.recordingrules.delete import delete_rules
|
15 | 15 | from knack.util import CLIError
|
| 16 | +from knack.log import get_logger |
16 | 17 | from azure.cli.core.azclierror import InvalidArgumentValueError
|
17 | 18 |
|
| 19 | +logger = get_logger(__name__) |
| 20 | + |
18 | 21 |
|
19 | 22 | # pylint: disable=line-too-long
|
20 | 23 | def link_azure_monitor_profile_artifacts(
|
@@ -81,17 +84,22 @@ def ensure_azure_monitor_profile_prerequisites(
|
81 | 84 | cluster_name
|
82 | 85 | )
|
83 | 86 | else:
|
| 87 | + is_prometheus_enabled = False |
84 | 88 | # Check if already onboarded
|
85 | 89 | 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 | + ) |
0 commit comments