mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
kubelet: eviction: add timestamp to FsStats
This commit is contained in:
parent
1d97472361
commit
c5faf1c156
@ -191,6 +191,8 @@ type VolumeStats struct {
|
|||||||
|
|
||||||
// FsStats contains data about filesystem usage.
|
// FsStats contains data about filesystem usage.
|
||||||
type FsStats struct {
|
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.
|
// AvailableBytes represents the storage space available (bytes) for the filesystem.
|
||||||
// +optional
|
// +optional
|
||||||
AvailableBytes *uint64 `json:"availableBytes,omitempty"`
|
AvailableBytes *uint64 `json:"availableBytes,omitempty"`
|
||||||
|
@ -634,14 +634,14 @@ func makeSignalObservations(summaryProvider stats.SummaryProvider) (signalObserv
|
|||||||
result[evictionapi.SignalNodeFsAvailable] = signalObservation{
|
result[evictionapi.SignalNodeFsAvailable] = signalObservation{
|
||||||
available: resource.NewQuantity(int64(*nodeFs.AvailableBytes), resource.BinarySI),
|
available: resource.NewQuantity(int64(*nodeFs.AvailableBytes), resource.BinarySI),
|
||||||
capacity: resource.NewQuantity(int64(*nodeFs.CapacityBytes), 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 {
|
if nodeFs.InodesFree != nil && nodeFs.Inodes != nil {
|
||||||
result[evictionapi.SignalNodeFsInodesFree] = signalObservation{
|
result[evictionapi.SignalNodeFsInodesFree] = signalObservation{
|
||||||
available: resource.NewQuantity(int64(*nodeFs.InodesFree), resource.BinarySI),
|
available: resource.NewQuantity(int64(*nodeFs.InodesFree), resource.BinarySI),
|
||||||
capacity: resource.NewQuantity(int64(*nodeFs.Inodes), 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{
|
result[evictionapi.SignalImageFsAvailable] = signalObservation{
|
||||||
available: resource.NewQuantity(int64(*imageFs.AvailableBytes), resource.BinarySI),
|
available: resource.NewQuantity(int64(*imageFs.AvailableBytes), resource.BinarySI),
|
||||||
capacity: resource.NewQuantity(int64(*imageFs.CapacityBytes), 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 {
|
if imageFs.InodesFree != nil && imageFs.Inodes != nil {
|
||||||
result[evictionapi.SignalImageFsInodesFree] = signalObservation{
|
result[evictionapi.SignalImageFsInodesFree] = signalObservation{
|
||||||
available: resource.NewQuantity(int64(*imageFs.InodesFree), resource.BinarySI),
|
available: resource.NewQuantity(int64(*imageFs.InodesFree), resource.BinarySI),
|
||||||
capacity: resource.NewQuantity(int64(*imageFs.Inodes), resource.BinarySI),
|
capacity: resource.NewQuantity(int64(*imageFs.Inodes), resource.BinarySI),
|
||||||
// TODO: add timestamp to stat (see memory stat)
|
time: imageFs.Time,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,12 +128,14 @@ func (sb *summaryBuilder) build() (*stats.Summary, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
rootStats := sb.containerInfoV2ToStats("", &rootInfo)
|
rootStats := sb.containerInfoV2ToStats("", &rootInfo)
|
||||||
|
cStats, _ := sb.latestContainerStats(&rootInfo)
|
||||||
nodeStats := stats.NodeStats{
|
nodeStats := stats.NodeStats{
|
||||||
NodeName: sb.node.Name,
|
NodeName: sb.node.Name,
|
||||||
CPU: rootStats.CPU,
|
CPU: rootStats.CPU,
|
||||||
Memory: rootStats.Memory,
|
Memory: rootStats.Memory,
|
||||||
Network: sb.containerInfoV2ToNetworkStats("node:"+sb.node.Name, &rootInfo),
|
Network: sb.containerInfoV2ToNetworkStats("node:"+sb.node.Name, &rootInfo),
|
||||||
Fs: &stats.FsStats{
|
Fs: &stats.FsStats{
|
||||||
|
Time: unversioned.NewTime(cStats.Timestamp),
|
||||||
AvailableBytes: &sb.rootFsInfo.Available,
|
AvailableBytes: &sb.rootFsInfo.Available,
|
||||||
CapacityBytes: &sb.rootFsInfo.Capacity,
|
CapacityBytes: &sb.rootFsInfo.Capacity,
|
||||||
UsedBytes: &sb.rootFsInfo.Usage,
|
UsedBytes: &sb.rootFsInfo.Usage,
|
||||||
@ -144,6 +146,7 @@ func (sb *summaryBuilder) build() (*stats.Summary, error) {
|
|||||||
StartTime: rootStats.StartTime,
|
StartTime: rootStats.StartTime,
|
||||||
Runtime: &stats.RuntimeStats{
|
Runtime: &stats.RuntimeStats{
|
||||||
ImageFs: &stats.FsStats{
|
ImageFs: &stats.FsStats{
|
||||||
|
Time: unversioned.NewTime(cStats.Timestamp),
|
||||||
AvailableBytes: &sb.imageFsInfo.Available,
|
AvailableBytes: &sb.imageFsInfo.Available,
|
||||||
CapacityBytes: &sb.imageFsInfo.Capacity,
|
CapacityBytes: &sb.imageFsInfo.Capacity,
|
||||||
UsedBytes: &sb.imageStats.TotalStorageBytes,
|
UsedBytes: &sb.imageStats.TotalStorageBytes,
|
||||||
@ -181,8 +184,14 @@ func (sb *summaryBuilder) containerInfoV2FsStats(
|
|||||||
info *cadvisorapiv2.ContainerInfo,
|
info *cadvisorapiv2.ContainerInfo,
|
||||||
cs *stats.ContainerStats) {
|
cs *stats.ContainerStats) {
|
||||||
|
|
||||||
|
lcs, found := sb.latestContainerStats(info)
|
||||||
|
if !found {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// The container logs live on the node rootfs device
|
// The container logs live on the node rootfs device
|
||||||
cs.Logs = &stats.FsStats{
|
cs.Logs = &stats.FsStats{
|
||||||
|
Time: unversioned.NewTime(lcs.Timestamp),
|
||||||
AvailableBytes: &sb.rootFsInfo.Available,
|
AvailableBytes: &sb.rootFsInfo.Available,
|
||||||
CapacityBytes: &sb.rootFsInfo.Capacity,
|
CapacityBytes: &sb.rootFsInfo.Capacity,
|
||||||
InodesFree: sb.rootFsInfo.InodesFree,
|
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)
|
// The container rootFs lives on the imageFs devices (which may not be the node root fs)
|
||||||
cs.Rootfs = &stats.FsStats{
|
cs.Rootfs = &stats.FsStats{
|
||||||
|
Time: unversioned.NewTime(lcs.Timestamp),
|
||||||
AvailableBytes: &sb.imageFsInfo.Available,
|
AvailableBytes: &sb.imageFsInfo.Available,
|
||||||
CapacityBytes: &sb.imageFsInfo.Capacity,
|
CapacityBytes: &sb.imageFsInfo.Capacity,
|
||||||
InodesFree: sb.imageFsInfo.InodesFree,
|
InodesFree: sb.imageFsInfo.InodesFree,
|
||||||
Inodes: sb.imageFsInfo.Inodes,
|
Inodes: sb.imageFsInfo.Inodes,
|
||||||
}
|
}
|
||||||
lcs, found := sb.latestContainerStats(info)
|
|
||||||
if !found {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
cfs := lcs.Filesystem
|
cfs := lcs.Filesystem
|
||||||
|
|
||||||
if cfs != nil {
|
if cfs != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user