Skip to content

Commit

Permalink
Merge pull request #2 from waynepeking348/dev/fix-kubelet-summary-client
Browse files Browse the repository at this point in the history
fix kubelet status summary
  • Loading branch information
waynepeking348 authored Feb 27, 2024
2 parents 4807bdf + ff10e87 commit d565124
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 d565124

Please sign in to comment.