Skip to content

Commit

Permalink
wrap stop
Browse files Browse the repository at this point in the history
  • Loading branch information
asaiacai committed Sep 29, 2024
1 parent 56163c0 commit 0d39425
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
5 changes: 1 addition & 4 deletions sky/provision/do/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ def stop_instances(
if worker_only and instance_name.endswith('-head'):
num_instances -= 1
continue
utils.client().droplet_actions.post(
droplet_id=instance_meta['id'],
body={'type': 'shutdown'},
)
utils.stop_instance(instance_meta)

# Wait for instances to stop
for _ in range(MAX_POLLS_FOR_UP_OR_STOP):
Expand Down
9 changes: 8 additions & 1 deletion sky/provision/do/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,18 @@ def create_instance(region: str, cluster_name_on_cloud: str, instance_type: str,
return instance


def start_instance(instance: Dict[str, Any]) -> None:
def start_instance(instance: Dict[str, Any]):
client().droplet_actions.post(droplet_id=instance['id'],
body={'type': 'power_on'})


def stop_instance(instance: Dict[str, Any]):
client().droplet_actions.post(
droplet_id=instance['id'],
body={'type': 'shutdown'},
)


def filter_instances(
cluster_name_on_cloud: str,
status_filters: Optional[List[str]] = None) -> Dict[str, Any]:
Expand Down

0 comments on commit 0d39425

Please sign in to comment.