Skip to content

Commit

Permalink
{AKS} Update monitor metrics related option names (#6379)
Browse files Browse the repository at this point in the history
  • Loading branch information
FumingZhang authored Jun 11, 2023
1 parent aebf070 commit a89ce69
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 14 deletions.
4 changes: 4 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ To release a new version, please select a new version number (usually plus 1 to
Pending
+++++++

0.5.142
+++++++
* Deprecate option names `--enable-azuremonitormetrics` and `--disable-azuremonitormetrics`, use `--enable-azure-monitor-metrics` and `--disable-azure-monitor-metrics` instead, so as to be consistent with the option names in official azure-cli. Fix issue `\#26600 <https://github.com/Azure/azure-cli/issues/26600>`_.

0.5.141
+++++++
* Fix `az aks get-credentials` not using the value set by environment variable `KUBECONFIG`, see issue `\#26444 <https://github.com/Azure/azure-cli-extensions/issues/26444>`_.
Expand Down
9 changes: 9 additions & 0 deletions src/aks-preview/azext_aks_preview/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@
- name: --enable-azuremonitormetrics
type: bool
short-summary: Enable Azure Monitor Metrics Profile
- name: --enable-azure-monitor-metrics
type: bool
short-summary: Enable Azure Monitor Metrics Profile
- name: --azure-monitor-workspace-resource-id
type: string
short-summary: Resource ID of the Azure Monitor Workspace
Expand Down Expand Up @@ -963,6 +966,9 @@
- name: --enable-azuremonitormetrics
type: bool
short-summary: Enable Azure Monitor Metrics Profile
- name: --enable-azure-monitor-metrics
type: bool
short-summary: Enable Azure Monitor Metrics Profile
- name: --azure-monitor-workspace-resource-id
type: string
short-summary: Resource ID of the Azure Monitor Workspace
Expand All @@ -981,6 +987,9 @@
- name: --disable-azuremonitormetrics
type: bool
short-summary: Disable Azure Monitor Metrics Profile. This will delete all DCRA's associated with the cluster, any linked DCRs with the data stream = prometheus-stream and the recording rule groups created by the addon for this AKS cluster.
- name: --disable-azure-monitor-metrics
type: bool
short-summary: Disable Azure Monitor Metrics Profile. This will delete all DCRA's associated with the cluster, any linked DCRs with the data stream = prometheus-stream and the recording rule groups created by the addon for this AKS cluster.
- name: --enable-node-restriction
type: bool
short-summary: Enable node restriction option on cluster.
Expand Down
9 changes: 6 additions & 3 deletions src/aks-preview/azext_aks_preview/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ def load_arguments(self, _):
help='The guardrails version', is_preview=True)
c.argument('guardrails_excluded_ns', type=str, is_preview=True)
# azure monitor profile
c.argument('enable_azuremonitormetrics', action='store_true')
c.argument('enable_azuremonitormetrics', action='store_true', deprecate_info=c.deprecate(target='--enable-azuremonitormetrics', redirect='--enable-azure-monitor-metrics', hide=True))
c.argument('enable_azure_monitor_metrics', action='store_true')
c.argument('azure_monitor_workspace_resource_id', validator=validate_azuremonitorworkspaceresourceid)
c.argument('ksm_metric_labels_allow_list')
c.argument('ksm_metric_annotations_allow_list')
Expand Down Expand Up @@ -543,13 +544,15 @@ def load_arguments(self, _):
c.argument('enable_private_cluster', action='store_true', is_preview=True, help='enable private cluster for apiserver vnet integration')
c.argument('disable_private_cluster', action='store_true', is_preview=True, help='disable private cluster for apiserver vnet integration')
c.argument('private_dns_zone', is_preview=True)
c.argument('enable_azuremonitormetrics', action='store_true')
c.argument('enable_azuremonitormetrics', action='store_true', deprecate_info=c.deprecate(target='--enable-azuremonitormetrics', redirect='--enable-azure-monitor-metrics', hide=True))
c.argument('enable_azure_monitor_metrics', action='store_true')
c.argument('azure_monitor_workspace_resource_id', validator=validate_azuremonitorworkspaceresourceid)
c.argument('ksm_metric_labels_allow_list')
c.argument('ksm_metric_annotations_allow_list')
c.argument('grafana_resource_id', validator=validate_grafanaresourceid)
c.argument('enable_windows_recording_rules', action='store_true')
c.argument('disable_azuremonitormetrics', action='store_true')
c.argument('disable_azuremonitormetrics', action='store_true', deprecate_info=c.deprecate(target='--disable-azuremonitormetrics', redirect='--disable-azure-monitor-metrics', hide=True))
c.argument('disable_azure_monitor_metrics', action='store_true')
c.argument('enable_vpa', action='store_true', is_preview=True, help="enable vertical pod autoscaler for cluster")
c.argument('disable_vpa', action='store_true', is_preview=True, help="disable vertical pod autoscaler for cluster")
c.argument('cluster_snapshot_id', validator=validate_cluster_snapshot_id, is_preview=True)
Expand Down
3 changes: 3 additions & 0 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,7 @@ def aks_create(
enable_azure_service_mesh=None,
# azure monitor profile
enable_azuremonitormetrics=False,
enable_azure_monitor_metrics=False,
azure_monitor_workspace_resource_id=None,
ksm_metric_labels_allow_list=None,
ksm_metric_annotations_allow_list=None,
Expand Down Expand Up @@ -729,12 +730,14 @@ def aks_update(
disable_private_cluster=False,
private_dns_zone=None,
enable_azuremonitormetrics=False,
enable_azure_monitor_metrics=False,
azure_monitor_workspace_resource_id=None,
ksm_metric_labels_allow_list=None,
ksm_metric_annotations_allow_list=None,
grafana_resource_id=None,
enable_windows_recording_rules=False,
disable_azuremonitormetrics=False,
disable_azure_monitor_metrics=False,
enable_vpa=False,
disable_vpa=False,
cluster_snapshot_id=None,
Expand Down
16 changes: 12 additions & 4 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1909,9 +1909,9 @@ def _get_enable_azure_monitor_metrics(self, enable_validation: bool = False) ->
:return: bool
"""
# print("_get_enable_azure_monitor_metrics being called...")
# Read the original value passed by the command.
enable_azure_monitor_metrics = self.raw_param.get("enable_azuremonitormetrics")
# TODO: should remove get value from enable_azuremonitormetrics once the option is removed
enable_azure_monitor_metrics = self.raw_param.get("enable_azure_monitor_metrics") or self.raw_param.get("enable_azuremonitormetrics")
# In create mode, try to read the property value corresponding to the parameter from the `mc` object.
if self.decorator_mode == DecoratorMode.CREATE:
if (
Expand Down Expand Up @@ -1947,7 +1947,8 @@ def _get_disable_azure_monitor_metrics(self, enable_validation: bool = False) ->
:return: bool
"""
# Read the original value passed by the command.
disable_azure_monitor_metrics = self.raw_param.get("disable_azuremonitormetrics")
# TODO: should remove get value from disable_azuremonitormetrics once the option is removed
disable_azure_monitor_metrics = self.raw_param.get("disable_azure_monitor_metrics") or self.raw_param.get("disable_azuremonitormetrics")
if disable_azure_monitor_metrics and self._get_enable_azure_monitor_metrics(False):
raise MutuallyExclusiveArgumentError("Cannot specify --enable-azuremonitormetrics and --disable-azuremonitormetrics at the same time.")
return disable_azure_monitor_metrics
Expand Down Expand Up @@ -3315,7 +3316,14 @@ def update_azure_monitor_profile(self, mc: ManagedCluster) -> ManagedCluster:
mc.azure_monitor_profile = self.models.ManagedClusterAzureMonitorProfile()
mc.azure_monitor_profile.metrics = self.models.ManagedClusterAzureMonitorProfileMetrics(enabled=False)

if (self.context.raw_param.get("enable_azuremonitormetrics") or self.context.raw_param.get("disable_azuremonitormetrics")):
# TODO: should remove get value from enable_azuremonitormetrics once the option is removed
# TODO: should remove get value from disable_azuremonitormetrics once the option is removed
if (
self.context.raw_param.get("enable_azure_monitor_metrics") or
self.context.raw_param.get("enable_azuremonitormetrics") or
self.context.raw_param.get("disable_azure_monitor_metrics") or
self.context.raw_param.get("disable_azuremonitormetrics")
):
ensure_azure_monitor_profile_prerequisites(
self.cmd,
self.context.get_subscription_id(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6431,7 +6431,7 @@ def test_aks_create_with_azuremonitormetrics(self, resource_group, resource_grou
})

create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} --ssh-key-value={ssh_key_value} --node-vm-size={node_vm_size} ' \
'--enable-managed-identity --enable-azuremonitormetrics --enable-windows-recording-rules --output=json'
'--enable-managed-identity --enable-azure-monitor-metrics --enable-windows-recording-rules --output=json'
self.cmd(create_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
])
Expand Down Expand Up @@ -6472,24 +6472,24 @@ def test_aks_update_with_azuremonitormetrics(self, resource_group, resource_grou
'node_vm_size': node_vm_size,
})

# create: without enable-azuremonitormetrics
# create: without enable-azure-monitor-metrics
create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} --ssh-key-value={ssh_key_value} --node-vm-size={node_vm_size} --enable-managed-identity --output=json'
self.cmd(create_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.not_exists('azureMonitorProfile.metrics'),
])

