From b2a0e2eb2eff8ca9ebfebcd68383b10449348944 Mon Sep 17 00:00:00 2001 From: liubog2008 Date: Wed, 10 Aug 2016 15:49:23 +0800 Subject: [PATCH] fix pod aggregation err and fix some bugs about autoscaling --- metrics/core/caicloud/caicloud_keys.go | 8 -------- metrics/processors/caicloud/pod_aggregator.go | 4 ++-- metrics/processors/caicloud/processors.go | 7 +++++++ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/metrics/core/caicloud/caicloud_keys.go b/metrics/core/caicloud/caicloud_keys.go index 4e05e41271..ad4ea6118d 100644 --- a/metrics/core/caicloud/caicloud_keys.go +++ b/metrics/core/caicloud/caicloud_keys.go @@ -9,14 +9,6 @@ import ( // anytime. It it only guaranteed that it is unique for the unique combination of // passed parameters. -func PodContainerKey(namespaceName, appName, podName, containerName string) string { - return fmt.Sprintf("namespace:%s/app:%s/pod:%s/container:%s", namespaceName, appName, podName, containerName) -} - -func PodKey(namespaceName, appName, podName string) string { - return fmt.Sprintf("namespace:%s/app:%s/pod:%s", namespaceName, appName, podName) -} - func AppKey(namespaceName, appName string) string { return fmt.Sprintf("namespace:%s/app:%s", namespaceName, appName) } diff --git a/metrics/processors/caicloud/pod_aggregator.go b/metrics/processors/caicloud/pod_aggregator.go index 266b7d31d1..b1fcb9279b 100644 --- a/metrics/processors/caicloud/pod_aggregator.go +++ b/metrics/processors/caicloud/pod_aggregator.go @@ -21,10 +21,10 @@ func (p *PodAggregator) Process(batch *core.DataBatch) (*core.DataBatch, error) if metricSetType, found := metricSet.Labels[core.LabelMetricSetType.Key]; found && metricSetType == core.MetricSetTypePodContainer { podName, found := metricSet.Labels[core.LabelPodName.Key] - appName, found2 := metricSet.Labels[caicloudcore.LabelAppName.Key] + _, found2 := metricSet.Labels[caicloudcore.LabelAppName.Key] namespaceName, found3 := metricSet.Labels[core.LabelNamespaceName.Key] if found && found2 && found3 { - podKey := caicloudcore.PodKey(namespaceName, appName, podName) + podKey := core.PodKey(namespaceName, podName) pod, found := pods[podKey] if !found { if podFromBatch, found := batch.MetricSets[podKey]; found { diff --git a/metrics/processors/caicloud/processors.go b/metrics/processors/caicloud/processors.go index 3a0625723f..9db7b8e76a 100644 --- a/metrics/processors/caicloud/processors.go +++ b/metrics/processors/caicloud/processors.go @@ -93,5 +93,12 @@ func GetProcessors(url *url.URL) ([]core.DataProcessor, error) { }, ) + nodeAutoscalingEnricher, err := kubeprocessors.NewNodeAutoscalingEnricher(url) + if err != nil { + glog.Fatalf("Failed to create NodeAutoscalingEnricher: %v", err) + return nil, err + } + dataProcessors = append(dataProcessors, nodeAutoscalingEnricher) + return dataProcessors, nil }