Merge pull request #30993 from mksalawa/bump_heapster_version
Automatic merge from submit-queue Bump heapster version Bump heapster version to v1.2.0-beta.1. Migrate metrics tests and HPA to use List objects introduced in the new version.
This commit is contained in:
@@ -284,9 +284,9 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
|
||||
var heapsterRawMemResponse []byte
|
||||
|
||||
if tc.useMetricsApi {
|
||||
metrics := []*metrics_api.PodMetrics{}
|
||||
metrics := metrics_api.PodMetricsList{}
|
||||
for i, cpu := range tc.reportedLevels {
|
||||
podMetric := &metrics_api.PodMetrics{
|
||||
podMetric := metrics_api.PodMetrics{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
|
||||
Namespace: namespace,
|
||||
@@ -306,7 +306,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
|
||||
},
|
||||
},
|
||||
}
|
||||
metrics = append(metrics, podMetric)
|
||||
metrics.Items = append(metrics.Items, podMetric)
|
||||
}
|
||||
heapsterRawMemResponse, _ = json.Marshal(&metrics)
|
||||
} else {
|
||||
|
@@ -166,15 +166,15 @@ func (h *HeapsterMetricsClient) getCpuUtilizationForPods(namespace string, selec
|
||||
|
||||
glog.V(4).Infof("Heapster metrics result: %s", string(resultRaw))
|
||||
|
||||
metrics := make([]metrics_api.PodMetrics, 0)
|
||||
metrics := metrics_api.PodMetricsList{}
|
||||
err = json.Unmarshal(resultRaw, &metrics)
|
||||
if err != nil {
|
||||
return 0, time.Time{}, fmt.Errorf("failed to unmarshall heapster response: %v", err)
|
||||
}
|
||||
|
||||
if len(metrics) != len(podNames) {
|
||||
if len(metrics.Items) != len(podNames) {
|
||||
present := sets.NewString()
|
||||
for _, m := range metrics {
|
||||
for _, m := range metrics.Items {
|
||||
present.Insert(m.Name)
|
||||
}
|
||||
missing := make([]string, 0)
|
||||
@@ -187,11 +187,11 @@ func (h *HeapsterMetricsClient) getCpuUtilizationForPods(namespace string, selec
|
||||
if len(missing) > 0 {
|
||||
hint = fmt.Sprintf(" (sample missing pod: %s/%s)", namespace, missing[0])
|
||||
}
|
||||
return 0, time.Time{}, fmt.Errorf("metrics obtained for %d/%d of pods%s", len(metrics), len(podNames), hint)
|
||||
return 0, time.Time{}, fmt.Errorf("metrics obtained for %d/%d of pods%s", len(metrics.Items), len(podNames), hint)
|
||||
}
|
||||
|
||||
sum := int64(0)
|
||||
for _, m := range metrics {
|
||||
for _, m := range metrics.Items {
|
||||
if _, found := podNames[m.Name]; found {
|
||||
for _, c := range m.Containers {
|
||||
cpu, found := c.Usage[v1.ResourceCPU]
|
||||
@@ -205,7 +205,7 @@ func (h *HeapsterMetricsClient) getCpuUtilizationForPods(namespace string, selec
|
||||
}
|
||||
}
|
||||
|
||||
return sum / int64(len(metrics)), metrics[0].Timestamp.Time, nil
|
||||
return sum / int64(len(metrics.Items)), metrics.Items[0].Timestamp.Time, nil
|
||||
}
|
||||
|
||||
// GetCustomMetric returns the average value of the given custom metric from the
|
||||
|
@@ -102,9 +102,9 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
|
||||
|
||||
if tc.useMetricsApi {
|
||||
fakeClient.AddProxyReactor("services", func(action core.Action) (handled bool, ret restclient.ResponseWrapper, err error) {
|
||||
metrics := []*metrics_api.PodMetrics{}
|
||||
metrics := metrics_api.PodMetricsList{}
|
||||
for i, containers := range tc.reportedPodMetrics {
|
||||
metric := &metrics_api.PodMetrics{
|
||||
metric := metrics_api.PodMetrics{
|
||||
ObjectMeta: v1.ObjectMeta{
|
||||
Name: fmt.Sprintf("%s-%d", podNamePrefix, i),
|
||||
Namespace: namespace,
|
||||
@@ -126,7 +126,7 @@ func (tc *testCase) prepareTestClient(t *testing.T) *fake.Clientset {
|
||||
}
|
||||
metric.Containers = append(metric.Containers, cm)
|
||||
}
|
||||
metrics = append(metrics, metric)
|
||||
metrics.Items = append(metrics.Items, metric)
|
||||
}
|
||||
heapsterRawMemResponse, _ := json.Marshal(&metrics)
|
||||
return true, newFakeResponseWrapper(heapsterRawMemResponse), nil
|
||||
|
Reference in New Issue
Block a user