fixing k8s.io/kubernetes/pkg/kubelet/eviction unit tests on Windows

Signed-off-by: Mark Rossetti <marosset@microsoft.com>
This commit is contained in:
Mark Rossetti 2025-02-12 16:57:19 -08:00
parent fbdf8905ea
commit ec165ca560
No known key found for this signature in database
GPG Key ID: 33F9E7BD7AA6C1B0
2 changed files with 14 additions and 0 deletions

View File

@ -19,6 +19,7 @@ package eviction
import (
"context"
"fmt"
goruntime "runtime"
"testing"
"time"
@ -189,6 +190,7 @@ func makeMemoryStats(nodeAvailableBytes string, podStats map[*v1.Pod]statsapi.Po
WorkingSetBytes: &WorkingSetBytes,
},
SystemContainers: []statsapi.ContainerStats{
// Used for memory signal observations on linux
{
Name: statsapi.SystemContainerPods,
Memory: &statsapi.MemoryStats{
@ -196,6 +198,14 @@ func makeMemoryStats(nodeAvailableBytes string, podStats map[*v1.Pod]statsapi.Po
WorkingSetBytes: &WorkingSetBytes,
},
},
// Used for memory signal observations on windows
{
Name: statsapi.SystemContainerWindowsGlobalCommitMemory,
Memory: &statsapi.MemoryStats{
AvailableBytes: &availableBytes,
UsageBytes: &WorkingSetBytes,
},
},
},
},
Pods: []statsapi.PodStats{},
@ -354,6 +364,9 @@ func TestMemoryPressure_VerifyPodStatus(t *testing.T) {
}
func TestPIDPressure_VerifyPodStatus(t *testing.T) {
if goruntime.GOOS == "windows" {
t.Skip("PID pressure is not supported on Windows")
}
testCases := map[string]struct {
wantPodStatus v1.PodStatus
}{

View File

@ -31,6 +31,7 @@ func makeMemoryAvailableSignalObservation(summary *statsapi.Summary) *signalObse
sysContainer, err := getSysContainer(summary.Node.SystemContainers, statsapi.SystemContainerWindowsGlobalCommitMemory)
if err != nil {
klog.ErrorS(err, "Eviction manager: failed to construct signal", "signal", evictionapi.SignalMemoryAvailable)
return nil
}
if memory := sysContainer.Memory; memory != nil && memory.AvailableBytes != nil && memory.UsageBytes != nil {
klog.V(4).InfoS(