populate the new node.status.nodeInfo.swapInfo field

Signed-off-by: Itamar Holder <iholder@redhat.com>
This commit is contained in:
Itamar Holder 2025-02-04 14:57:49 +02:00
parent a9b0211409
commit 16871a1faa

View File

@ -44,6 +44,7 @@ import (
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
"k8s.io/kubernetes/pkg/kubelet/events"
netutils "k8s.io/utils/net"
"k8s.io/utils/ptr"
"k8s.io/klog/v2"
)
@ -354,6 +355,12 @@ func MachineInfo(nodeName string,
// node status.
node.Status.Capacity[v1.ResourceName(removedResource)] = *resource.NewQuantity(int64(0), resource.DecimalSI)
}
if utilfeature.DefaultFeatureGate.Enabled(features.NodeSwap) && info.SwapCapacity != 0 {
node.Status.NodeInfo.Swap = &v1.NodeSwapStatus{
Capacity: ptr.To(int64(info.SwapCapacity)),
}
}
}
// Set Allocatable.