# update: enable-azuremonitormetrics
# update: enable-azure-monitor-metrics
update_cmd = 'aks update --resource-group={resource_group} --name={name} --yes --output=json ' \
'--enable-azuremonitormetrics --enable-managed-identity --enable-windows-recording-rules'
'--enable-azure-monitor-metrics --enable-managed-identity --enable-windows-recording-rules'
self.cmd(update_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('azureMonitorProfile.metrics.enabled', True),
])

# update: disable-azuremonitormetrics
# update: disable-azure-monitor-metrics
update_cmd = 'aks update --resource-group={resource_group} --name={name} --yes --output=json ' \
'--disable-azuremonitormetrics'
'--disable-azure-monitor-metrics'
self.cmd(update_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('azureMonitorProfile.metrics.enabled', False),
Expand Down
9 changes: 9 additions & 0 deletions src/aks-preview/linter_exclusions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ aks create:
nrg_lockdown_restriction_level:
rule_exclusions:
- option_length_too_long
enable_azure_monitor_metrics:
rule_exclusions:
- option_length_too_long
aks update:
parameters:
enable_pod_identity_with_kubenet:
Expand Down Expand Up @@ -113,6 +116,12 @@ aks update:
nrg_lockdown_restriction_level:
rule_exclusions:
- option_length_too_long
enable_azure_monitor_metrics:
rule_exclusions:
- option_length_too_long
disable_azure_monitor_metrics:
rule_exclusions:
- option_length_too_long
aks delete:
parameters:
ignore_pod_disruption_budget:
Expand Down
2 changes: 1 addition & 1 deletion src/aks-preview/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from setuptools import setup, find_packages

VERSION = "0.5.141"
VERSION = "0.5.142"

CLASSIFIERS = [
"Development Status :: 4 - Beta",
Expand Down

0 comments on commit a89ce69

Please sign in to comment.