diff --git a/pkg/kubelet/api/v1alpha1/stats/types.go b/pkg/kubelet/api/v1alpha1/stats/types.go index 3b32307c1c6..dfd133f844f 100644 --- a/pkg/kubelet/api/v1alpha1/stats/types.go +++ b/pkg/kubelet/api/v1alpha1/stats/types.go @@ -191,6 +191,8 @@ type VolumeStats struct { // FsStats contains data about filesystem usage. type FsStats struct { + // The time at which these stats were updated. + Time unversioned.Time `json:"time"` // AvailableBytes represents the storage space available (bytes) for the filesystem. // +optional AvailableBytes *uint64 `json:"availableBytes,omitempty"` diff --git a/pkg/kubelet/eviction/helpers.go b/pkg/kubelet/eviction/helpers.go index 86059a23da2..71552c8dbb9 100644 --- a/pkg/kubelet/eviction/helpers.go +++ b/pkg/kubelet/eviction/helpers.go @@ -634,14 +634,14 @@ func makeSignalObservations(summaryProvider stats.SummaryProvider) (signalObserv result[evictionapi.SignalNodeFsAvailable] = signalObservation{ available: resource.NewQuantity(int64(*nodeFs.AvailableBytes), resource.BinarySI), capacity: resource.NewQuantity(int64(*nodeFs.CapacityBytes), resource.BinarySI), - // TODO: add timestamp to stat (see memory stat) + time: nodeFs.Time, } } if nodeFs.InodesFree != nil && nodeFs.Inodes != nil { result[evictionapi.SignalNodeFsInodesFree] = signalObservation{ available: resource.NewQuantity(int64(*nodeFs.InodesFree), resource.BinarySI), capacity: resource.NewQuantity(int64(*nodeFs.Inodes), resource.BinarySI), - // TODO: add timestamp to stat (see memory stat) + time: nodeFs.Time, } } } @@ -651,13 +651,13 @@ func makeSignalObservations(summaryProvider stats.SummaryProvider) (signalObserv result[evictionapi.SignalImageFsAvailable] = signalObservation{ available: resource.NewQuantity(int64(*imageFs.AvailableBytes), resource.BinarySI), capacity: resource.NewQuantity(int64(*imageFs.CapacityBytes), resource.BinarySI), - // TODO: add timestamp to stat (see memory stat) + time: imageFs.Time, } if imageFs.InodesFree != nil && imageFs.Inodes != nil { result[evictionapi.SignalImageFsInodesFree] = signalObservation{ available: resource.NewQuantity(int64(*imageFs.InodesFree), resource.BinarySI), capacity: resource.NewQuantity(int64(*imageFs.Inodes), resource.BinarySI), - // TODO: add timestamp to stat (see memory stat) + time: imageFs.Time, } } } diff --git a/pkg/kubelet/server/stats/summary.go b/pkg/kubelet/server/stats/summary.go index fe0285acdec..3b502404a73 100644 --- a/pkg/kubelet/server/stats/summary.go +++ b/pkg/kubelet/server/stats/summary.go @@ -128,12 +128,14 @@ func (sb *summaryBuilder) build() (*stats.Summary, error) { } rootStats := sb.containerInfoV2ToStats("", &rootInfo) + cStats, _ := sb.latestContainerStats(&rootInfo) nodeStats := stats.NodeStats{ NodeName: sb.node.Name, CPU: rootStats.CPU, Memory: rootStats.Memory, Network: sb.containerInfoV2ToNetworkStats("node:"+sb.node.Name, &rootInfo), Fs: &stats.FsStats{ + Time: unversioned.NewTime(cStats.Timestamp), AvailableBytes: &sb.rootFsInfo.Available, CapacityBytes: &sb.rootFsInfo.Capacity, UsedBytes: &sb.rootFsInfo.Usage, @@ -144,6 +146,7 @@ func (sb *summaryBuilder) build() (*stats.Summary, error) { StartTime: rootStats.StartTime, Runtime: &stats.RuntimeStats{ ImageFs: &stats.FsStats{ + Time: unversioned.NewTime(cStats.Timestamp), AvailableBytes: &sb.imageFsInfo.Available, CapacityBytes: &sb.imageFsInfo.Capacity, UsedBytes: &sb.imageStats.TotalStorageBytes, @@ -181,8 +184,14 @@ func (sb *summaryBuilder) containerInfoV2FsStats( info *cadvisorapiv2.ContainerInfo, cs *stats.ContainerStats) { + lcs, found := sb.latestContainerStats(info) + if !found { + return + } + // The container logs live on the node rootfs device cs.Logs = &stats.FsStats{ + Time: unversioned.NewTime(lcs.Timestamp), AvailableBytes: &sb.rootFsInfo.Available, CapacityBytes: &sb.rootFsInfo.Capacity, InodesFree: sb.rootFsInfo.InodesFree, @@ -196,15 +205,12 @@ func (sb *summaryBuilder) containerInfoV2FsStats( // The container rootFs lives on the imageFs devices (which may not be the node root fs) cs.Rootfs = &stats.FsStats{ + Time: unversioned.NewTime(lcs.Timestamp), AvailableBytes: &sb.imageFsInfo.Available, CapacityBytes: &sb.imageFsInfo.Capacity, InodesFree: sb.imageFsInfo.InodesFree, Inodes: sb.imageFsInfo.Inodes, } - lcs, found := sb.latestContainerStats(info) - if !found { - return - } cfs := lcs.Filesystem if cfs != nil {