Skip to content

Commit 86b11c6

Browse files
authored
Merge pull request #3144 from yangjunmyfm192085/fixcrioerror
fix error log of crio client
2 parents db88ad0 + 01ac73b commit 86b11c6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

container/crio/client.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"context"
1919
"encoding/json"
2020
"fmt"
21+
"io/ioutil"
2122
"net"
2223
"net/http"
2324
"sync"
@@ -141,7 +142,11 @@ func (c *crioClientImpl) ContainerInfo(id string) (*ContainerInfo, error) {
141142
// golang's http.Do doesn't return an error if non 200 response code is returned
142143
// handle this case here, rather than failing to decode the body
143144
if resp.StatusCode != http.StatusOK {
144-
return nil, fmt.Errorf("Error finding container %s: Status %d returned error %s", id, resp.StatusCode, resp.Body)
145+
respBody, err := ioutil.ReadAll(resp.Body)
146+
if err != nil {
147+
return nil, fmt.Errorf("Error finding container %s: Status %d", id, resp.StatusCode)
148+
}
149+
return nil, fmt.Errorf("Error finding container %s: Status %d returned error %s", id, resp.StatusCode, string(respBody))
145150
}
146151

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

0 commit comments

Comments
 (0)