Merge pull request #1005 from huanggze/monit

fix crash when monitoring component is disabled
This commit is contained in:
KubeSphere CI Bot
2019-10-16 14:30:45 +08:00
committed by GitHub
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) rawMetrics := GetNamespaceMetrics(params)
if rawMetrics == nil {
return namespaces
}
for _, result := range rawMetrics.Results { for _, result := range rawMetrics.Results {
for _, data := range result.Data.Result { 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 return rawMetrics, -1
} }