Skip to content

Commit

Permalink
fix KubeletSummaryClient
Browse files Browse the repository at this point in the history
  • Loading branch information
luomingmeng authored and waynepeking348 committed Feb 28, 2024
1 parent 8b6d6ab commit b24c422
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (c *KubeletSummaryClient) Summary(ctx context.Context) (*statsapi.Summary,
return nil, fmt.Errorf("failed to get kubelet config for summary api, error: %v", err)
}
} else {
url := fmt.Sprintf(summaryApi, c.baseConf.KubeletReadOnlyPort, c.baseConf.KubeletPodsEndpoint)
url := fmt.Sprintf(summaryApi, c.baseConf.KubeletReadOnlyPort, c.baseConf.KubeletSummaryEndpoint)
if err := process.GetAndUnmarshal(url, summary); err != nil {
return nil, fmt.Errorf("failed to get summary, error: %v", err)
}
Expand Down
4 changes: 4 additions & 0 deletions pkg/util/process/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ func GetAndUnmarshal(url string, v interface{}) error {
return err
}

if resp.StatusCode != http.StatusOK {
return fmt.Errorf("invalid response status code %d, url: %s", resp.StatusCode, url)
}

err = json.Unmarshal(body, v)
if err != nil {
return err
Expand Down

0 comments on commit b24c422

Please sign in to comment.