From 42f4b4fe1d15671ca9faa08bc140285f3a1abd43 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Sun, 1 May 2022 23:08:35 +0000 Subject: [PATCH 01/11] update with no args to reconcile --- .../azext_aks_preview/decorator.py | 112 +++++++++--------- 1 file changed, 57 insertions(+), 55 deletions(-) diff --git a/src/aks-preview/azext_aks_preview/decorator.py b/src/aks-preview/azext_aks_preview/decorator.py index 57b74fb58df..f366f188ca0 100644 --- a/src/aks-preview/azext_aks_preview/decorator.py +++ b/src/aks-preview/azext_aks_preview/decorator.py @@ -2345,61 +2345,63 @@ def check_raw_parameters(self): ) if not is_changed and is_default: - # Note: Uncomment the followings to automatically generate the error message. - # option_names = [ - # '"{}"'.format(format_parameter_name_to_option_name(x)) - # for x in self.context.raw_param.keys() - # if x not in excluded_keys - # ] - # error_msg = "Please specify one or more of {}.".format( - # " or ".join(option_names) - # ) - # raise RequiredArgumentMissingError(error_msg) - raise RequiredArgumentMissingError( - 'Please specify "--enable-cluster-autoscaler" or ' - '"--disable-cluster-autoscaler" or ' - '"--update-cluster-autoscaler" or ' - '"--cluster-autoscaler-profile" or ' - '"--enable-pod-security-policy" or ' - '"--disable-pod-security-policy" or ' - '"--api-server-authorized-ip-ranges" or ' - '"--attach-acr" or ' - '"--detach-acr" or ' - '"--uptime-sla" or ' - '"--no-uptime-sla" or ' - '"--load-balancer-managed-outbound-ip-count" or ' - '"--load-balancer-outbound-ips" or ' - '"--load-balancer-outbound-ip-prefixes" or ' - '"--nat-gateway-managed-outbound-ip-count" or ' - '"--nat-gateway-idle-timeout" or ' - '"--enable-aad" or ' - '"--aad-tenant-id" or ' - '"--aad-admin-group-object-ids" or ' - '"--enable-ahub" or ' - '"--disable-ahub" or ' - '"--enable-managed-identity" or ' - '"--enable-pod-identity" or ' - '"--disable-pod-identity" or ' - '"--auto-upgrade-channel" or ' - '"--enable-secret-rotation" or ' - '"--disable-secret-rotation" or ' - '"--rotation-poll-interval" or ' - '"--tags" or ' - '"--windows-admin-password" or ' - '"--enable-azure-rbac" or ' - '"--disable-azure-rbac" or ' - '"--enable-local-accounts" or ' - '"--disable-local-accounts" or ' - '"--enable-public-fqdn" or ' - '"--disable-public-fqdn"' - '"--enble-windows-gmsa" or ' - '"--nodepool-labels" or ' - '"--enable-oidc-issuer" or ' - '"--http-proxy-config" or ' - '"--enable-azure-keyvault-kms" or ' - '"--enable-workload-identity" or ' - '"--disable-workload-identity".' - ) + reconcilePrompt = "no argument specified to update would you like to reconcile to current settings?" + if not prompt_y_n(reconcilePrompt, default="n"): + # Note: Uncomment the followings to automatically generate the error message. + # option_names = [ + # '"{}"'.format(format_parameter_name_to_option_name(x)) + # for x in self.context.raw_param.keys() + # if x not in excluded_keys + # ] + # error_msg = "Please specify one or more of {}.".format( + # " or ".join(option_names) + # ) + # raise RequiredArgumentMissingError(error_msg) + raise RequiredArgumentMissingError( + 'Please specify "--enable-cluster-autoscaler" or ' + '"--disable-cluster-autoscaler" or ' + '"--update-cluster-autoscaler" or ' + '"--cluster-autoscaler-profile" or ' + '"--enable-pod-security-policy" or ' + '"--disable-pod-security-policy" or ' + '"--api-server-authorized-ip-ranges" or ' + '"--attach-acr" or ' + '"--detach-acr" or ' + '"--uptime-sla" or ' + '"--no-uptime-sla" or ' + '"--load-balancer-managed-outbound-ip-count" or ' + '"--load-balancer-outbound-ips" or ' + '"--load-balancer-outbound-ip-prefixes" or ' + '"--nat-gateway-managed-outbound-ip-count" or ' + '"--nat-gateway-idle-timeout" or ' + '"--enable-aad" or ' + '"--aad-tenant-id" or ' + '"--aad-admin-group-object-ids" or ' + '"--enable-ahub" or ' + '"--disable-ahub" or ' + '"--enable-managed-identity" or ' + '"--enable-pod-identity" or ' + '"--disable-pod-identity" or ' + '"--auto-upgrade-channel" or ' + '"--enable-secret-rotation" or ' + '"--disable-secret-rotation" or ' + '"--rotation-poll-interval" or ' + '"--tags" or ' + '"--windows-admin-password" or ' + '"--enable-azure-rbac" or ' + '"--disable-azure-rbac" or ' + '"--enable-local-accounts" or ' + '"--disable-local-accounts" or ' + '"--enable-public-fqdn" or ' + '"--disable-public-fqdn"' + '"--enble-windows-gmsa" or ' + '"--nodepool-labels" or ' + '"--enable-oidc-issuer" or ' + '"--http-proxy-config" or ' + '"--enable-azure-keyvault-kms" or ' + '"--enable-workload-identity" or ' + '"--disable-workload-identity".' + ) def update_load_balancer_profile(self, mc: ManagedCluster) -> ManagedCluster: """Update load balancer profile for the ManagedCluster object. From 8da34a7ad30c9d6a58dc9f4a492ee88f1ae19125 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Sun, 1 May 2022 23:13:30 +0000 Subject: [PATCH 02/11] allow no argument to agentpool update to reconcile that --- src/aks-preview/azext_aks_preview/custom.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/aks-preview/azext_aks_preview/custom.py b/src/aks-preview/azext_aks_preview/custom.py index 31b8ea892bc..ce4de29532d 100644 --- a/src/aks-preview/azext_aks_preview/custom.py +++ b/src/aks-preview/azext_aks_preview/custom.py @@ -52,7 +52,7 @@ from dateutil.parser import parse # pylint: disable=import-error from dateutil.relativedelta import relativedelta # pylint: disable=import-error from knack.log import get_logger -from knack.prompting import NoTTYException, prompt_pass +from knack.prompting import NoTTYException, prompt_pass, prompt_y_n from knack.util import CLIError from msrestazure.azure_exceptions import CloudError from six.moves.urllib.error import URLError # pylint: disable=import-error @@ -398,7 +398,6 @@ def delete_role_assignments(cli_ctx, ids=None, assignee=None, role=None, resourc assignments_client.delete_by_id(i) return if not any([ids, assignee, role, resource_group_name, scope, assignee, yes]): - from knack.prompting import prompt_y_n msg = 'This will delete all role assignments under the subscription. Are you sure?' if not prompt_y_n(msg, default="n"): return @@ -1058,8 +1057,6 @@ def aks_kollect(cmd, # pylint: disable=too-many-statements,too-many-locals readonly_sas_token = readonly_sas_token.strip('?') - from knack.prompting import prompt_y_n - print() print('This will deploy a daemon set to your cluster to collect logs and diagnostic information and ' f'save them to the storage account ' @@ -1240,7 +1237,6 @@ def aks_upgrade(cmd, # pylint: disable=unused-argument, too-many-return-state node_image_only=False, aks_custom_headers=None, yes=False): - from knack.prompting import prompt_y_n msg = 'Kubernetes may be unavailable during cluster upgrades.\n Are you sure you want to perform this operation?' if not yes and not prompt_y_n(msg, default="n"): return None @@ -1837,10 +1833,12 @@ def aks_agentpool_update(cmd, # pylint: disable=unused-argument disable_cluster_autoscaler + update_cluster_autoscaler if (update_autoscaler != 1 and not tags and not scale_down_mode and not mode and not max_surge and labels is None and node_taints is None): - raise CLIError('Please specify one or more of "--enable-cluster-autoscaler" or ' - '"--disable-cluster-autoscaler" or ' - '"--update-cluster-autoscaler" or ' - '"--tags" or "--mode" or "--max-surge" or "--scale-down-mode" or "--labels" or "--node-taints') + reconcilePrompt = "no argument specified to update would you like to reconcile to current settings?" + if not prompt_y_n(reconcilePrompt, default="n"): + raise CLIError('Please specify one or more of "--enable-cluster-autoscaler" or ' + '"--disable-cluster-autoscaler" or ' + '"--update-cluster-autoscaler" or ' + '"--tags" or "--mode" or "--max-surge" or "--scale-down-mode" or "--labels" or "--node-taints') instance = client.get(resource_group_name, cluster_name, nodepool_name) From cb85d4e478870353926c67c5f5944f5c1d417d33 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Mon, 2 May 2022 18:42:52 +0000 Subject: [PATCH 03/11] keep patch --- .../azext_aks_preview/tests/latest/test_decorator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py b/src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py index dda96e47b99..2890b2edc8d 100644 --- a/src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py +++ b/src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py @@ -3265,7 +3265,10 @@ def test_check_raw_parameters(self): CUSTOM_MGMT_AKS_PREVIEW, ) # fail on no updated parameter provided - with self.assertRaises(RequiredArgumentMissingError): + with patch( + "azext_aks_preview.decorator.prompt_y_n", + return_value=False, + ),self.assertRaises(RequiredArgumentMissingError): dec_1.check_raw_parameters() # custom value From 46a065f4a2794b9c6ea0fc23e8faf76567b370e1 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Mon, 2 May 2022 18:44:08 +0000 Subject: [PATCH 04/11] try and test reconcile case --- .../azext_aks_preview/tests/latest/test_decorator.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py b/src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py index 2890b2edc8d..635bed89a3c 100644 --- a/src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py +++ b/src/aks-preview/azext_aks_preview/tests/latest/test_decorator.py @@ -3271,6 +3271,13 @@ def test_check_raw_parameters(self): ),self.assertRaises(RequiredArgumentMissingError): dec_1.check_raw_parameters() + # unless user says they want to reconcile + with patch( + "azext_aks_preview.decorator.prompt_y_n", + return_value=True, + ): + dec_1.check_raw_parameters() + # custom value dec_2 = AKSPreviewUpdateDecorator( self.cmd, From ef3575837d82d596ab69f717549a3982febe2288 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Mon, 2 May 2022 18:54:06 +0000 Subject: [PATCH 05/11] help for update with out arguments --- src/aks-preview/azext_aks_preview/_help.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index fa00f0c8f81..5024f2e9150 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -517,7 +517,7 @@ helps['aks update'] = """ type: command - short-summary: Update a managed Kubernetes cluster properties, such as enable/disable cluster-autoscaler + short-summary: Update a managed Kubernetes cluster properties, such as enable/disable cluster-autoscaler. No argumentss reconciles the cluster to its current state. parameters: - name: --enable-cluster-autoscaler -e type: bool @@ -707,6 +707,8 @@ type: string short-summary: Identifier of Azure Key Vault key. examples: + - name: Reconcile the cluster back to its current state. + text: az aks update -g MyResourceGroup -n MyManagedCluster - name: Enable cluster-autoscaler within node count range [1,5] text: az aks update --enable-cluster-autoscaler --min-count 1 --max-count 5 -g MyResourceGroup -n MyManagedCluster - name: Disable cluster-autoscaler for an existing cluster @@ -1132,7 +1134,7 @@ helps['aks nodepool update'] = """ type: command - short-summary: Update a node pool to enable/disable cluster-autoscaler or change min-count or max-count + short-summary: Update a node pool to enable/disable cluster-autoscaler or change min-count or max-count. No argumentss reconciles the nodepool to its current state. parameters: - name: --enable-cluster-autoscaler -e type: bool @@ -1165,6 +1167,8 @@ type: string short-summary: The node taints for the node pool. examples: + - name: Reconcile the nodepool back to its current state. + text: az aks nodepool update -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster - name: Enable cluster-autoscaler within node count range [1,5] text: az aks nodepool update --enable-cluster-autoscaler --min-count 1 --max-count 5 -g MyResourceGroup -n nodepool1 --cluster-name MyManagedCluster - name: Disable cluster-autoscaler for an existing cluster From f7114f7ace333b39ca364f7c736c4eb790c514fe Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 4 May 2022 10:16:49 -0700 Subject: [PATCH 06/11] Update _help.py --- src/aks-preview/azext_aks_preview/_help.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index 5024f2e9150..0627b292aaa 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -517,7 +517,8 @@ helps['aks update'] = """ type: command - short-summary: Update a managed Kubernetes cluster properties, such as enable/disable cluster-autoscaler. No argumentss reconciles the cluster to its current state. + short-summary: Update a managed Kubernetes cluster properties, such as enable/disable cluster-autoscaler. + ents attempts to move the cluster to its goal state without changing the current cluster configuration. . This operation can be used to move out of a non succeeded state. parameters: - name: --enable-cluster-autoscaler -e type: bool @@ -1134,7 +1135,7 @@ helps['aks nodepool update'] = """ type: command - short-summary: Update a node pool to enable/disable cluster-autoscaler or change min-count or max-count. No argumentss reconciles the nodepool to its current state. + short-summary: Update a node pool to enable/disable cluster-autoscaler or change min-count or max-count. No arguments attempts to move the cluster to its goal state without changing the current cluster configuration. This operation can be used to move out of a non succeeded state. parameters: - name: --enable-cluster-autoscaler -e type: bool From ea452ce4702ca7c1ca2aaff3b4b0d712101dda0d Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 4 May 2022 17:40:40 +0000 Subject: [PATCH 07/11] short summaries --- src/aks-preview/azext_aks_preview/_help.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index 0627b292aaa..340c82254f3 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -517,8 +517,8 @@ helps['aks update'] = """ type: command - short-summary: Update a managed Kubernetes cluster properties, such as enable/disable cluster-autoscaler. - ents attempts to move the cluster to its goal state without changing the current cluster configuration. . This operation can be used to move out of a non succeeded state. + short-summary: Update a managed Kubernetes cluster properties. + long-summary: Update a managed Kubernetes cluster properties, such as enable/disable cluster-autoscaler. No arguments attempts to move the cluster to its goal state without changing the current cluster configuration. This operation can be used to move out of a non succeeded state. parameters: - name: --enable-cluster-autoscaler -e type: bool @@ -1135,7 +1135,8 @@ helps['aks nodepool update'] = """ type: command - short-summary: Update a node pool to enable/disable cluster-autoscaler or change min-count or max-count. No arguments attempts to move the cluster to its goal state without changing the current cluster configuration. This operation can be used to move out of a non succeeded state. + short-summary: Update a node pool properties. + long-summary: Update a node pool to enable/disable cluster-autoscaler or change min-count or max-count. No arguments attempts to move the cluster to its goal state without changing the current cluster configuration. This operation can be used to move out of a non succeeded state. parameters: - name: --enable-cluster-autoscaler -e type: bool From a8308a9990bfd08a9c26c9cdcfc7c67e28fe317e Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 4 May 2022 14:49:37 -0700 Subject: [PATCH 08/11] Update src/aks-preview/azext_aks_preview/_help.py Co-authored-by: Matthew Christopher --- src/aks-preview/azext_aks_preview/_help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index 340c82254f3..790f1adb972 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -1136,7 +1136,7 @@ helps['aks nodepool update'] = """ type: command short-summary: Update a node pool properties. - long-summary: Update a node pool to enable/disable cluster-autoscaler or change min-count or max-count. No arguments attempts to move the cluster to its goal state without changing the current cluster configuration. This operation can be used to move out of a non succeeded state. + long-summary: Update a node pool to enable/disable cluster-autoscaler or change min-count or max-count. When called with no optional arguments this attempts to move the cluster to its goal state without changing the current cluster configuration. This can be used to move out of a non succeeded state. parameters: - name: --enable-cluster-autoscaler -e type: bool From beabdb5221e34624a89a4aba46903a017447b6ba Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 4 May 2022 14:52:31 -0700 Subject: [PATCH 09/11] Update src/aks-preview/azext_aks_preview/_help.py Co-authored-by: Matthew Christopher --- src/aks-preview/azext_aks_preview/_help.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index 790f1adb972..9d68d375824 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -518,7 +518,7 @@ helps['aks update'] = """ type: command short-summary: Update a managed Kubernetes cluster properties. - long-summary: Update a managed Kubernetes cluster properties, such as enable/disable cluster-autoscaler. No arguments attempts to move the cluster to its goal state without changing the current cluster configuration. This operation can be used to move out of a non succeeded state. + long-summary: Update the properties of a managed Kubernetes cluster. Can be used for example to enable/disable cluster-autoscaler. When called with no optional arguments this attempts to move the cluster to its goal state without changing the current cluster configuration. This can be used to move out of a non succeeded state. parameters: - name: --enable-cluster-autoscaler -e type: bool From fb94ed79d9658695b408bc8a82ea098c24f360cd Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 4 May 2022 21:55:41 +0000 Subject: [PATCH 10/11] matchris comments --- src/aks-preview/azext_aks_preview/_help.py | 2 +- src/aks-preview/azext_aks_preview/custom.py | 2 +- src/aks-preview/azext_aks_preview/decorator.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/aks-preview/azext_aks_preview/_help.py b/src/aks-preview/azext_aks_preview/_help.py index 9d68d375824..0ded5391934 100644 --- a/src/aks-preview/azext_aks_preview/_help.py +++ b/src/aks-preview/azext_aks_preview/_help.py @@ -517,7 +517,7 @@ helps['aks update'] = """ type: command - short-summary: Update a managed Kubernetes cluster properties. + short-summary: Update the properties of a managed Kubernetes cluster. long-summary: Update the properties of a managed Kubernetes cluster. Can be used for example to enable/disable cluster-autoscaler. When called with no optional arguments this attempts to move the cluster to its goal state without changing the current cluster configuration. This can be used to move out of a non succeeded state. parameters: - name: --enable-cluster-autoscaler -e diff --git a/src/aks-preview/azext_aks_preview/custom.py b/src/aks-preview/azext_aks_preview/custom.py index ce4de29532d..93032f84b92 100644 --- a/src/aks-preview/azext_aks_preview/custom.py +++ b/src/aks-preview/azext_aks_preview/custom.py @@ -1833,7 +1833,7 @@ def aks_agentpool_update(cmd, # pylint: disable=unused-argument disable_cluster_autoscaler + update_cluster_autoscaler if (update_autoscaler != 1 and not tags and not scale_down_mode and not mode and not max_surge and labels is None and node_taints is None): - reconcilePrompt = "no argument specified to update would you like to reconcile to current settings?" + reconcilePrompt = 'no argument specified to update would you like to reconcile to current settings?' if not prompt_y_n(reconcilePrompt, default="n"): raise CLIError('Please specify one or more of "--enable-cluster-autoscaler" or ' '"--disable-cluster-autoscaler" or ' diff --git a/src/aks-preview/azext_aks_preview/decorator.py b/src/aks-preview/azext_aks_preview/decorator.py index f366f188ca0..87e65e4a633 100644 --- a/src/aks-preview/azext_aks_preview/decorator.py +++ b/src/aks-preview/azext_aks_preview/decorator.py @@ -2345,7 +2345,7 @@ def check_raw_parameters(self): ) if not is_changed and is_default: - reconcilePrompt = "no argument specified to update would you like to reconcile to current settings?" + reconcilePrompt = 'no argument specified to update would you like to reconcile to current settings?' if not prompt_y_n(reconcilePrompt, default="n"): # Note: Uncomment the followings to automatically generate the error message. # option_names = [ From a991245a2e980e99a3bee5453a2a8289d4cbdc63 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Thu, 5 May 2022 05:42:18 +0000 Subject: [PATCH 11/11] bump vesion --- src/aks-preview/HISTORY.md | 4 ++++ src/aks-preview/setup.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/aks-preview/HISTORY.md b/src/aks-preview/HISTORY.md index 5ac5d775625..ff67370d709 100644 --- a/src/aks-preview/HISTORY.md +++ b/src/aks-preview/HISTORY.md @@ -3,6 +3,10 @@ Release History =============== +0.5.66 +++++++ +* Prompt when no arguments are given to update and nodepool update to see if the customer wants to try goal seek to current settings. + 0.5.65 ++++++ * Add `--ignore-pod-disruption-budget` flag for `az aks nodepool delete` for ignoring PodDisruptionBudget. diff --git a/src/aks-preview/setup.py b/src/aks-preview/setup.py index 315922dcec5..4292b77c0b4 100644 --- a/src/aks-preview/setup.py +++ b/src/aks-preview/setup.py @@ -9,7 +9,7 @@ from setuptools import setup, find_packages -VERSION = "0.5.65" +VERSION = "0.5.66" CLASSIFIERS = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers",