mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 13:31:52 +00:00
Add swap statistics to CRI-API
Signed-off-by: Itamar Holder <iholder@redhat.com>
This commit is contained in:
parent
053d7ac61f
commit
87ff9c4525
@ -577,6 +577,7 @@ func (p *criStatsProvider) makeContainerStats(
|
||||
CPU: &statsapi.CPUStats{},
|
||||
Memory: &statsapi.MemoryStats{},
|
||||
Rootfs: &statsapi.FsStats{},
|
||||
Swap: &statsapi.SwapStats{},
|
||||
// UserDefinedMetrics is not supported by CRI.
|
||||
}
|
||||
if stats.Cpu != nil {
|
||||
@ -607,6 +608,19 @@ func (p *criStatsProvider) makeContainerStats(
|
||||
result.Memory.Time = metav1.NewTime(time.Unix(0, time.Now().UnixNano()))
|
||||
result.Memory.WorkingSetBytes = uint64Ptr(0)
|
||||
}
|
||||
if stats.Swap != nil {
|
||||
result.Swap.Time = metav1.NewTime(time.Unix(0, stats.Swap.Timestamp))
|
||||
if stats.Swap.SwapUsageBytes != nil {
|
||||
result.Swap.SwapUsageBytes = &stats.Swap.SwapUsageBytes.Value
|
||||
}
|
||||
if stats.Swap.SwapAvailableBytes != nil {
|
||||
result.Swap.SwapAvailableBytes = &stats.Swap.SwapAvailableBytes.Value
|
||||
}
|
||||
} else {
|
||||
result.Swap.Time = metav1.NewTime(time.Unix(0, time.Now().UnixNano()))
|
||||
result.Swap.SwapUsageBytes = uint64Ptr(0)
|
||||
result.Swap.SwapAvailableBytes = uint64Ptr(0)
|
||||
}
|
||||
if stats.WritableLayer != nil {
|
||||
result.Rootfs.Time = metav1.NewTime(time.Unix(0, stats.WritableLayer.Timestamp))
|
||||
if stats.WritableLayer.UsedBytes != nil {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1639,6 +1639,8 @@ message ContainerStats {
|
||||
MemoryUsage memory = 3;
|
||||
// Usage of the writable layer.
|
||||
FilesystemUsage writable_layer = 4;
|
||||
// Swap usage gathered from the container.
|
||||
SwapUsage swap = 5;
|
||||
}
|
||||
|
||||
// WindowsContainerStats provides the resource usage statistics for a container specific for Windows
|
||||
@ -1693,6 +1695,15 @@ message MemoryUsage {
|
||||
UInt64Value major_page_faults = 7;
|
||||
}
|
||||
|
||||
message SwapUsage {
|
||||
// Timestamp in nanoseconds at which the information were collected. Must be > 0.
|
||||
int64 timestamp = 1;
|
||||
// Available swap for use. This is defined as the swap limit - swapUsageBytes.
|
||||
UInt64Value swap_available_bytes = 2;
|
||||
// Total memory in use. This includes all memory regardless of when it was accessed.
|
||||
UInt64Value swap_usage_bytes = 3;
|
||||
}
|
||||
|
||||
// WindowsMemoryUsage provides the memory usage information specific to Windows
|
||||
message WindowsMemoryUsage {
|
||||
// Timestamp in nanoseconds at which the information were collected. Must be > 0.
|
||||
|
Loading…
Reference in New Issue
Block a user