fix crash when monit is disabled

Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
huanggze
2019-10-15 16:06:50 +08:00
parent cfc1929a80
commit dbfb7f8fc9
2 changed files with 4 additions and 1 deletions

View File

@@ -40,6 +40,9 @@ func GetNamespacesWithMetrics(namespaces []*v1.Namespace) []*v1.Namespace {
}
rawMetrics := GetNamespaceMetrics(params)
if rawMetrics == nil {
return namespaces
}
for _, result := range rawMetrics.Results {
for _, data := range result.Data.Result {

View File

@@ -68,7 +68,7 @@ func (rawMetrics *Response) SortBy(sortMetricName string, sortType string) (*Res
}
}()
if sortMetricName == "" {
if sortMetricName == "" || rawMetrics == nil {
return rawMetrics, -1
}