Skip to content

Commit

Permalink
Set CPU metrics for init containers under containerd
Browse files Browse the repository at this point in the history
metrics-server doesn't return metrics for pods with init containers
under containerd because they have incomplete CPU metrics returned by
the kubelet /stats/summary API.

This problem has been fixed in 1.14 (#74336), but the cherry-picks
dropped the `usageNanoCores` metric.

This change adds the missing `usageNanoCores` metric for init containers.

Fixes #76292
  • Loading branch information
jmcmeek committed Apr 12, 2019
1 parent e7b7983 commit b468466
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/kubelet/stats/cri_stats_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ func (p *criStatsProvider) makeContainerStats(
} else {
result.CPU.Time = metav1.NewTime(time.Unix(0, time.Now().UnixNano()))
result.CPU.UsageCoreNanoSeconds = Uint64Ptr(0)
result.CPU.UsageNanoCores = Uint64Ptr(0)
}
if stats.Memory != nil {
result.Memory.Time = metav1.NewTime(time.Unix(0, stats.Memory.Timestamp))
Expand Down Expand Up @@ -500,6 +501,7 @@ func (p *criStatsProvider) makeContainerCPUAndMemoryStats(
} else {
result.CPU.Time = metav1.NewTime(time.Unix(0, time.Now().UnixNano()))
result.CPU.UsageCoreNanoSeconds = Uint64Ptr(0)
result.CPU.UsageNanoCores = Uint64Ptr(0)
}
if stats.Memory != nil {
result.Memory.Time = metav1.NewTime(time.Unix(0, stats.Memory.Timestamp))
Expand Down

0 comments on commit b468466

Please sign in to comment.