Skip to content

Support wss:// websocket URLs for api-managed SSH proxying [WIP] #5116

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 1 commit into
base: master
Choose a base branch
from

Conversation

funkypenguin
Copy link
Contributor

Fixes #5016

Signed-off-by: David Young [email protected]

This PR resolves (in a backwards-compatible way) the issues with ws:// vs wss:// raised in #5016.

I'm creating this as a WIP because I'm seeking guidance about how best to test locally.

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)

@@ -162,7 +162,7 @@ def _get_cluster_records_and_set_ssh_config(
# updating skypilot.
f'\'{sys.executable} {sky.__root_dir__}/templates/'
f'websocket_proxy.py '
f'{server_common.get_server_url().split("://")[1]} '
f'{server_common.get_server_url().replace("http://", "ws://").replace("https://", "wss://").split("://")[1]} '
Copy link
Collaborator

Choose a reason for hiding this comment

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

it seems after splitting, the URL passed to the executable will not be affected by the replacement. Should we remove the split, and make the replacement in sky/templates/websocket_proxy.py instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see what you mean, I left the split there, it shouldn't be there! What the best way to set this up to test locally on MacOS? I tried building the Dockerfile, but it just pulls the latest sky cli nightly with pip...

My thinking was to make this backwards-compatible, so that a user who still has a "non-protocoled" hostname in their config can still use sky/templates/websocket_proxy.py as-is (there's a check for :// in the hostname), but that any new configs created after this PR is merged will have either http:// or https:// in the config, which will better inform sky/templates/websocket_proxy.py re which websockets prefix to use.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point! For backward compatibility, I think we can deal with it in the websocket_proxy.py, where we can check if the protocol is included in the URL and default to http if not.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For testing it, a simple test might be mock the is_api_server_local to be False all the time?

@annotations.lru_cache(scope='global')
def is_api_server_local():
return get_server_url() in AVAILABLE_LOCAL_API_SERVER_URLS

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What I'm after in terms of advice on testing is more about how to build the CLI locally? I was hoping to do it in a dockerfile to keep dependencies etc clean, but the Dockerfile seems to just pull the latest nightly with pip. Is there a "best practice" way to test this locally?

@Michaelvll Michaelvll requested review from romilbhardwaj and removed request for romilbhardwaj April 9, 2025 18:21
@Michaelvll
Copy link
Collaborator

Thanks for the great effort on this PR @funkypenguin ! This PR #5183 works on the same issue by coincidence. We are thinking of directly having that PR to be merged. Could you help check if that PR solves your issue as well? Your input would be really important :)

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.

Support wss:// websocket URLs for api-managed SSH proxying
2 participants