Skip to content

Commit

Permalink
API: fix a possibly unbound error in core.cancel(). (#2061)
Browse files Browse the repository at this point in the history
Core: fix a possibly unbound error in core.cancel().
  • Loading branch information
concretevitamin authored Jun 11, 2023
1 parent 17a8dc8 commit c5a60d4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sky/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ def cancel(
cluster_name, operation_str='Cancelling jobs')

# Check the status of the cluster.
handle = None
try:
handle = backend_utils.check_cluster_available(
cluster_name,
Expand All @@ -572,11 +573,15 @@ def cancel(
isinstance(e.handle, backends.CloudVmRayResourceHandle)), e
if (e.handle is None or e.handle.head_ip is None):
raise
handle = e.handle
# Even if the cluster is not UP, we can still try to cancel the job if
# the head node is still alive. This is useful when a spot cluster's
# worker node is preempted, but we can still cancel the job on the head
# node.

assert handle is not None, (
f'handle for cluster {cluster_name!r} should not be None')

backend = backend_utils.get_backend_from_handle(handle)

if all:
Expand Down

0 comments on commit c5a60d4

Please sign in to comment.