diff --git a/pkg/metaserver/agent/metric/provisioner/kubelet/client/client.go b/pkg/metaserver/agent/metric/provisioner/kubelet/client/client.go index 389c51c3b..57f6bb2e6 100644 --- a/pkg/metaserver/agent/metric/provisioner/kubelet/client/client.go +++ b/pkg/metaserver/agent/metric/provisioner/kubelet/client/client.go @@ -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) } diff --git a/pkg/util/process/http.go b/pkg/util/process/http.go index 0755502c8..7ada81df2 100644 --- a/pkg/util/process/http.go +++ b/pkg/util/process/http.go @@ -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