Merge pull request #55213 from Random-Liu/work-around-heapster-panic

Automatic merge from submit-queue (batch tested with PRs 53592, 52562, 55175, 55213). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Work around heapster panic

For https://github.com/kubernetes/kubernetes/issues/54962.

Work around https://github.com/kubernetes/kubernetes/issues/54962 for now. It is blocking the cri-containerd cluster e2e test, and it seems that heapster update takes time.

@yujuhong @yguo0905 

```release-note
none

```
This commit is contained in:
Kubernetes Submit Queue 2017-11-07 11:21:25 -08:00 committed by GitHub
commit 454074d230
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -22,6 +22,7 @@ go_library(
"//pkg/kubelet/server/stats:go_default_library",
"//pkg/kubelet/types:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
"//vendor/github.com/golang/protobuf/proto:go_default_library",
"//vendor/github.com/google/cadvisor/fs:go_default_library",
"//vendor/github.com/google/cadvisor/info/v1:go_default_library",
"//vendor/github.com/google/cadvisor/info/v2:go_default_library",

View File

@ -21,6 +21,7 @@ import (
"time"
"github.com/golang/glog"
"github.com/golang/protobuf/proto"
cadvisorfs "github.com/google/cadvisor/fs"
cadvisorapiv2 "github.com/google/cadvisor/info/v2"
@ -221,9 +222,15 @@ func (p *criStatsProvider) makeContainerStats(
Name: stats.Attributes.Metadata.Name,
// The StartTime in the summary API is the container creation time.
StartTime: metav1.NewTime(time.Unix(0, container.CreatedAt)),
CPU: &statsapi.CPUStats{},
Memory: &statsapi.MemoryStats{},
Rootfs: &statsapi.FsStats{},
// Work around heapster bug. https://github.com/kubernetes/kubernetes/issues/54962
// TODO(random-liu): Remove this after heapster is updated to newer than 1.5.0-beta.0.
CPU: &statsapi.CPUStats{
UsageNanoCores: proto.Uint64(0),
},
Memory: &statsapi.MemoryStats{
RSSBytes: proto.Uint64(0),
},
Rootfs: &statsapi.FsStats{},
Logs: &statsapi.FsStats{
Time: metav1.NewTime(rootFsInfo.Timestamp),
AvailableBytes: &rootFsInfo.Available,

View File

@ -235,13 +235,13 @@ func makeFakeImageFsUsage(fsUUID string) *runtimeapi.FilesystemUsage {
func checkCRICPUAndMemoryStats(assert *assert.Assertions, actual statsapi.ContainerStats, cs *runtimeapi.ContainerStats) {
assert.Equal(cs.Cpu.Timestamp, actual.CPU.Time.UnixNano())
assert.Equal(cs.Cpu.UsageCoreNanoSeconds.Value, *actual.CPU.UsageCoreNanoSeconds)
assert.Nil(actual.CPU.UsageNanoCores)
assert.Zero(*actual.CPU.UsageNanoCores)
assert.Equal(cs.Memory.Timestamp, actual.Memory.Time.UnixNano())
assert.Nil(actual.Memory.AvailableBytes)
assert.Nil(actual.Memory.UsageBytes)
assert.Equal(cs.Memory.WorkingSetBytes.Value, *actual.Memory.WorkingSetBytes)
assert.Nil(actual.Memory.RSSBytes)
assert.Zero(*actual.Memory.RSSBytes)
assert.Nil(actual.Memory.PageFaults)
assert.Nil(actual.Memory.MajorPageFaults)
}