Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
Merge pull request #1870 from kawych/release-1.5
Browse files Browse the repository at this point in the history
Cherry-pick PR #1839 to Release 1.5
  • Loading branch information
kawych authored Nov 10, 2017
2 parents 859ccd7 + edc0b1d commit a825e6c
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions metrics/sources/summary/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,27 +197,17 @@ 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
}
}
metrics[key] = this.decodeContainerStats(podMetrics.Labels, &container, false)
}
}

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{
Expand Down

0 comments on commit a825e6c

Please sign in to comment.