diff --git a/pkg/cron/monitoring.go b/pkg/cron/monitoring.go index 8d923d0..63e87c0 100644 --- a/pkg/cron/monitoring.go +++ b/pkg/cron/monitoring.go @@ -42,19 +42,16 @@ func syncClusterAlertRecords() { for k, v := range apiserver.ApiServer.MonitoringClientMap { wg.Add(1) go func(key string, client monitoring.Interface) { - defer wg.Done() - rules, err := client.GetExceptionRules() if err != nil { + logx.Error(err) return } - res[k] = rules - + res[key] = rules }(k, v) } wg.Wait() - // push data req := SyncClusterAlertReq{ AlertRecordsMap: res, @@ -82,17 +79,17 @@ func syncClusterLoadRecords() { for clusterName, client := range apiserver.ApiServer.MonitoringClientMap { wg.Add(1) - go func(clusterName string, client monitoring.Interface) { + go func(name string, client monitoring.Interface) { defer wg.Done() // prometheus data - clusterResourceLoad, err := fetchClusterResourceLoad(clusterName, client) + clusterResourceLoad, err := fetchClusterResourceLoad(name, client) if err != nil { logx.Error(err) return } // pod utilisation - if _, ok := apiserver.ApiServer.ClientSetMap[clusterName]; ok { - podUtilisation, count, total, err := v1.PodUtilisation(apiserver.ApiServer.ClientSetMap[clusterName]) + if _, ok := apiserver.ApiServer.ClientSetMap[name]; ok { + podUtilisation, count, total, err := v1.PodUtilisation(apiserver.ApiServer.ClientSetMap[name]) if err != nil { logx.Error(err) }