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

Add http resp code check for kuberay #435

Merged
merged 1 commit into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions ray-operator/controllers/ray/utils/dashboard_httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions ray-operator/controllers/ray/utils/httpproxy_httpclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package utils

import (
"fmt"
"io/ioutil"
"net/http"
"time"
)
Expand Down Expand Up @@ -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
}