Skip to content

Commit

Permalink
revert using constants for cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
landscapepainter committed Aug 27, 2024
1 parent 68af033 commit 7a26edc
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions sky/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2257,7 +2257,7 @@ def autostop(
'Only one of --idle-minutes and --cancel should be specified. '
f'cancel: {cancel}, idle_minutes: {idle_minutes}')
if cancel:
idle_minutes = constants.IDLE_MINUTES_TO_AUTOSTOP_FOR_CANCEL
idle_minutes = -1
elif idle_minutes is None:
idle_minutes = 5
_down_or_stop_clusters(clusters,
Expand Down Expand Up @@ -2704,8 +2704,7 @@ def _down_or_stop_clusters(

operation = 'Terminating' if down else 'Stopping'
if idle_minutes_to_autostop is not None:
is_cancel = (idle_minutes_to_autostop ==
constants.IDLE_MINUTES_TO_AUTOSTOP_FOR_CANCEL)
is_cancel = idle_minutes_to_autostop < 0
verb = 'Cancelling' if is_cancel else 'Scheduling'
option_str = 'down' if down else 'stop'
if is_cancel:
Expand Down
2 changes: 1 addition & 1 deletion sky/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def autostop(
sky.exceptions.CloudUserIdentityError: if we fail to get the current
user identity.
"""
is_cancel = idle_minutes == constants.IDLE_MINUTES_TO_AUTOSTOP_FOR_CANCEL
is_cancel = idle_minutes < 0
verb = 'Cancelling' if is_cancel else 'Scheduling'
option_str = 'down' if down else 'stop'
if is_cancel:
Expand Down
4 changes: 2 additions & 2 deletions sky/provision/kubernetes/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1849,8 +1849,8 @@ def set_autodown_annotations(handle: 'backends.CloudVmRayResourceHandle',
annotation=annotation,
namespace=namespace)

elif (idle_minutes_to_autostop is not None and idle_minutes_to_autostop
== constants.IDLE_MINUTES_TO_AUTOSTOP_FOR_CANCEL):
elif (idle_minutes_to_autostop is not None and
idle_minutes_to_autostop < 0):
for annotation_key in annotation_keys:
_remove_pod_annotations(pod=pod,
annotation_key=annotation_key,
Expand Down
4 changes: 1 addition & 3 deletions sky/skylet/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,7 @@
# controller and sky serve controller.
# TODO(tian): Refactor to controller_utils. Current blocker: circular import.
CONTROLLER_IDLE_MINUTES_TO_AUTOSTOP = 10
# idle_minutes_to_autostop value used to indicate cancellation on registered
# autostop/down.
IDLE_MINUTES_TO_AUTOSTOP_FOR_CANCEL = -1

# Due to the CPU/memory usage of the controller process launched with sky jobs (
# use ray job under the hood), we need to reserve some CPU/memory for each jobs/
# serve controller process.
Expand Down

0 comments on commit 7a26edc

Please sign in to comment.