Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

{ACS} az aks create/update: Add parameter --auto-upgrade-channel to support auto upgrade #18825

Merged
merged 28 commits into from
Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c662843
implementedCodeFromPreviousPRs
Jul 13, 2021
b30dd37
adding ManagedClusterAutoUpgradeProfile code
Jul 14, 2021
c8ed48e
adding test record
Jul 15, 2021
c00c905
Fix linter failures (#19116) (#19147)
zhoxing-ms Aug 6, 2021
71456b1
Handle unsupported and no_effect change types (#19144)
shenglol Aug 6, 2021
ed4e903
[Batch] Upgrade api-version to v2021-06-01 (#19100)
cRui861 Aug 7, 2021
da3ff65
{Release} Hotfix: Release 2.27.1 (#19187)
zhoxing-ms Aug 11, 2021
1b21016
change to direct enums
charliedmcb Aug 12, 2021
0a925aa
fixing PR comments
Aug 12, 2021
c7f92e3
change to auto_upgrade_channels
Aug 12, 2021
4121a33
Merge branch 'master' into charliedmcb/addingAutoupgraderToCLI
Aug 12, 2021
c1affbf
test_aks_create_with_auto_upgrade_channel
Aug 12, 2021
f6a3be7
Revert "test_aks_create_with_auto_upgrade_channel"
Aug 15, 2021
ec9cd69
Revert "Merge branch 'master' into charliedmcb/addingAutoupgraderToCLI"
Aug 15, 2021
e5985c3
Revert "Revert "Merge branch 'master' into charliedmcb/addingAutoupgr…
Aug 15, 2021
0ef331c
Revert "Merge branch 'master' into charliedmcb/addingAutoupgraderToCLI"
Aug 15, 2021
cd47cb0
Revert "Revert "Merge branch 'master' into charliedmcb/addingAutoupgr…
Aug 15, 2021
8d8f80f
Revert "Revert "Revert "Merge branch 'master' into charliedmcb/adding…
Aug 15, 2021
fb05ee7
Revert "Revert "Revert "Revert "Merge branch 'master' into charliedmc…
Aug 15, 2021
effe159
Revert "Handle unsupported and no_effect change types (#19144)"
Aug 15, 2021
33c2f04
Revert "Revert "Handle unsupported and no_effect change types (#19144)""
Aug 15, 2021
0df7c06
Revert "{Release} Hotfix: Release 2.27.1 (#19187)"
Aug 15, 2021
8aa3f09
Revert "[Batch] Upgrade api-version to v2021-06-01 (#19100)"
Aug 15, 2021
dbca938
Revert "Handle unsupported and no_effect change types (#19144)"
Aug 15, 2021
432f0ee
Merge remote-tracking branch 'origin' into charliedmcb/addingAutoupgr…
Aug 15, 2021
49ef3ad
running new test
Aug 15, 2021
eb0e57f
remove yaml
Aug 15, 2021
90c3952
ran test
Aug 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
CONST_SPOT_EVICTION_POLICY_DELETE = "Delete"
CONST_SPOT_EVICTION_POLICY_DEALLOCATE = "Deallocate"

# consts for upgrade channel
zhoxing-ms marked this conversation as resolved.
Show resolved Hide resolved
CONST_RAPID_UPGRADE_CHANNEL = "rapid"
CONST_STABLE_UPGRADE_CHANNEL = "stable"
CONST_PATCH_UPGRADE_CHANNEL = "patch"
CONST_NODE_IMAGE_UPGRADE_CHANNEL = "node-image"
CONST_NONE_UPGRADE_CHANNEL = "none"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these enumerations are only used in arg_type=get_enum_type() and are not used elsewhere, I suggest that they do not need to be defined separately. You can just define it this way https://github.com/Azure/azure-cli/pull/18825/files#r687325877

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Followed the style of defining the array at the top of the _params file, and using that in the get_enum_type() calls. Curious what you think.

Copy link
Contributor

@zhoxing-ms zhoxing-ms Aug 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, instead of defining these enumerations, we can write valid values directly to arg_type=get_enum_type(). Therefore, these enumerations can be deleted, such as #18825 (comment)


CONST_OS_DISK_TYPE_MANAGED = "Managed"
CONST_OS_DISK_TYPE_EPHEMERAL = "Ephemeral"

Expand Down
6 changes: 6 additions & 0 deletions src/azure-cli/azure/cli/command_modules/acs/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@
type: string
short-summary: How outbound traffic will be configured for a cluster.
long-summary: Select between loadBalancer and userDefinedRouting. If not set, defaults to type loadBalancer. Requires --vnet-subnet-id to be provided with a preconfigured route table and --load-balancer-sku to be Standard.
- name: --auto-upgrade-channel
type: string
short-summary: Specify the upgrade channel for autoupgrade. It could be rapid, stable, patch, node-image or none, none means disable autoupgrade.
charliedmcb marked this conversation as resolved.
Show resolved Hide resolved
- name: --enable-cluster-autoscaler
type: bool
short-summary: Enable cluster autoscaler, default value is false.
Expand Down Expand Up @@ -541,6 +544,9 @@
type: int
short-summary: Load balancer idle timeout in minutes.
long-summary: Desired idle timeout for load balancer outbound flows, default is 30 minutes. Please specify a value in the range of [4, 100].
- name: --auto-upgrade-channel
type: string
short-summary: Specify the upgrade channel for autoupgrade. It could be rapid, stable, patch, node-image or none, none means disable autoupgrade.
charliedmcb marked this conversation as resolved.
Show resolved Hide resolved
- name: --attach-acr
type: string
short-summary: Grant the 'acrpull' role assignment to the ACR specified by name or resource ID.
Expand Down
5 changes: 4 additions & 1 deletion src/azure-cli/azure/cli/command_modules/acs/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
from ._consts import CONST_OUTBOUND_TYPE_LOAD_BALANCER, CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING, \
CONST_SCALE_SET_PRIORITY_REGULAR, CONST_SCALE_SET_PRIORITY_SPOT, \
CONST_SPOT_EVICTION_POLICY_DELETE, CONST_SPOT_EVICTION_POLICY_DEALLOCATE, \
CONST_OS_DISK_TYPE_MANAGED, CONST_OS_DISK_TYPE_EPHEMERAL
CONST_OS_DISK_TYPE_MANAGED, CONST_OS_DISK_TYPE_EPHEMERAL, \
CONST_RAPID_UPGRADE_CHANNEL, CONST_STABLE_UPGRADE_CHANNEL, CONST_PATCH_UPGRADE_CHANNEL, CONST_NODE_IMAGE_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL

orchestrator_types = ["Custom", "DCOS", "Kubernetes", "Swarm", "DockerCE"]

Expand Down Expand Up @@ -202,6 +203,7 @@ def load_arguments(self, _):
validator=validate_load_balancer_idle_timeout)
c.argument('outbound_type', arg_type=get_enum_type([CONST_OUTBOUND_TYPE_LOAD_BALANCER,
CONST_OUTBOUND_TYPE_USER_DEFINED_ROUTING]))
c.argument('auto_upgrade_channel', arg_type=get_enum_type([CONST_RAPID_UPGRADE_CHANNEL, CONST_STABLE_UPGRADE_CHANNEL, CONST_PATCH_UPGRADE_CHANNEL, CONST_NODE_IMAGE_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to declare the default value here? Such as

arg_type=get_enum_type(...),..., default='xxx'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xhl873, assuming the answer is no. There was no default before.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use upgrade channel none as the default?

Copy link
Contributor Author

@charliedmcb charliedmcb Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, nil is used for unspecified, and upgrade channel none is used if the customer wants to turn it off.

We could make upgrade channel none the default for create, since there is nothing it would be turning off, but for update adding upgrade channel none as the default would make any update call turn off autoupgrade for the customer unless they specified it on each call.

I talked with Xiahe about this as we agreed that just adding a default like this for create did not make sense.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated model includes an enum value for unspecified

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could see making unspecified the default. Although, rejecting nil in place of a new unspecified value at this point would still break the preview CLI, and current behavior of the REST API if customers were using it directly. (ok, because autoupgrader is not GA yet?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, using unspecified over nil adds another channel to track where nil could be used, but I get the argument around removing the reliance on nil values.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure it matters too much, we can convert the nil to unspecified in RP ( or keep using nil )

Copy link
Contributor

@zhoxing-ms zhoxing-ms Aug 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
c.argument('auto_upgrade_channel', arg_type=get_enum_type([CONST_RAPID_UPGRADE_CHANNEL, CONST_STABLE_UPGRADE_CHANNEL, CONST_PATCH_UPGRADE_CHANNEL, CONST_NODE_IMAGE_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL]))
c.argument('auto_upgrade_channel', arg_type=get_enum_type(['rapid', 'stable', 'patch', 'node-image', 'none']))

c.argument('enable_cluster_autoscaler', action='store_true')
c.argument('cluster_autoscaler_profile', nargs='+', options_list=["--cluster-autoscaler-profile", "--ca-profile"], validator=validate_cluster_autoscaler_profile,
help="Space-separated list of key=value pairs for configuring cluster autoscaler. Pass an empty string to clear the profile.")
Expand Down Expand Up @@ -295,6 +297,7 @@ def load_arguments(self, _):
validator=validate_load_balancer_outbound_ports)
c.argument('load_balancer_idle_timeout', type=int,
validator=validate_load_balancer_idle_timeout)
c.argument('auto_upgrade_channel', arg_type=get_enum_type([CONST_RAPID_UPGRADE_CHANNEL, CONST_STABLE_UPGRADE_CHANNEL, CONST_PATCH_UPGRADE_CHANNEL, CONST_NODE_IMAGE_UPGRADE_CHANNEL, CONST_NONE_UPGRADE_CHANNEL]))
charliedmcb marked this conversation as resolved.
Show resolved Hide resolved
c.argument('api_server_authorized_ip_ranges',
type=str, validator=validate_ip_ranges)
c.argument('enable_ahub', options_list=['--enable-ahub'])
Expand Down
17 changes: 16 additions & 1 deletion src/azure-cli/azure/cli/command_modules/acs/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1940,6 +1940,7 @@ def aks_create(cmd, client, resource_group_name, name, ssh_key_value, # pylint:
load_balancer_outbound_ports=None,
charliedmcb marked this conversation as resolved.
Show resolved Hide resolved
load_balancer_idle_timeout=None,
outbound_type=None,
auto_upgrade_channel=None,
enable_addons=None,
workspace_resource_id=None,
vnet_subnet_id=None,
Expand Down Expand Up @@ -2329,6 +2330,10 @@ def aks_create(cmd, client, resource_group_name, name, ssh_key_value, # pylint:
cmd.cli_ctx,
cluster_identity_object_id)

auto_upgrade_profile = None
if auto_upgrade_channel is not None:
auto_upgrade_profile = ManagedClusterAutoUpgradeProfile(upgrade_channel=auto_upgrade_channel)

mc = ManagedCluster(
location=location,
tags=tags,
Expand All @@ -2346,7 +2351,8 @@ def aks_create(cmd, client, resource_group_name, name, ssh_key_value, # pylint:
api_server_access_profile=api_server_access_profile,
identity=identity,
disk_encryption_set_id=node_osdisk_diskencryptionset_id,
identity_profile=identity_profile
identity_profile=identity_profile,
auto_upgrade_profile=auto_upgrade_profile
)

use_custom_private_dns_zone = False
Expand Down Expand Up @@ -2642,6 +2648,7 @@ def aks_update(cmd, client, resource_group_name, name,
enable_ahub=False,
disable_ahub=False,
windows_admin_password=None,
auto_upgrade_channel=None,
enable_managed_identity=False,
assign_identity=None,
yes=False,
Expand Down Expand Up @@ -2683,6 +2690,7 @@ def aks_update(cmd, client, resource_group_name, name,
not update_aad_profile and
not enable_ahub and
not disable_ahub and
not auto_upgrade_channel and
not windows_admin_password and
not enable_managed_identity and
not assign_identity):
Expand All @@ -2695,6 +2703,7 @@ def aks_update(cmd, client, resource_group_name, name,
'"--load-balancer-outbound-ip-prefixes" or'
'"--load-balancer-outbound-ports" or'
'"--load-balancer-idle-timeout" or'
'"--auto-upgrade-channel" or '
'"--attach-acr" or "--detach-acr" or'
'"--uptime-sla" or'
'"--no-uptime-sla" or '
Expand Down Expand Up @@ -2856,6 +2865,12 @@ def aks_update(cmd, client, resource_group_name, name,
if disable_ahub:
instance.windows_profile.license_type = 'None'

if instance.auto_upgrade_profile is None:
instance.auto_upgrade_profile = ManagedClusterAutoUpgradeProfile()

if auto_upgrade_channel is not None:
instance.auto_upgrade_profile.upgrade_channel = auto_upgrade_channel

if windows_admin_password:
instance.windows_profile.admin_password = windows_admin_password

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4485,6 +4485,35 @@ def test_aks_update_to_msi_cluster_with_addons(self, resource_group, resource_gr
self.cmd(
'aks delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()])

@AllowLargeResponse()
@ResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
def test_aks_create_with_auto_upgrade_channel(self, resource_group, resource_group_location):
aks_name = self.create_random_name('cliakstest', 16)
self.kwargs.update({
'resource_group': resource_group,
'name': aks_name,
'location': resource_group_location,
})

# create
create_cmd = 'aks create --resource-group={resource_group} --name={name} --location={location} ' \
'--generate-ssh-keys --enable-managed-identity ' \
'--auto-upgrade-channel rapid'
self.cmd(create_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('autoUpgradeProfile.upgradeChannel', 'rapid')
])

# update upgrade channel
self.cmd('aks update --resource-group={resource_group} --name={name} --auto-upgrade-channel stable', checks=[
self.check('provisioningState', 'Succeeded'),
self.check('autoUpgradeProfile.upgradeChannel', 'stable')
])

# delete
self.cmd(
'aks delete -g {resource_group} -n {name} --yes --no-wait', checks=[self.is_empty()])

@live_only()
@AllowLargeResponse()
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='westus2')
Expand Down