fix crash when monit is disabled
Signed-off-by: huanggze <loganhuang@yunify.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -68,7 +68,7 @@ func (rawMetrics *Response) SortBy(sortMetricName string, sortType string) (*Res
|
||||
}
|
||||
}()
|
||||
|
||||
if sortMetricName == "" {
|
||||
if sortMetricName == "" || rawMetrics == nil {
|
||||
return rawMetrics, -1
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user