Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cblmemo committed Sep 14, 2023
1 parent baf62f9 commit 4c52014
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
6 changes: 6 additions & 0 deletions sky/backends/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class ReservedClusterGroup(enum.Enum):
f'sky spot queue{colorama.Style.RESET_ALL}'),
decline_stop_hint=('Spot controller will be auto-stopped after all '
'spot jobs finish.'),
decline_cancel_hint=(
'Cancelling the spot controller\'s jobs is not allowed.\nTo cancel '
f'spot jobs, use: {colorama.Style.BRIGHT}sky spot cancel <spot '
f'job IDs> [--all]{colorama.Style.RESET_ALL}'),
check_cluster_name_hint=(
f'Cluster {spot_lib.SPOT_CONTROLLER_NAME} is reserved for '
'managed spot controller. '))
Expand All @@ -138,6 +142,8 @@ class ReservedClusterGroup(enum.Enum):
f'sky serve status{colorama.Style.RESET_ALL}'),
decline_stop_hint=(f'To teardown a service, use {colorama.Style.BRIGHT}'
f'sky serve down{colorama.Style.RESET_ALL}.'),
decline_cancel_hint=(
'Cancelling the sky serve controller\'s jobs is not allowed.'),
check_cluster_name_hint=(
f'Cluster prefix {serve_lib.CONTROLLER_PREFIX} is reserved for '
'sky serve controller. '))
Expand Down
18 changes: 3 additions & 15 deletions sky/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
from sky import core
from sky import exceptions
from sky import global_user_state
from sky import serve as serve_lib
from sky import sky_logging
from sky import spot as spot_lib
from sky import status_lib
Expand Down Expand Up @@ -2102,8 +2101,6 @@ def cancel(cluster: str, all: bool, jobs: List[int], yes: bool): # pylint: disa
Job IDs can be looked up by ``sky queue cluster_name``.
"""
bold = colorama.Style.BRIGHT
reset = colorama.Style.RESET_ALL
job_identity_str = None
job_ids_to_cancel = None
if not jobs and not all:
Expand Down Expand Up @@ -2131,18 +2128,9 @@ def cancel(cluster: str, all: bool, jobs: List[int], yes: bool): # pylint: disa
try:
core.cancel(cluster, all=all, job_ids=job_ids_to_cancel)
except exceptions.NotSupportedError:
if cluster == spot_lib.SPOT_CONTROLLER_NAME:
# Friendly message for usage like 'sky cancel <spot controller>
# -a/<jobid>'.
error_str = (
'Cancelling the spot controller\'s jobs is not allowed.'
f'\nTo cancel spot jobs, use: {bold}sky spot cancel <spot '
f'job IDs> [--all]{reset}')
else:
assert cluster.startswith(serve_lib.CONTROLLER_PREFIX)
error_str = (
'Cancelling the sky serve controller\'s jobs is not allowed.')
click.echo(error_str)
group = backend_utils.ReservedClusterGroup.get_group(cluster)
assert group is not None
click.echo(group.value.decline_cancel_hint)
sys.exit(1)
except ValueError as e:
raise click.UsageError(str(e))
Expand Down
9 changes: 6 additions & 3 deletions sky/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,20 @@ def _start(
f'Starting cluster {cluster_name!r} with backend {backend.NAME} '
'is not supported.')

if cluster_name == spot.SPOT_CONTROLLER_NAME:
if backend_utils.ReservedClusterGroup.get_group(cluster_name) is not None:
if down:
raise ValueError('Using autodown (rather than autostop) is not '
'supported for the spot controller. Pass '
'supported for skypilot controllers. Pass '
'`down=False` or omit it instead.')
if idle_minutes_to_autostop is not None:
raise ValueError(
'Passing a custom autostop setting is currently not '
'supported when starting the spot controller. To '
'supported when starting skypilot controllers. To '
'fix: omit the `idle_minutes_to_autostop` argument to use the '
f'default autostop settings (got: {idle_minutes_to_autostop}).')
# TODO(tian): Maybe we should merge the two MINUTES_TO_AUTOSTOP
# together. Currently, the two value is the same so we just use spot
# constant here.
idle_minutes_to_autostop = spot.SPOT_CONTROLLER_IDLE_MINUTES_TO_AUTOSTOP

# NOTE: if spot_queue() calls _start() and hits here, that entrypoint
Expand Down

0 comments on commit 4c52014

Please sign in to comment.