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

[Bug] Service (Serve) changing port from 8000 to 9000 doesn't work #1081

Merged
merged 7 commits into from
May 15, 2023

Conversation

kevin85421
Copy link
Member

@kevin85421 kevin85421 commented May 12, 2023

Why are these changes needed?

Without this PR, users can only serve requests via port 8000.

To serve requests via another port (e.g. 9000), user needs to specify spec.serveConfig.port and the head Pod's serve port to 9000. See RESTful API and single-application config schema for more details.

The HTTPProxy is used to check the health condition (code) of Serve deployments. If the Serve deployments are healthy, the HTTPProxy will add the label "ray.io/serve=true" to the Pod. Note that the selector of Kubernetes Serve service also includes "ray.io/serve=true". That is, the traffic will be redirected to the Serve deployments after HTTPProxy believes that the deployments are healthy.

Others

  • Convert HealthCheckPath (public) into healthCheckPath (private) because the variable is only used by the function CheckHealth().

  • The single-application config schema indicates that port is an int in Python. However, the size of int type in Python depends on the underlying platform and implementation. Hence, I am unsure about which integer type to use in Golang (e.g. int, int32, int64). I conducted the following experiment and found that there is no difference between int, int32, and int64 after serializing. Hence, I declare Port as an int in this PR.

    package main
    
    import (
        "bytes"
        "encoding/json"
        "fmt"
    )
    
    func main() {
        // Define sample integer values
        valueInt := 42
        valueInt32 := int32(42)
        valueInt64 := int64(42)
    
        // Serialize int to JSON
        jsonInt, _ := json.Marshal(valueInt)
        fmt.Println("Serialized int:", jsonInt, string(jsonInt))
    
        // Serialize int32 to JSON
        jsonInt32, _ := json.Marshal(valueInt32)
        fmt.Println("Serialized int32:", jsonInt32, string(jsonInt32))
    
        // Serialize int64 to JSON
        jsonInt64, _ := json.Marshal(valueInt64)
        fmt.Println("Serialized int64:", jsonInt64, string(jsonInt64))
    
        // Compare the byte slices
        equal := bytes.Equal(jsonInt, jsonInt32) && bytes.Equal(jsonInt32, jsonInt64)
        fmt.Println("Are the byte slices equal?", equal)
    }
    
    # STDOUT
    Serialized int: [52 50] 42
    Serialized int32: [52 50] 42
    Serialized int64: [52 50] 42
    Are the byte slices equal? true

Related issue number

Closes #570

Checks

  • I've made sure the tests are passing.
  • Testing Strategy
    • Unit tests
    • Manual tests
    • This PR is not tested :(
# Step 0: Build the KubeRay operator
# Step 1: Install the KubeRay operator. Note that we need to use the local Helm chart because this PR includes CRD 
changes.
# (path: helm-chart/kuberay-operator)
helm install kuberay-operator . --set image.repository=controller,image.tag=latest

# Step 2: Create a RayService (path: ray-operator/config/samples)
kubectl apply -f ray-service.different-port.yaml

# Step 3: Wait until the service `rayservice-sample-serve-svc` is created and forward the port 9000
kubectl port-forward svc/rayservice-sample-serve-svc 9000

# Step 4: Test it
curl -X POST -H 'Content-Type: application/json' localhost:9000 -d '["PEAR", 12]'
Screen Shot 2023-05-12 at 11 18 21 AM

@kevin85421 kevin85421 changed the title WIP [Bug] Service (Serve) changing port from 8000 to 9000 doesn't work May 12, 2023
@kevin85421 kevin85421 marked this pull request as ready for review May 12, 2023 18:18
@kevin85421
Copy link
Member Author

cc @Yicheng-Lu-llll

@Yicheng-Lu-llll
Copy link
Contributor

LGTM!

@kevin85421 kevin85421 merged commit 0cabd14 into ray-project:master May 15, 2023
19 checks passed
lowang-bh pushed a commit to lowang-bh/kuberay that referenced this pull request Sep 24, 2023
…ay-project#1081)

Service (Serve) changing port from 8000 to 9000 doesn't work
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.

[Bug] Service (Serve) changing port from 8000 to 9000 doesn't work
3 participants