Skip to content

Commit

Permalink
[SkyServe] Fix replica log not found when replica cluster not found (#…
Browse files Browse the repository at this point in the history
…2924)

* fix

* log position
  • Loading branch information
cblmemo authored Jan 3, 2024
1 parent 318553b commit 527eb4c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions sky/serve/serve_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,6 @@ def stream_replica_logs(service_name: str,

replica_cluster_name = generate_replica_cluster_name(
service_name, replica_id)
handle = global_user_state.get_handle_from_cluster_name(
replica_cluster_name)
if handle is None:
return _FAILED_TO_FIND_REPLICA_MSG.format(replica_id=replica_id)
assert isinstance(handle, backends.CloudVmRayResourceHandle), handle

launch_log_file_name = generate_replica_launch_log_file_name(
service_name, replica_id)
Expand Down Expand Up @@ -575,11 +570,17 @@ def _get_replica_status() -> serve_state.ReplicaStatus:
# Early exit if not following the logs.
return ''

backend = backends.CloudVmRayBackend()
handle = global_user_state.get_handle_from_cluster_name(
replica_cluster_name)
if handle is None:
return _FAILED_TO_FIND_REPLICA_MSG.format(replica_id=replica_id)
assert isinstance(handle, backends.CloudVmRayResourceHandle), handle

# Notify user here to make sure user won't think the log is finished.
print(f'{colorama.Fore.YELLOW}Start streaming logs for task job '
f'of replica {replica_id}...{colorama.Style.RESET_ALL}')

backend = backends.CloudVmRayBackend()
# Always tail the latest logs, which represent user setup & run.
returncode = backend.tail_logs(handle, job_id=None, follow=follow)
if returncode != 0:
Expand Down

0 comments on commit 527eb4c

Please sign in to comment.