mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Make sure the StatusCode is taken into account in DoRaw()
Currently if there is an error (not found) the error printed out is to do with the inablity to convert an empty body into the expected json. This patch will fill in the err correctly. example of before (with NotFound error): $ kubectl top node failed to unmarshall heapster response: json: cannot unmarshal object into Go value of type []v1alpha1.NodeMetrics Now: $ kubectl top node the server could not find the requested resource (get services http:heapster:)
This commit is contained in:
parent
9c5e11e991
commit
c955de2ba8
@ -881,6 +881,9 @@ func (r *Request) DoRaw() ([]byte, error) {
|
||||
var result Result
|
||||
err := r.request(func(req *http.Request, resp *http.Response) {
|
||||
result.body, result.err = ioutil.ReadAll(resp.Body)
|
||||
if resp.StatusCode < http.StatusOK || resp.StatusCode > http.StatusPartialContent {
|
||||
result.err = r.transformUnstructuredResponseError(resp, req, result.body)
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user