Files
kuberay/ray-operator/controllers/ray/utils/httpproxy_httpclient.go
9c0b0366d2 Cherry pick master fixes to 0.3 release (#449)
* Fix nil pointer dereference (#429)

Signed-off-by: Kevin Su <[email protected]>

* Fix wrong ray start command (#431)

Signed-off-by: Kevin Su <[email protected]>

* Add ray state api doc link in ray service doc (#428)

* Add ray state api doc link in ray service doc

* Update doc

* update

* [doc] Fix config typos

Signed-off-by: Dmitri Gekhtman <[email protected]>

Fixes a couple of typos in recently introduced sample configs.

* Add http resp code check for kuberay (#435)

* Clean up example samples (#434)

This PR cleans up the "complete" and "autoscaler" sample yamls a bit.
Unnecessary pod spec fields are removed without sacrificing the completeness of the examples.
The idea is to make the configuration look less intimidating.

Signed-off-by: Dmitri Gekhtman <[email protected]>

* Add more env for RayService head or worker pods (#439)

* fix: worker node can't connect to head node service (#445)

Signed-off-by: Kevin Su <[email protected]>

* helm-chart/ray-cluster: allow head autoscaling (#443)

Also allow setting rayVersion

Signed-off-by: Christos Kotsis <[email protected]>

* Disable async serve handler in Ray Service cluster (#447)

* Add wget timeout to probes (#448)

* Enable tests against release-0.3 branch

Signed-off-by: Kevin Su <[email protected]>
Signed-off-by: Dmitri Gekhtman <[email protected]>
Signed-off-by: Christos Kotsis <[email protected]>
Co-authored-by: Kevin Su <[email protected]>
Co-authored-by: bruce <[email protected]>
Co-authored-by: Dmitri Gekhtman <[email protected]>
Co-authored-by: Christos Kotsis <[email protected]>
Co-authored-by: Yi Cheng <[email protected]>
Co-authored-by: Wilson Wang <[email protected]>
2022-08-10 10:53:17 -07:00

62 lines
1.2 KiB
Go

package utils
import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
var (
DefaultHttpProxyPort = 8000
HealthCheckPath = "/-/healthz"
)
type RayHttpProxyClientInterface interface {
InitClient()
CheckHealth() error
SetHostIp(hostIp string)
}
// GetRayHttpProxyClientFunc Used for unit tests.
var GetRayHttpProxyClientFunc = GetRayHttpProxyClient
func GetRayHttpProxyClient() RayHttpProxyClientInterface {
return &RayHttpProxyClient{}
}
type RayHttpProxyClient struct {
client http.Client
httpProxyURL string
}
func (r *RayHttpProxyClient) InitClient() {
r.client = http.Client{
Timeout: 20 * time.Millisecond,
}
}
func (r *RayHttpProxyClient) SetHostIp(hostIp string) {
r.httpProxyURL = fmt.Sprint("http://", hostIp, ":", DefaultHttpProxyPort)
}
func (r *RayHttpProxyClient) CheckHealth() error {
req, err := http.NewRequest("GET", r.httpProxyURL+HealthCheckPath, nil)
if err != nil {
return err
}
resp, err := r.client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
if resp.StatusCode < 200 || resp.StatusCode > 299 {
return fmt.Errorf("RayHttpProxyClient CheckHealth fail: %s %s", resp.Status, string(body))
}
return nil
}