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

[AKS] az aks update/az aks nodepool update: Allow empty string as label value #4351

Merged
merged 6 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1772,7 +1772,7 @@ def aks_agentpool_update(cmd, # pylint: disable=unused-argument
update_autoscaler = enable_cluster_autoscaler + \
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 not labels):
if (update_autoscaler != 1 and not tags and not scale_down_mode and not mode and not max_surge and labels is None):
raise CLIError('Please specify one or more of "--enable-cluster-autoscaler" or '
'"--disable-cluster-autoscaler" or '
'"--update-cluster-autoscaler" or '
Expand Down
3 changes: 2 additions & 1 deletion src/aks-preview/azext_aks_preview/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,8 @@ def check_raw_parameters(self):
# some parameters support the use of empty string or dictionary to update/remove previously set values
is_default = (
self.context.get_cluster_autoscaler_profile() is None and
self.context.get_api_server_authorized_ip_ranges() is None
self.context.get_api_server_authorized_ip_ranges() is None and
self.context.get_nodepool_labels() is None
)

if not is_changed and is_default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ interactions:
"maxPods": 110, "osType": "Linux", "osSKU": "Ubuntu", "enableAutoScaling": false,
"type": "VirtualMachineScaleSets", "mode": "System", "orchestratorVersion":
"1.21.7", "upgradeSettings": {}, "powerState": {"code": "Running"}, "enableNodePublicIP":
false, "nodeLabels": {"label1": "value2"}, "enableEncryptionAtHost": false,
false, "nodeLabels": {}, "enableEncryptionAtHost": false,
"enableUltraSSD": false, "enableFIPS": false}}'
headers:
Accept:
Expand Down Expand Up @@ -1102,7 +1102,7 @@ interactions:
\ \"type\": \"VirtualMachineScaleSets\",\n \"enableAutoScaling\": false,\n
\ \"provisioningState\": \"Updating\",\n \"powerState\": {\n \"code\":
\"Running\"\n },\n \"orchestratorVersion\": \"1.21.7\",\n \"enableNodePublicIP\":
false,\n \"nodeLabels\": {\n \"label1\": \"value2\"\n },\n \"mode\":
false,\n \"nodeLabels\": {\n \n },\n \"mode\":
\"System\",\n \"enableEncryptionAtHost\": false,\n \"enableUltraSSD\":
false,\n \"osType\": \"Linux\",\n \"osSKU\": \"Ubuntu\",\n \"nodeImageVersion\":
\"AKSUbuntu-1804gen2containerd-2021.12.07\",\n \"upgradeSettings\": {},\n
Expand Down Expand Up @@ -1214,7 +1214,7 @@ interactions:
\ \"type\": \"VirtualMachineScaleSets\",\n \"enableAutoScaling\": false,\n
\ \"provisioningState\": \"Succeeded\",\n \"powerState\": {\n \"code\":
\"Running\"\n },\n \"orchestratorVersion\": \"1.21.7\",\n \"enableNodePublicIP\":
false,\n \"nodeLabels\": {\n \"label1\": \"value2\"\n },\n \"mode\":
false,\n \"nodeLabels\": {\n \n },\n \"mode\":
\"System\",\n \"enableEncryptionAtHost\": false,\n \"enableUltraSSD\":
false,\n \"osType\": \"Linux\",\n \"osSKU\": \"Ubuntu\",\n \"nodeImageVersion\":
\"AKSUbuntu-1804gen2containerd-2021.12.07\",\n \"upgradeSettings\": {},\n
Expand Down Expand Up @@ -1273,7 +1273,7 @@ interactions:
\ \"type\": \"VirtualMachineScaleSets\",\n \"enableAutoScaling\": false,\n
\ \"provisioningState\": \"Succeeded\",\n \"powerState\": {\n \"code\":
\"Running\"\n },\n \"orchestratorVersion\": \"1.21.7\",\n \"enableNodePublicIP\":
false,\n \"nodeLabels\": {\n \"label1\": \"value2\"\n },\n \"mode\":
false,\n \"nodeLabels\": {\n \n },\n \"mode\":
\"System\",\n \"enableEncryptionAtHost\": false,\n \"enableUltraSSD\":
false,\n \"osType\": \"Linux\",\n \"osSKU\": \"Ubuntu\",\n \"nodeImageVersion\":
\"AKSUbuntu-1804gen2containerd-2021.12.07\",\n \"upgradeSettings\": {},\n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ interactions:
"OCIContainer", "maxPods": 110, "osType": "Linux", "osSKU": "Ubuntu", "enableAutoScaling":
false, "type": "VirtualMachineScaleSets", "mode": "System", "orchestratorVersion":
"1.21.7", "powerState": {"code": "Running"}, "enableNodePublicIP": false, "nodeLabels":
{"label1": "value11"}, "enableEncryptionAtHost": false, "enableUltraSSD": false,
{}, "enableEncryptionAtHost": false, "enableUltraSSD": false,
"enableFIPS": false, "name": "nodepool1"}], "linuxProfile": {"adminUsername":
"azureuser", "ssh": {"publicKeys": [{"keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCYjiOAmfMwVuIAE31nCYs7f3ygC/sIwuNTchhXbeuMgnBngX9/ytGfyDPtJcHeAWGAWJqXDvlQ1zKcqvkEcEbrRioF6s6KrihUEbZp/QqspPRMkCLxl+11LcUkxDiErzX3oc9Wa9YiKEZIq4E2nOASLya8SVFWl3rQWaHsXe07JiH7AE9Gf6GaJsjn+coQ3yE12u6kpbduPWLSTdEiAeFKvM/jrUtLWVyxli0jvgZjU+y/VJuQJlhqZcHKeK0xG8JD8lgryv2Fu4esrxw2YqSJGySoE4Fm+BMe3wsydbf3cbzj7mI6WAMbA0aFS6atge+Cn4tuOWa3BYa2XIKOYXhl
azcli_aks_live_test@example.com\n"}]}}, "servicePrincipalProfile": {"clientId":"00000000-0000-0000-0000-000000000001"},
Expand Down Expand Up @@ -1050,7 +1050,7 @@ interactions:
\ \"enableAutoScaling\": false,\n \"provisioningState\": \"Updating\",\n
\ \"powerState\": {\n \"code\": \"Running\"\n },\n \"orchestratorVersion\":
\"1.21.7\",\n \"enableNodePublicIP\": false,\n \"nodeLabels\": {\n
\ \"label1\": \"value11\"\n },\n \"mode\": \"System\",\n \"enableEncryptionAtHost\":
\ \n },\n \"mode\": \"System\",\n \"enableEncryptionAtHost\":
false,\n \"enableUltraSSD\": false,\n \"osType\": \"Linux\",\n \"osSKU\":
\"Ubuntu\",\n \"nodeImageVersion\": \"AKSUbuntu-1804gen2containerd-2021.12.07\",\n
\ \"enableFIPS\": false\n }\n ],\n \"linuxProfile\": {\n \"adminUsername\":
Expand Down Expand Up @@ -1285,7 +1285,7 @@ interactions:
\ \"enableAutoScaling\": false,\n \"provisioningState\": \"Succeeded\",\n
\ \"powerState\": {\n \"code\": \"Running\"\n },\n \"orchestratorVersion\":
\"1.21.7\",\n \"enableNodePublicIP\": false,\n \"nodeLabels\": {\n
\ \"label1\": \"value11\"\n },\n \"mode\": \"System\",\n \"enableEncryptionAtHost\":
\ \n },\n \"mode\": \"System\",\n \"enableEncryptionAtHost\":
false,\n \"enableUltraSSD\": false,\n \"osType\": \"Linux\",\n \"osSKU\":
\"Ubuntu\",\n \"nodeImageVersion\": \"AKSUbuntu-1804gen2containerd-2021.12.07\",\n
\ \"enableFIPS\": false\n }\n ],\n \"linuxProfile\": {\n \"adminUsername\":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3132,7 +3132,6 @@ def test_aks_nodepool_update_label_msi(self, resource_group, resource_group_loca
aks_name = self.create_random_name('cliakstest', 16)
nodepool1_name = "nodepool1"
nodepool2_name = "nodepool2"
nodepool3_name = "nodepool3"
tags = "key1=value1"
new_tags = "key2=value2"
labels = "label1=value1"
Expand All @@ -3148,7 +3147,6 @@ def test_aks_nodepool_update_label_msi(self, resource_group, resource_group_loca
'labels': labels,
'nodepool1_name': nodepool1_name,
'nodepool2_name': nodepool2_name,
'nodepool3_name': nodepool3_name
})

# create
Expand Down Expand Up @@ -3185,6 +3183,7 @@ def test_aks_nodepool_update_label_msi(self, resource_group, resource_group_loca
os.close(fd)
os.remove(temp_path)

# nodepool update nodepool1 label
self.cmd('aks nodepool update --resource-group={resource_group} --cluster-name={name} --name={nodepool1_name} --labels {labels}', checks=[
self.check('provisioningState', 'Succeeded'),
])
Expand All @@ -3195,14 +3194,14 @@ def test_aks_nodepool_update_label_msi(self, resource_group, resource_group_loca
self.check('[0].nodeLabels.label1', 'value1'),
])

# nodepool update nodepool2 label
self.cmd('aks nodepool update --resource-group={resource_group} --cluster-name={name} --name={nodepool1_name} --labels label1=value2', checks=[
self.check('nodeLabels.label1', 'value2')
# nodepool delete nodepool1 label
self.cmd('aks nodepool update --resource-group={resource_group} --cluster-name={name} --name={nodepool1_name} --labels ', checks=[
self.check('nodeLabels.label1', None)
])

# nodepool show
self.cmd('aks nodepool show --resource-group={resource_group} --cluster-name={name} --name={nodepool1_name}', checks=[
self.check('nodeLabels.label1', 'value2')
self.check('nodeLabels.label1', None)
])


Expand Down Expand Up @@ -3250,10 +3249,10 @@ def test_aks_update_label_msi(self, resource_group, resource_group_location):
])

update_cmd = 'aks update --resource-group={resource_group} --name={name} ' \
'--nodepool-labels label1=value11'
'--nodepool-labels '
self.cmd(update_cmd, checks=[
self.check('provisioningState', 'Succeeded'),
self.check('agentPoolProfiles[0].nodeLabels.label1', 'value11'),
self.check('agentPoolProfiles[0].nodeLabels.label1', None),
self.check('agentPoolProfiles[0].nodeLabels.label2', None),
])

Expand Down