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

[k8s] Fix --purge not cleaning up cluster in stale k8s context #4514

Merged
merged 6 commits into from
Jan 6, 2025
Merged
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
28 changes: 21 additions & 7 deletions sky/backends/cloud_vm_ray_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -4198,11 +4198,20 @@ def post_teardown_cleanup(self,
attempts = 0
while True:
logger.debug(f'instance statuses attempt {attempts + 1}')
node_status_dict = provision_lib.query_instances(
repr(cloud),
cluster_name_on_cloud,
config['provider'],
non_terminated_only=False)
try:
node_status_dict = provision_lib.query_instances(
repr(cloud),
cluster_name_on_cloud,
config['provider'],
non_terminated_only=False)
except Exception as e: # pylint: disable=broad-except
if purge:
logger.warning(
f'Failed to query instances. Skipping since purge is '
f'set. Details: '
f'{common_utils.format_exception(e, use_bracket=True)}')
break
raise

unexpected_node_state: Optional[Tuple[str, str]] = None
for node_id, node_status in node_status_dict.items():
Expand All @@ -4221,8 +4230,13 @@ def post_teardown_cleanup(self,
time.sleep(_TEARDOWN_WAIT_BETWEEN_ATTEMPS_SECONDS)
else:
(node_id, node_status) = unexpected_node_state
raise RuntimeError(f'Instance {node_id} in unexpected state '
f'{node_status}.')
if purge:
logger.warning(f'Instance {node_id} in unexpected '
f'state {node_status}. Skipping since purge '
'is set.')
break
raise RuntimeError(f'Instance {node_id} in unexpected '
f'state {node_status}.')

global_user_state.remove_cluster(handle.cluster_name,
terminate=terminate)
Expand Down
Loading