Merge pull request #130125 from marosset/windows-unit-tests-kubelet-eviction-fixes

fixing k8s.io/kubernetes/pkg/kubelet/eviction unit tests on Windows
This commit is contained in:
Kubernetes Prow Robot 2025-03-07 12:27:46 -08:00 committed by GitHub
commit 83b696c720
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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(