Merge pull request #79057 from rphillips/fixes/e2e_kubelet_stats_fix

kubelet_stats: fix potential e2e crash dereferencing ContainerStats.CPU
This commit is contained in:
Kubernetes Prow Robot 2019-06-25 03:48:39 -07:00 committed by GitHub
commit 1db31d474f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -599,6 +599,9 @@ func (r *resourceCollector) collectStats(oldStatsMap map[string]*kubeletstatsv1a
} }
if oldStats, ok := oldStatsMap[name]; ok { if oldStats, ok := oldStatsMap[name]; ok {
if oldStats.CPU == nil || cStats.CPU == nil || oldStats.Memory == nil || cStats.Memory == nil {
continue
}
if oldStats.CPU.Time.Equal(&cStats.CPU.Time) { if oldStats.CPU.Time.Equal(&cStats.CPU.Time) {
// No change -> skip this stat. // No change -> skip this stat.
continue continue