Skip to content
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

[Serve] Expose replica and controller urls on load balancer #3351

Closed
wants to merge 3 commits into from

Conversation

Michaelvll
Copy link
Collaborator

@Michaelvll Michaelvll commented Mar 21, 2024

We now expose replica URLs from the load balancer for better metrics support.

curl https://lb_endpoint/-/urls

{
  'controller': 'https://endpoint:30001',
  'replicas': ['https://ip1:8080', 'https://ip2:8080']
}

Future TODO:

  • Add prometheus example

Tested (run the relevant ones):

  • Code formatting: bash format.sh
  • Any manual or new tests for this PR (please specify below)
    • sky serve up -n test examples/serve/http_server/task.yaml
    • curl $(sky serve status --endpoint test)/-/urls
  • All smoke tests: pytest tests/test_smoke.py
  • Relevant individual smoke tests: pytest tests/test_smoke.py::test_fill_in_the_name
  • Backward compatibility tests: bash tests/backward_comaptibility_tests.sh

Copy link
Member

@concretevitamin concretevitamin left a comment

Choose a reason for hiding this comment

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

Thanks, some comments.

async def _get_urls(self, request: fastapi.Request):
del request # Unused

ready_replica_urls = self._load_balancing_policy.ready_replicas
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should cache this in this SkyServeLoadBalancer class whenever we've finished a sync. Seems appropriate.

Alternatively, we should make abstract class LoadBalancingPolicy expose a get_ready_replicas() and use it here? Subclasses may want to have R/W locks to protect this field.

@@ -91,7 +91,21 @@ async def _redirect_handler(self, request: fastapi.Request):
logger.info(f'Redirecting request to {path}')
return fastapi.responses.RedirectResponse(url=path)

async def _get_urls(self, request: fastapi.Request):
Copy link
Member

Choose a reason for hiding this comment

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

nit: how about _get_ready_replicas?

nit: return type

ready_replica_urls = self._load_balancing_policy.ready_replicas
for i, ready_replica_url in enumerate(ready_replica_urls):
if not ready_replica_url.startswith('http'):
ready_replica_url = 'https://' + ready_replica_url
Copy link
Member

Choose a reason for hiding this comment

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

Why do we want to prepend this? E.g., Caddy / Prometheus's target lists do not require this.

ready_replica_url = 'https://' + ready_replica_url
ready_replica_urls[i] = ready_replica_url
return fastapi.responses.JSONResponse(content={
'controller': self._controller_url,
Copy link
Member

Choose a reason for hiding this comment

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

Oh I see the reason for this naming now. Shall we separate them out?

Copy link
Member

Choose a reason for hiding this comment

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

Are these intended?

Copy link

github-actions bot commented Aug 1, 2024

This PR is stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Aug 1, 2024
Copy link

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants