From 10fedfe43294d1e151b768bc982b94fb280516da Mon Sep 17 00:00:00 2001 From: huanggze Date: Tue, 3 Nov 2020 11:58:16 +0800 Subject: [PATCH] minor cleanup Signed-off-by: huanggze --- pkg/kapis/monitoring/group.go | 18 --------- pkg/models/monitoring/monitoring.go | 2 +- pkg/models/monitoring/namespaces.go | 63 ----------------------------- 3 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 pkg/kapis/monitoring/group.go delete mode 100644 pkg/models/monitoring/namespaces.go diff --git a/pkg/kapis/monitoring/group.go b/pkg/kapis/monitoring/group.go deleted file mode 100644 index ce6b7cc73..000000000 --- a/pkg/kapis/monitoring/group.go +++ /dev/null @@ -1,18 +0,0 @@ -/* -Copyright 2019 The KubeSphere authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// Package monitoring contains monitoring API versions -package monitoring diff --git a/pkg/models/monitoring/monitoring.go b/pkg/models/monitoring/monitoring.go index 7fecaf943..b945a6c15 100644 --- a/pkg/models/monitoring/monitoring.go +++ b/pkg/models/monitoring/monitoring.go @@ -40,7 +40,7 @@ type MonitoringOperator interface { GetMetadata(namespace string) Metadata GetMetricLabelSet(metric, namespace string, start, end time.Time) MetricLabelSet - // TODO: refactor + // TODO: expose KubeSphere self metrics in Prometheus format GetKubeSphereStats() Metrics GetWorkspaceStats(workspace string) Metrics } diff --git a/pkg/models/monitoring/namespaces.go b/pkg/models/monitoring/namespaces.go deleted file mode 100644 index b05d3414b..000000000 --- a/pkg/models/monitoring/namespaces.go +++ /dev/null @@ -1,63 +0,0 @@ -/* -Copyright 2019 The KubeSphere Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package monitoring - -import "k8s.io/api/core/v1" - -// TODO(wansir): Can we decouple this part from monitoring module, since the project structure has been changed -func GetNamespacesWithMetrics(namespaces []*v1.Namespace) []*v1.Namespace { - // var nsNameList []string - // for i := range namespaces { - // nsNameList = append(nsNameList, namespaces[i].Name) - // } - // nsFilter := "^(" + strings.Join(nsNameList, "|") + ")$" - // - // now := time.Now() - // opt := &monitoring.QueryOptions{ - // Level: monitoring.MetricsLevelNamespace, - // ResourcesFilter: nsFilter, - // Start: now, - // End: now, - // MetricsFilter: "namespace_cpu_usage|namespace_memory_usage_wo_cache|namespace_pod_count", - // } - // - // gm, err := monitoring.Get(opt) - // if err != nil { - // klog.Error(err) - // return namespaces - // } - // - // for _, m := range gm.Results { - // for _, v := range m.Data.MetricsValues { - // ns, exist := v.Metadata["namespace"] - // if !exist { - // continue - // } - // - // for _, item := range namespaces { - // if item.Name == ns { - // if item.Annotations == nil { - // item.Annotations = make(map[string]string, 0) - // } - // item.Annotations[m.MetricsName] = strconv.FormatFloat(v.Sample[1], 'f', -1, 64) - // } - // } - // } - // } - // - return namespaces -}