diff --git a/src/fleet/HISTORY.rst b/src/fleet/HISTORY.rst index edd685d497a..becbf2337fd 100644 --- a/src/fleet/HISTORY.rst +++ b/src/fleet/HISTORY.rst @@ -72,4 +72,8 @@ Release History 1.0.3 ++++++ -* Added `az fleet reconcile` & `az fleet member reconcile` commands. \ No newline at end of file +* Added `az fleet reconcile` & `az fleet member reconcile` commands. + +1.0.4 +++++++ +* Added new --upgrade-type parameter "ControlPlaneOnly" for command `az fleet updaterun create --upgrade-type`. \ No newline at end of file diff --git a/src/fleet/azext_fleet/_help.py b/src/fleet/azext_fleet/_help.py index 87bf734ea59..8b7d00a00e1 100644 --- a/src/fleet/azext_fleet/_help.py +++ b/src/fleet/azext_fleet/_help.py @@ -181,10 +181,10 @@ parameters: - name: --upgrade-type type: string - short-summary: Specify the upgrade type of members. Acceptable values are 'Full' and 'NodeImageOnly'. + short-summary: Specify the upgrade type of members. Acceptable values are 'Full', 'ControlPlaneOnly', and 'NodeImageOnly'. - name: --kubernetes-version type: string - short-summary: Specify the kubernetes version to upgrade member(s) to, when --upgrade-type is set to 'Full'. Acceptable format is x.x.x (eg. 1.2.3). + short-summary: Specify the kubernetes version to upgrade member(s) to, when --upgrade-type is set to 'Full' or 'ControlPlaneOnly'. Acceptable format is x.x.x (eg. 1.2.3). - name: --stages type: string short-summary: Path to a JSON file that defines stages to upgrade a fleet. See examples for reference. diff --git a/src/fleet/azext_fleet/_params.py b/src/fleet/azext_fleet/_params.py index 23c47ddef16..af8f820b43d 100644 --- a/src/fleet/azext_fleet/_params.py +++ b/src/fleet/azext_fleet/_params.py @@ -59,7 +59,7 @@ def load_arguments(self, _): c.argument('fleet_name', options_list=['--fleet-name', '-f'], help='Specify the fleet name.') with self.argument_context('fleet updaterun create') as c: - c.argument('upgrade_type', arg_type=get_enum_type(['Full', 'NodeImageOnly'])) + c.argument('upgrade_type', arg_type=get_enum_type(['Full', 'NodeImageOnly', 'ControlPlaneOnly'])) c.argument('kubernetes_version', validator=validate_kubernetes_version) c.argument('node_image_selection', arg_type=get_enum_type(['Latest', 'Consistent']), help='Node Image Selection is an option that lets you choose how your clusters\' nodes are upgraded') c.argument('stages', type=file_type, completer=FilesCompleter(), help='Path to a json file that defines stages to upgrade a fleet. See examples for further reference.') diff --git a/src/fleet/azext_fleet/constants.py b/src/fleet/azext_fleet/constants.py new file mode 100644 index 00000000000..0c0d3877ea8 --- /dev/null +++ b/src/fleet/azext_fleet/constants.py @@ -0,0 +1,14 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +UPGRADE_TYPE_CONTROLPLANEONLY = "ControlPlaneOnly" +UPGRADE_TYPE_FULL = "Full" +UPGRADE_TYPE_NODEIMAGEONLY = "NodeImageOnly" + +UPGRADE_TYPE_ERROR_MESSAGES = { + UPGRADE_TYPE_CONTROLPLANEONLY: f"Please set kubernetes version when upgrade type is '{UPGRADE_TYPE_CONTROLPLANEONLY}'.", # pylint: disable=line-too-long + UPGRADE_TYPE_FULL: f"Please set kubernetes version when upgrade type is '{UPGRADE_TYPE_FULL}'.", + UPGRADE_TYPE_NODEIMAGEONLY: f"Cannot set kubernetes version when upgrade type is '{UPGRADE_TYPE_NODEIMAGEONLY}'." +} diff --git a/src/fleet/azext_fleet/custom.py b/src/fleet/azext_fleet/custom.py index 166e71b40fc..e3e8e0a5cd8 100644 --- a/src/fleet/azext_fleet/custom.py +++ b/src/fleet/azext_fleet/custom.py @@ -14,6 +14,10 @@ from azext_fleet._client_factory import CUSTOM_MGMT_FLEET from azext_fleet._helpers import print_or_merge_credentials +from azext_fleet.constants import UPGRADE_TYPE_CONTROLPLANEONLY +from azext_fleet.constants import UPGRADE_TYPE_FULL +from azext_fleet.constants import UPGRADE_TYPE_NODEIMAGEONLY +from azext_fleet.constants import UPGRADE_TYPE_ERROR_MESSAGES # pylint: disable=too-many-locals @@ -316,10 +320,17 @@ def create_update_run(cmd, stages=None, update_strategy_name=None, no_wait=False): - if upgrade_type == "Full" and kubernetes_version is None: - raise CLIError("Please set kubernetes version when upgrade type is 'Full'.") - if upgrade_type == "NodeImageOnly" and kubernetes_version is not None: - raise CLIError("Cannot set kubernetes version when upgrade type is 'NodeImageOnly'.") + + if upgrade_type in UPGRADE_TYPE_ERROR_MESSAGES: + if ( + ((upgrade_type in (UPGRADE_TYPE_FULL, UPGRADE_TYPE_CONTROLPLANEONLY)) and kubernetes_version is None) or # pylint: disable=line-too-long + (upgrade_type == UPGRADE_TYPE_NODEIMAGEONLY and kubernetes_version is not None) + ): + raise CLIError(UPGRADE_TYPE_ERROR_MESSAGES[upgrade_type]) + else: + raise CLIError((f"The upgrade type parameter '{upgrade_type}' is not valid." + f"Valid options are: '{UPGRADE_TYPE_FULL}', '{UPGRADE_TYPE_CONTROLPLANEONLY}', or '{UPGRADE_TYPE_NODEIMAGEONLY}'")) # pylint: disable=line-too-long + if stages is not None and update_strategy_name is not None: raise CLIError("Cannot set stages when update strategy name is set.") diff --git a/src/fleet/setup.py b/src/fleet/setup.py index 98899dca7a7..7c19c452842 100644 --- a/src/fleet/setup.py +++ b/src/fleet/setup.py @@ -16,7 +16,7 @@ # TODO: Confirm this is the right version number you want and it matches your # HISTORY.rst entry. -VERSION = '1.0.3' +VERSION = '1.0.4' # The full list of classifiers is available at # https://pypi.python.org/pypi?%3Aaction=list_classifiers