Skip to content

Fix serve status ordering by READY and versionfix replica ordering #5188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mert-cemri
Copy link

Fixes #3052

  • Show READY replicas at the top
  • Order replicas by descending version

Tested (run the relevant ones):

  • Code formatting: install pre-commit (auto-check on commit) or bash format.sh
  • Any manual or new tests for this PR (please specify below)
  • All smoke tests: /smoke-test (CI) or pytest tests/test_smoke.py (local)
  • Relevant individual tests: /smoke-test -k test_name (CI) or pytest tests/test_smoke.py::test_name (local)
  • Backward compatibility: /quicktest-core (CI) or pytest tests/smoke_tests/test_backward_compat.py (local)

@Michaelvll Michaelvll requested a review from cblmemo April 11, 2025 16:28
Copy link
Collaborator

@cblmemo cblmemo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this @mert-cemri ! It mostly looks good to me. However, there seems to contain some unnecessary refactoring. Could we keep as much original code as possible to keep the chance of breaking anything as low as possible?

Comment on lines +4722 to +4723
service_names_to_query: Optional[List[str]] = list(
service_names) if service_names else None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to convert it to list here?

service_names_to_query: Optional[List[str]] = list(
service_names) if service_names else None

# Show a status message while fetching data
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those comments looks a little bit tedious. Could we remove them?

Comment on lines +767 to +788
def _sort_replica_records(
replica_records: List[Dict[str, Any]]) -> List[Dict[str, Any]]:
"""Sort replica records based on version, status and replica_id."""

# Define the sorting key function internally
def _sort_key(replica_record: Dict[str, Any]) -> Tuple[int, int, int]:
# Sort by version descending (latest first)
version = int(replica_record.get('version', 0))
# Sort by status, prioritizing READY
if replica_record['status'] == serve_state.ReplicaStatus.READY:
status_priority = 0
elif replica_record['status'] == serve_state.ReplicaStatus.PROVISIONING:
status_priority = 1
else:
status_priority = 2
# Sort by replica_id ascending as a tie-breaker
replica_id = int(replica_record.get('id', 0))
return -version, status_priority, replica_id

# Sort the records using the defined key
sorted_records = sorted(replica_records, key=_sort_key)
return sorted_records
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems will mix replica records for different service together. Should we sort first based on its service name?

if not service_records:
return 'No existing services.'
return 'No services found.'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change this?

# Add service name and replica id to replica info dict.
for info in record['replica_info']:
info['service_name'] = record['name']
info['replica_id'] = info['id']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Serve] sky serve status should show ready replicas at the top and ordered by the version
2 participants