-
Notifications
You must be signed in to change notification settings - Fork 3k
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 nodepool delete-machines
: Add support to delete specific machines in an agent pool
#29921
[AKS] az aks nodepool delete-machines
: Add support to delete specific machines in an agent pool
#29921
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -134,6 +134,7 @@ def load_command_table(self, _): | |
g.custom_command('start', 'aks_agentpool_start', supports_no_wait=True) | ||
g.wait_command('wait') | ||
g.custom_command('operation-abort', 'aks_agentpool_operation_abort', supports_no_wait=True) | ||
g.custom_command("delete-machines", "aks_agentpool_delete_machines", supports_no_wait=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Rules in CI might be a bit rigid, I guess changing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
|
||
with self.command_group('aks command', managed_clusters_sdk, client_factory=cf_managed_clusters) as g: | ||
g.custom_command('invoke', 'aks_runcommand', supports_no_wait=True, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
import unittest | ||
|
||
from azure.cli.command_modules.acs._format import version_to_tuple | ||
from azure.cli.command_modules.acs._format import aks_machine_list_table_format | ||
from azure.cli.command_modules.acs._helpers import ( | ||
_get_test_sp_object_id, | ||
get_shared_control_plane_identity, | ||
|
@@ -7923,6 +7924,69 @@ def test_aks_nodepool_snapshot(self, resource_group, resource_group_location): | |
self.is_empty() | ||
]) | ||
|
||
@AllowLargeResponse() | ||
@AKSCustomResourceGroupPreparer( | ||
random_name_length=17, name_prefix="clitest", location="westus2" | ||
) | ||
def test_aks_nodepool_delete_machines(self, resource_group, resource_group_location): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Queued live test for this, you'll need to commit the recording file (would be generated by running the test case in live mode, find it from pipeline artifact) to pass CI. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://dev.azure.com/msazure/CloudNativeCompute/_build/results?buildId=103633419&view=results This is the passed test I ran. Wondering which recording file do I need? btw, I uploaded the test_aks_nodepool_delete_machines.yaml already. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Take another look, it seems that you performed some data plane operations in the test case, which cannot be properly replayed. Please mark the case as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
aks_name = self.create_random_name("cliakstest", 16) | ||
nodepool_name = self.create_random_name("c", 6) | ||
self.kwargs.update( | ||
{ | ||
"resource_group": resource_group, | ||
"location": resource_group_location, | ||
"name": aks_name, | ||
"nodepool_name": nodepool_name, | ||
"ssh_key_value": self.generate_ssh_keys(), | ||
} | ||
) | ||
|
||
# create aks cluster | ||
create_cmd = "aks create --resource-group={resource_group} --name={name} --ssh-key-value={ssh_key_value}" | ||
self.cmd( | ||
create_cmd, | ||
checks=[ | ||
self.check("provisioningState", "Succeeded"), | ||
], | ||
) | ||
# add nodepool | ||
self.cmd( | ||
"aks nodepool add --resource-group={resource_group} --cluster-name={name} --name={nodepool_name} --node-count=4", | ||
checks=[self.check("provisioningState", "Succeeded")], | ||
) | ||
# list machines | ||
list_cmd = 'aks machine list ' \ | ||
' --resource-group={resource_group} ' \ | ||
' --cluster-name={name} --nodepool-name={nodepool_name} -o json' | ||
machine_list = self.cmd(list_cmd).get_output_in_json() | ||
assert len(machine_list) == 4 | ||
aks_machine_list_table_format(machine_list) | ||
# delete machines | ||
machine_name1 = machine_list[0]["name"] | ||
machine_name2 = machine_list[2]["name"] | ||
self.kwargs.update( | ||
{ | ||
"resource_group": resource_group, | ||
"location": resource_group_location, | ||
"name": aks_name, | ||
"nodepool_name": nodepool_name, | ||
"ssh_key_value": self.generate_ssh_keys(), | ||
"machine_name1": machine_name1, | ||
"machine_name2": machine_name2, | ||
} | ||
) | ||
self.cmd( | ||
"aks nodepool delete-machines --resource-group={resource_group} --cluster-name={name} --nodepool-name={nodepool_name} --machine-names {machine_name1} {machine_name2}" | ||
) | ||
# list machines after deletion | ||
machine_list_after = self.cmd(list_cmd).get_output_in_json() | ||
assert len(machine_list_after) == 2 | ||
# delete AKS cluster | ||
self.cmd( | ||
"aks delete -g {resource_group} -n {name} --yes --no-wait", | ||
checks=[self.is_empty()], | ||
) | ||
|
||
@AllowLargeResponse() | ||
@AKSCustomResourceGroupPreparer(random_name_length=17, name_prefix='clitest', location='centraluseuap') | ||
def test_aks_create_with_windows_gmsa(self, resource_group, resource_group_location): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some unit tests for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finally decide to use kubectl to get machine name instead of use machine api. Machine api is not GA yet.