Work around heapster panic.

This commit is contained in:
Lantao Liu 2017-11-07 06:27:30 +00:00
parent 9feabbdaeb
commit b037be6c19
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)
}