From 21e2b5fd9ba4de25427fe21351cba1a49a5d3dd6 Mon Sep 17 00:00:00 2001 From: Henry Chen Date: Tue, 29 Oct 2024 15:26:30 -0400 Subject: [PATCH 1/2] remove uptime-sla --- .../azure/cli/command_modules/acs/_help.py | 9 - .../azure/cli/command_modules/acs/_params.py | 3 - .../azure/cli/command_modules/acs/custom.py | 3 - .../acs/managed_cluster_decorator.py | 102 +----------- .../acs/tests/latest/test_aks_commands.py | 14 +- .../latest/test_managed_cluster_decorator.py | 156 +----------------- 6 files changed, 16 insertions(+), 271 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/acs/_help.py b/src/azure-cli/azure/cli/command_modules/acs/_help.py index 39e4a902e6d..fad264e3032 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_help.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_help.py @@ -327,9 +327,6 @@ - name: --enable-high-log-scale-mode type: bool short-summary: Enable High Log Scale Mode for Container Logs. - - name: --uptime-sla - type: bool - short-summary: --uptime-sla is deprecated. Please use '--tier standard' instead. - name: --tier type: string short-summary: Specify SKU tier for managed clusters. '--tier standard' enables a standard managed cluster service with a financially backed SLA. '--tier free' does not have a financially backed SLA. @@ -654,12 +651,6 @@ - name: --max-count type: int short-summary: Maximum nodes count used for autoscaler, when "--enable-cluster-autoscaler" specified. Please specify the value in the range of [1, 1000] - - name: --uptime-sla - type: bool - short-summary: Enable a standard managed cluster service with a financially backed SLA. --uptime-sla is deprecated. Please use '--tier standard' instead. - - name: --no-uptime-sla - type: bool - short-summary: Change a standard managed cluster to a free one. --no-uptime-sla is deprecated. Please use '--tier free' instead. - name: --tier type: string short-summary: Specify SKU tier for managed clusters. '--tier standard' enables a standard managed cluster service with a financially backed SLA. '--tier free' changes a standard managed cluster to a free one. diff --git a/src/azure-cli/azure/cli/command_modules/acs/_params.py b/src/azure-cli/azure/cli/command_modules/acs/_params.py index 1eca29b7d25..18fdc61fbed 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/_params.py +++ b/src/azure-cli/azure/cli/command_modules/acs/_params.py @@ -317,7 +317,6 @@ def load_arguments(self, _): c.argument('node_os_upgrade_channel', arg_type=get_enum_type(node_os_upgrade_channels)) c.argument('cluster_autoscaler_profile', nargs='+', options_list=["--cluster-autoscaler-profile", "--ca-profile"], help="Comma-separated list of key=value pairs for configuring cluster autoscaler. Pass an empty string to clear the profile.") - c.argument('uptime_sla', action='store_true', deprecate_info=c.deprecate(target='--uptime-sla', hide=True)) c.argument('tier', arg_type=get_enum_type(sku_tiers), validator=validate_sku_tier) c.argument('fqdn_subdomain') c.argument('api_server_authorized_ip_ranges', validator=validate_ip_ranges) @@ -489,8 +488,6 @@ def load_arguments(self, _): c.argument('auto_upgrade_channel', arg_type=get_enum_type(auto_upgrade_channels)) c.argument('cluster_autoscaler_profile', nargs='+', options_list=["--cluster-autoscaler-profile", "--ca-profile"], help="Comma-separated list of key=value pairs for configuring cluster autoscaler. Pass an empty string to clear the profile.") - c.argument('uptime_sla', action='store_true', deprecate_info=c.deprecate(target='--uptime-sla', hide=True)) - c.argument('no_uptime_sla', action='store_true', deprecate_info=c.deprecate(target='--no-uptime-sla', hide=True)) c.argument('tier', arg_type=get_enum_type(sku_tiers), validator=validate_sku_tier) c.argument('api_server_authorized_ip_ranges', validator=validate_ip_ranges) # private cluster parameters diff --git a/src/azure-cli/azure/cli/command_modules/acs/custom.py b/src/azure-cli/azure/cli/command_modules/acs/custom.py index f55a34528e4..cf96e438b9a 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/custom.py +++ b/src/azure-cli/azure/cli/command_modules/acs/custom.py @@ -519,7 +519,6 @@ def aks_create( auto_upgrade_channel=None, node_os_upgrade_channel=None, cluster_autoscaler_profile=None, - uptime_sla=False, tier=None, fqdn_subdomain=None, api_server_authorized_ip_ranges=None, @@ -705,8 +704,6 @@ def aks_update( auto_upgrade_channel=None, node_os_upgrade_channel=None, cluster_autoscaler_profile=None, - uptime_sla=False, - no_uptime_sla=False, tier=None, api_server_authorized_ip_ranges=None, enable_public_fqdn=False, diff --git a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py index e93f122536a..d4a50288039 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/managed_cluster_decorator.py @@ -4498,41 +4498,6 @@ def update_azure_service_mesh_profile(self) -> ServiceMeshProfile: return new_profile return self.mc.service_mesh_profile - def _get_uptime_sla(self, enable_validation: bool = False) -> bool: - """Internal function to obtain the value of uptime_sla. - - This function supports the option of enable_validation. When enabled, if both uptime_sla and no_uptime_sla are - specified, raise a MutuallyExclusiveArgumentError. - - :return: bool - """ - # read the original value passed by the command - uptime_sla = self.raw_param.get("uptime_sla") - - # In create mode, try to read the property value corresponding to the parameter from the `mc` object. - if self.decorator_mode == DecoratorMode.CREATE: - if ( - self.mc and - self.mc.sku and - self.mc.sku.tier is not None - ): - uptime_sla = self.mc.sku.tier == "Standard" - - # this parameter does not need dynamic completion - # validation - if enable_validation: - if uptime_sla and self._get_no_uptime_sla(enable_validation=False): - raise MutuallyExclusiveArgumentError( - 'Cannot specify "--uptime-sla" and "--no-uptime-sla" at the same time.' - ) - - if uptime_sla and self.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_FREE: - raise MutuallyExclusiveArgumentError( - 'Cannot specify "--uptime-sla" and "--tier free" at the same time.' - ) - - return uptime_sla - def get_tier(self) -> str: """Obtain the value of tier. @@ -4542,66 +4507,7 @@ def get_tier(self) -> str: if not tier: return "" - tierStr = tier.lower() - if tierStr == CONST_MANAGED_CLUSTER_SKU_TIER_FREE and self._get_uptime_sla(enable_validation=False): - raise MutuallyExclusiveArgumentError( - 'Cannot specify "--uptime-sla" and "--tier free" at the same time.' - ) - - if tierStr == CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD and self._get_no_uptime_sla(enable_validation=False): - raise MutuallyExclusiveArgumentError( - 'Cannot specify "--no-uptime-sla" and "--tier standard" at the same time.' - ) - - return tierStr - - def get_uptime_sla(self) -> bool: - """Obtain the value of uptime_sla. - - This function will verify the parameter by default. If both uptime_sla and no_uptime_sla are specified, raise - a MutuallyExclusiveArgumentError. - - :return: bool - """ - return self._get_uptime_sla(enable_validation=True) - - def _get_no_uptime_sla(self, enable_validation: bool = False) -> bool: - """Internal function to obtain the value of no_uptime_sla. - - This function supports the option of enable_validation. When enabled, if both uptime_sla and no_uptime_sla are - specified, raise a MutuallyExclusiveArgumentError. - - :return: bool - """ - # read the original value passed by the command - no_uptime_sla = self.raw_param.get("no_uptime_sla") - # We do not support this option in create mode, therefore we do not read the value from `mc`. - - # this parameter does not need dynamic completion - # validation - if enable_validation: - if no_uptime_sla and self._get_uptime_sla(enable_validation=False): - raise MutuallyExclusiveArgumentError( - 'Cannot specify "--uptime-sla" and "--no-uptime-sla" at the same time.' - ) - - if no_uptime_sla and self.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD: - raise MutuallyExclusiveArgumentError( - 'Cannot specify "--no-uptime-sla" and "--tier standard" at the same time.' - ) - - return no_uptime_sla - - def get_no_uptime_sla(self) -> bool: - """Obtain the value of no_uptime_sla. - - This function will verify the parameter by default. If both uptime_sla and no_uptime_sla are specified, raise - a MutuallyExclusiveArgumentError. - - :return: bool - """ - - return self._get_no_uptime_sla(enable_validation=True) + return tier.lower() def get_defender_config(self) -> Union[ManagedClusterSecurityProfileDefender, None]: """Obtain the value of defender. @@ -6516,7 +6422,7 @@ def set_up_sku(self, mc: ManagedCluster) -> ManagedCluster: """ self._ensure_mc(mc) - if self.context.get_uptime_sla() or self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD: + if self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD: mc.sku = self.models.ManagedClusterSKU( name="Base", tier="Standard" @@ -7255,13 +7161,13 @@ def update_sku(self, mc: ManagedCluster) -> ManagedCluster: tier="Premium" ) - if self.context.get_uptime_sla() or self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD: + if self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_STANDARD: mc.sku = self.models.ManagedClusterSKU( name="Base", tier="Standard" ) - if self.context.get_no_uptime_sla() or self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_FREE: + if self.context.get_tier() == CONST_MANAGED_CLUSTER_SKU_TIER_FREE: mc.sku = self.models.ManagedClusterSKU( name="Base", tier="Free" diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py index a7d1822ca4a..b3086267b58 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py @@ -2102,7 +2102,7 @@ def test_aks_create_with_paid_sku(self, resource_group, resource_group_location, # create create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} ' \ '--dns-name-prefix={dns_name_prefix} --node-count=1 --ssh-key-value={ssh_key_value} ' \ - '--service-principal={service_principal} --client-secret={client_secret} --uptime-sla ' + '--service-principal={service_principal} --client-secret={client_secret} --tier standard ' self.cmd(create_cmd, checks=[ self.exists('fqdn'), self.exists('nodeResourceGroup'), @@ -5262,21 +5262,21 @@ def test_aks_create_with_paid_sku_msi(self, resource_group, resource_group_locat # create create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} ' \ '--dns-name-prefix={dns_name_prefix} --node-count=1 --ssh-key-value={ssh_key_value} ' \ - '--uptime-sla' + '--tier standard' self.cmd(create_cmd, checks=[ self.exists('fqdn'), self.exists('nodeResourceGroup'), self.check('provisioningState', 'Succeeded'), self.check('sku.tier', 'Standard') ]) - # update to no uptime sla - no_uptime_sla_cmd = 'aks update --resource-group={resource_group} --name={name} --no-uptime-sla' - self.cmd(no_uptime_sla_cmd, checks=[ + # update to free tier + free_tier_cmd = 'aks update --resource-group={resource_group} --name={name} --tier free' + self.cmd(free_tier_cmd, checks=[ self.check('sku.tier', 'Free') ]) # update to uptime sla again - uptime_sla_cmd = 'aks update --resource-group={resource_group} --name={name} --uptime-sla' - self.cmd(uptime_sla_cmd, checks=[ + standard_tier_cmd = 'aks update --resource-group={resource_group} --name={name} --tier standard' + self.cmd(standard_tier_cmd, checks=[ self.check('sku.tier', 'Standard') ]) # delete diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py index d2d58b6dea8..e313f515cee 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_managed_cluster_decorator.py @@ -4160,127 +4160,6 @@ def test_get_cluster_autoscaler_profile(self): }, ) - def test_get_uptime_sla(self): - # default - ctx_1 = AKSManagedClusterContext( - self.cmd, - AKSManagedClusterParamDict( - { - "uptime_sla": False, - } - ), - self.models, - DecoratorMode.CREATE, - ) - self.assertEqual(ctx_1.get_uptime_sla(), False) - sku = self.models.ManagedClusterSKU( - name="Base", - tier="Standard", - ) - mc = self.models.ManagedCluster( - location="test_location", - sku=sku, - ) - ctx_1.attach_mc(mc) - self.assertEqual(ctx_1.get_uptime_sla(), True) - - # custom value - ctx_2 = AKSManagedClusterContext( - self.cmd, - AKSManagedClusterParamDict( - { - "uptime_sla": False, - } - ), - self.models, - DecoratorMode.UPDATE, - ) - sku_2 = self.models.ManagedClusterSKU( - name="Base", - tier="Standard", - ) - mc_2 = self.models.ManagedCluster( - location="test_location", - sku=sku_2, - ) - ctx_2.attach_mc(mc_2) - self.assertEqual(ctx_2.get_uptime_sla(), False) - - # custom value - ctx_3 = AKSManagedClusterContext( - self.cmd, - AKSManagedClusterParamDict( - { - "uptime_sla": True, - "no_uptime_sla": True, - } - ), - self.models, - DecoratorMode.CREATE, - ) - sku_3 = self.models.ManagedClusterSKU( - name="Base", - tier="Free", - ) - mc_3 = self.models.ManagedCluster( - location="test_location", - sku=sku_3, - ) - ctx_3.attach_mc(mc_3) - self.assertEqual(ctx_3.get_uptime_sla(), False) - - def test_get_no_uptime_sla(self): - # default - ctx_1 = AKSManagedClusterContext( - self.cmd, - AKSManagedClusterParamDict( - { - "no_uptime_sla": False, - } - ), - self.models, - DecoratorMode.UPDATE, - ) - self.assertEqual(ctx_1.get_no_uptime_sla(), False) - sku = self.models.ManagedClusterSKU( - name="Base", - tier="Standard", - ) - mc = self.models.ManagedCluster( - location="test_location", - sku=sku, - ) - ctx_1.attach_mc(mc) - self.assertEqual(ctx_1.get_no_uptime_sla(), False) - - # custom value - ctx_2 = AKSManagedClusterContext( - self.cmd, - AKSManagedClusterParamDict( - { - "uptime_sla": True, - "no_uptime_sla": True, - } - ), - self.models, - DecoratorMode.UPDATE, - ) - sku_2 = self.models.ManagedClusterSKU( - name="Base", - tier="Free", - ) - mc_2 = self.models.ManagedCluster( - location="test_location", - sku=sku_2, - ) - ctx_2.attach_mc(mc_2) - # fail on mutually exclusive uptime_sla and no_uptime_sla - with self.assertRaises(MutuallyExclusiveArgumentError): - ctx_2.get_uptime_sla() - # fail on mutually exclusive uptime_sla and no_uptime_sla - with self.assertRaises(MutuallyExclusiveArgumentError): - ctx_2.get_no_uptime_sla() - def test_get_disable_local_accounts(self): # default ctx_1 = AKSManagedClusterContext( @@ -7364,7 +7243,7 @@ def test_set_up_sku(self): self.cmd, self.client, { - "uptime_sla": False, + "tier": "free", }, ResourceType.MGMT_CONTAINERSERVICE, ) @@ -7385,7 +7264,7 @@ def test_set_up_sku(self): self.cmd, self.client, { - "uptime_sla": True, + "tier": "standard", }, ResourceType.MGMT_CONTAINERSERVICE, ) @@ -8596,8 +8475,7 @@ def test_update_sku(self): self.cmd, self.client, { - "uptime_sla": False, - "no_uptime_sla": False, + "tier": "free", }, ResourceType.MGMT_CONTAINERSERVICE, ) @@ -8622,35 +8500,12 @@ def test_update_sku(self): ) self.assertEqual(dec_mc_1, ground_truth_mc_1) - # custom value - dec_2 = AKSManagedClusterUpdateDecorator( - self.cmd, - self.client, - { - "uptime_sla": True, - "no_uptime_sla": True, - }, - ResourceType.MGMT_CONTAINERSERVICE, - ) - mc_2 = self.models.ManagedCluster( - location="test_location", - sku=self.models.ManagedClusterSKU( - name="Base", - tier="Free", - ), - ) - dec_2.context.attach_mc(mc_2) - # fail on mutually exclusive uptime_sla and no_uptime_sla - with self.assertRaises(MutuallyExclusiveArgumentError): - dec_2.update_sku(mc_2) - # custom value dec_3 = AKSManagedClusterUpdateDecorator( self.cmd, self.client, { - "uptime_sla": False, - "no_uptime_sla": True, + "tier": "free", }, ResourceType.MGMT_CONTAINERSERVICE, ) @@ -8677,8 +8532,7 @@ def test_update_sku(self): self.cmd, self.client, { - "uptime_sla": True, - "no_uptime_sla": False, + "tier": "standard", }, ResourceType.MGMT_CONTAINERSERVICE, ) From ec6264b3ea707ec6abfde8c2f0fbbe840fbb96ae Mon Sep 17 00:00:00 2001 From: Henry Chen Date: Thu, 31 Oct 2024 11:32:07 -0400 Subject: [PATCH 2/2] empty --- .../cli/command_modules/acs/tests/latest/test_aks_commands.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py index b3086267b58..07a121258c1 100644 --- a/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py +++ b/src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py @@ -2099,6 +2099,7 @@ def test_aks_create_with_paid_sku(self, resource_group, resource_group_location, 'client_secret': sp_password, 'resource_type': 'Microsoft.ContainerService/ManagedClusters' }) + # create create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} ' \ '--dns-name-prefix={dns_name_prefix} --node-count=1 --ssh-key-value={ssh_key_value} ' \