Ignore duplicated stats for containers
@@ -196,10 +196,10 @@ func (this *summaryMetricsSource) decodePodStats(metrics map[string]*MetricSet,
// This check ensures that we are not replacing metrics of running container with metrics of terminated one if
// there are two exactly same containers reported by kubelet.
if _, exist := metrics[key]; exist {
- glog.V(8).Infof("Metrics reported from two containers with the same key: %v. Create time of "+
+ glog.V(2).Infof("Metrics reported from two containers with the same key: %v. Create time of "+
"containers are %v and %v. Metrics from the older container are going to be dropped.", key,
container.StartTime.Time, metrics[key].CreateTime)
- if containerIsTerminated(&container, metrics[key].CreateTime) {
+ if container.StartTime.Time.Before(metrics[key].CreateTime) {
continue
}
}
@@ -207,16 +207,6 @@ func (this *summaryMetricsSource) decodePodStats(metrics map[string]*MetricSet,
}
}
-func containerIsTerminated(container *stats.ContainerStats, otherStartTime time.Time) bool {
- if container.StartTime.Time.Before(otherStartTime) {
- if *container.CPU.UsageNanoCores == 0 && *container.Memory.RSSBytes == 0 {
- return true
- }
- glog.Warningf("Two identical containers are reported and the older one is not terminated: %v", container)
- }
- return false
-}
-
func (this *summaryMetricsSource) decodeContainerStats(podLabels map[string]string, container *stats.ContainerStats, isSystemContainer bool) *MetricSet {
glog.V(9).Infof("Decoding container stats stats for container %s...", container.Name)
containerMetrics := &MetricSet{
