mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2025-01-03 15:50:10 +00:00
Fix response on no metrics found (#67)
Fixes the response from `GetMetricsBySelector` in case no metrics are found. This issue caused a panic in kube-controller-manager: https://github.com/kubernetes/kubernetes/pull/80392 Fix #40 Signed-off-by: Mikkel Oscar Lyderik Larsen <mikkel.larsen@zalando.de>
This commit is contained in:
Mikkel Oscar Lyderik Larsen
committed by
Sandor Szücs
parent
9950851cad
commit
461869c69b
@ -155,12 +155,12 @@ func (s *MetricStore) GetMetricsBySelector(namespace string, selector labels.Sel
|
||||
|
||||
metrics, ok := s.customMetricsStore[info.Metric]
|
||||
if !ok {
|
||||
return nil
|
||||
return &custom_metrics.MetricValueList{}
|
||||
}
|
||||
|
||||
group, ok := metrics[info.GroupResource]
|
||||
if !ok {
|
||||
return nil
|
||||
return &custom_metrics.MetricValueList{}
|
||||
}
|
||||
|
||||
if !info.Namespaced {
|
||||
|
@ -568,7 +568,7 @@ func TestCustomMetricsStorageErrors(t *testing.T) {
|
||||
require.Nil(t, metric)
|
||||
|
||||
metrics := metricsStore.GetMetricsBySelector(tc.byLabel.namespace, tc.byLabel.selector, tc.byLabel.info)
|
||||
require.Nil(t, metrics)
|
||||
require.Equal(t, &custom_metrics.MetricValueList{}, metrics)
|
||||
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user