From 9b6eb9c3a9d43e2f6350c88893dfecea682b1c1d Mon Sep 17 00:00:00 2001 From: Itamar Holder Date: Tue, 27 Jun 2023 12:43:02 +0300 Subject: [PATCH] Add SwapStats to NodeStats, PodStats and ContainerStats Signed-off-by: Itamar Holder Kubernetes-commit: a05d200ac8961ec29c8eebab46ca1fa249061a2f --- pkg/apis/stats/v1alpha1/types.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/pkg/apis/stats/v1alpha1/types.go b/pkg/apis/stats/v1alpha1/types.go index 5e75fef..f201ce3 100644 --- a/pkg/apis/stats/v1alpha1/types.go +++ b/pkg/apis/stats/v1alpha1/types.go @@ -59,6 +59,9 @@ type NodeStats struct { // Stats about the rlimit of system. // +optional Rlimit *RlimitStats `json:"rlimit,omitempty"` + // Stats pertaining to swap resources. This is reported to non-windows systems only. + // +optional + Swap *SwapStats `json:"swap,omitempty"` } // RlimitStats are stats rlimit of OS. @@ -131,6 +134,9 @@ type PodStats struct { // ProcessStats pertaining to processes. // +optional ProcessStats *ProcessStats `json:"process_stats,omitempty"` + // Stats pertaining to swap resources. This is reported to non-windows systems only. + // +optional + Swap *SwapStats `json:"swap,omitempty"` } // ContainerStats holds container-level unprocessed sample stats. @@ -159,6 +165,9 @@ type ContainerStats struct { // +patchMergeKey=name // +patchStrategy=merge UserDefinedMetrics []UserDefinedMetric `json:"userDefinedMetrics,omitempty" patchStrategy:"merge" patchMergeKey:"name"` + // Stats pertaining to swap resources. This is reported to non-windows systems only. + // +optional + Swap *SwapStats `json:"swap,omitempty"` } // PodReference contains enough information to locate the referenced pod. @@ -237,6 +246,19 @@ type MemoryStats struct { MajorPageFaults *uint64 `json:"majorPageFaults,omitempty"` } +// SwapStats contains data about memory usage +type SwapStats struct { + // The time at which these stats were updated. + Time metav1.Time `json:"time"` + // Available swap memory for use. This is defined as the - . + // If swap limit is undefined, this value is omitted. + // +optional + SwapAvailableBytes *uint64 `json:"swapAvailableBytes,omitempty"` + // Total swap memory in use. + // +optional + SwapUsageBytes *uint64 `json:"swapUsageBytes,omitempty"` +} + // AcceleratorStats contains stats for accelerators attached to the container. type AcceleratorStats struct { // Make of the accelerator (nvidia, amd, google etc.)