Skip to content

[apiserversdk] check service belongs to kuberay #3563

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

Conversation

troychiu
Copy link
Contributor

@troychiu troychiu commented May 8, 2025

Why are these changes needed?

wrap the handler with a checker which make sure the service exists and belongs to kuberay.

End-to-end tests

service exists but doesn't belong to kuberay
Screenshot 2025-05-08 at 1 12 28 AM
service doesn't exist
Screenshot 2025-05-08 at 1 12 42 AM
service exists and belongs to kuberay
Screenshot 2025-05-08 at 1 12 52 AM

Related issue number

Closes #3521

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(

troychiu added 3 commits May 8, 2025 00:27
Signed-off-by: Troy Chiu <y.troychiu@gmail.com>
Signed-off-by: Troy Chiu <y.troychiu@gmail.com>
Signed-off-by: Troy Chiu <y.troychiu@gmail.com>
@troychiu troychiu marked this pull request as ready for review May 8, 2025 08:20
@troychiu
Copy link
Contributor Author

troychiu commented May 8, 2025

Hi @rueian can I get a review from you? Thank you.

return nil, err
}

return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor

Choose a reason for hiding this comment

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

curious about the decision here to choose anonymous function, instead of a normal function?

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 don't have a preference. Do you prefer a normal function?

troychiu added 2 commits May 8, 2025 22:05
Signed-off-by: Troy Chiu <y.troychiu@gmail.com>
Signed-off-by: Troy Chiu <y.troychiu@gmail.com>
@troychiu troychiu requested review from rueian and dentiny May 10, 2025 06:34
Comment on lines 43 to 45
// This pattern allows accessing KubeRay dashboards and job submissions.
// Note: We register both "/proxy" and "/proxy/" to handle requests with and without trailing slashes.
// See https://pkg.go.dev/net/http#hdr-Trailing_slash_redirection-ServeMux
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move the comment to the test? We can have examples to show why avoiding trailing slash redirection matters there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

do you mean keeping the comments in both place or entirely move to the test?

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer to entirely move to the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why moving to test? I thought this comment was telling people why we register two paths. I won't expect people read tests.

Copy link
Contributor

@rueian rueian May 11, 2025

Choose a reason for hiding this comment

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

Because we can have examples to show why avoiding trailing slash redirection matters there. The current statement "to handle requests with and without trailing slashes" alone doesn’t really show why avoiding the direction matters (it redirects non-GET requests to GET requests).

I don’t worry about people not reading the test. People who have doubts about the reason why we need two routes here will eventually find the test. However, if we really need a comment here, could we just say "to avoid the trailing slash redirection" instead of "to handle requests with and without trailing slashes" to avoid misunderstanding.

troychiu added 2 commits May 10, 2025 23:44
Signed-off-by: Troy Chiu <y.troychiu@gmail.com>
Signed-off-by: Troy Chiu <y.troychiu@gmail.com>
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.

[Feature][apiserversdk] check whether the service for proxying belongs to KubeRay first
3 participants