diff --git a/src/cli/onefuzz/api.py b/src/cli/onefuzz/api.py index 01c502c049..afb219bf0d 100644 --- a/src/cli/onefuzz/api.py +++ b/src/cli/onefuzz/api.py @@ -1059,13 +1059,16 @@ def delete( for container_name in to_keep: self.logger.info("not removing: %s", container_name) - for container_name in to_delete: - if dryrun: - self.logger.info("container would be deleted: %s", container_name) - elif self.onefuzz.containers.delete(container_name).result: - self.logger.info("removed container: %s", container_name) - else: - self.logger.info("container already removed: %s", container_name) + if len(to_delete) > 0: + for container_name in to_delete: + if dryrun: + self.logger.info("container would be deleted: %s", container_name) + elif self.onefuzz.containers.delete(container_name).result: + self.logger.info("removed container: %s", container_name) + else: + self.logger.info("container already removed: %s", container_name) + else: + self.logger.info("nothing to delete") class JobTasks(Endpoint):