Skip to content

Commit

Permalink
Merge pull request #3144 from yangjunmyfm192085/fixcrioerror
Browse files Browse the repository at this point in the history
fix error log of crio client
  • Loading branch information
bobbypage authored Aug 2, 2022
2 parents db88ad0 + 01ac73b commit 86b11c6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion container/crio/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/http"
"sync"
Expand Down Expand Up @@ -141,7 +142,11 @@ func (c *crioClientImpl) ContainerInfo(id string) (*ContainerInfo, error) {
// golang's http.Do doesn't return an error if non 200 response code is returned
// handle this case here, rather than failing to decode the body
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("Error finding container %s: Status %d returned error %s", id, resp.StatusCode, resp.Body)
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("Error finding container %s: Status %d", id, resp.StatusCode)
}
return nil, fmt.Errorf("Error finding container %s: Status %d returned error %s", id, resp.StatusCode, string(respBody))
}

if err := json.NewDecoder(resp.Body).Decode(&cInfo); err != nil {
Expand Down

0 comments on commit 86b11c6

Please sign in to comment.