Skip to content

Commit 54e5f2d

Browse files
Enrico Usaitilne
authored andcommitted
Improve messages from delete command when cluster does not exist
Before: ``` Deleting: test WARNING: Cluster test has already been deleted. Checking if there are any running compute fleet nodes that require termination ``` After: ``` Deleting: test WARNING: Cluster test has already been deleted or does not exist. Checking if there are running compute nodes that require termination... Compute fleet cleaned up. ``` Signed-off-by: Enrico Usai <[email protected]>
1 parent bbcf0ed commit 54e5f2d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

cli/pcluster/cli_commands/delete.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def delete(args):
3434
args.cluster_name
3535
)
3636
)
37-
utils.warn("Cluster {0} has already been deleted.".format(args.cluster_name))
37+
utils.warn("Cluster {0} has already been deleted or does not exist.".format(args.cluster_name))
3838
_terminate_cluster_nodes(stack_name)
3939
sys.exit(0)
4040
elif args.keep_logs:
@@ -130,17 +130,15 @@ def _delete_cluster(cluster_name, nowait):
130130

131131
def _terminate_cluster_nodes(stack_name):
132132
try:
133-
LOGGER.debug("Compute fleet clean-up: STARTED")
134-
# FIXME: improve messaging when cluster does not exist
135-
LOGGER.info("\nChecking if there are any running compute fleet nodes that require termination")
133+
LOGGER.info("\nChecking if there are running compute nodes that require termination...")
136134
ec2 = boto3.client("ec2", config=Config(retries={"max_attempts": 10}))
137135

138136
for instance_ids in _describe_instance_ids_iterator(stack_name):
139137
LOGGER.info("Terminating following instances: %s", instance_ids)
140138
if instance_ids:
141139
ec2.terminate_instances(InstanceIds=instance_ids)
142140

143-
LOGGER.debug("Compute fleet clean-up: COMPLETED")
141+
LOGGER.info("Compute fleet cleaned up.")
144142
except Exception as e:
145143
LOGGER.error("Failed when checking for running EC2 instances with error: %s", e)
146144

cli/tests/pcluster/cli_commands/test_pcluster_delete.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def test_delete(
5959

6060
assert_that(warn_mock.call_count).is_equal_to(warn_call_count)
6161
if warn_call_count > 0:
62-
warn_mock.assert_called_with("Cluster {0} has already been deleted.".format(args.cluster_name))
62+
warn_mock.assert_called_with(
63+
"Cluster {0} has already been deleted or does not exist.".format(args.cluster_name)
64+
)
6365

6466
assert_that(persist_cloudwatch_log_groups_mock.called).is_equal_to(persist_called)
6567
if persist_called:

0 commit comments

Comments
 (0)