diff --git a/ray-operator/controllers/ray/utils/dashboard_httpclient.go b/ray-operator/controllers/ray/utils/dashboard_httpclient.go index df3c19248f..0414d41d6f 100644 --- a/ray-operator/controllers/ray/utils/dashboard_httpclient.go +++ b/ray-operator/controllers/ray/utils/dashboard_httpclient.go @@ -178,6 +178,9 @@ func (r *RayDashboardClient) GetDeployments() (string, error) { defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) + if resp.StatusCode < 200 || resp.StatusCode > 299 { + return "", fmt.Errorf("GetDeployments fail: %s %s", resp.Status, string(body)) + } return string(body), nil } @@ -210,6 +213,11 @@ func (r *RayDashboardClient) UpdateDeployments(specs rayv1alpha1.ServeDeployment } defer resp.Body.Close() + body, _ := ioutil.ReadAll(resp.Body) + if resp.StatusCode < 200 || resp.StatusCode > 299 { + return fmt.Errorf("UpdateDeployments fail: %s %s", resp.Status, string(body)) + } + return nil } @@ -228,6 +236,10 @@ func (r *RayDashboardClient) GetDeploymentsStatus() (*ServeDeploymentStatuses, e body, _ := ioutil.ReadAll(resp.Body) + if resp.StatusCode < 200 || resp.StatusCode > 299 { + return nil, fmt.Errorf("GetDeploymentsStatus fail: %s %s", resp.Status, string(body)) + } + var serveStatuses ServeDeploymentStatuses if err = json.Unmarshal(body, &serveStatuses); err != nil { return nil, err diff --git a/ray-operator/controllers/ray/utils/httpproxy_httpclient.go b/ray-operator/controllers/ray/utils/httpproxy_httpclient.go index 4615de3642..471f5a5565 100644 --- a/ray-operator/controllers/ray/utils/httpproxy_httpclient.go +++ b/ray-operator/controllers/ray/utils/httpproxy_httpclient.go @@ -2,6 +2,7 @@ package utils import ( "fmt" + "io/ioutil" "net/http" "time" ) @@ -51,5 +52,10 @@ func (r *RayHttpProxyClient) CheckHealth() error { } 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 }