@@ -24,6 +24,8 @@ import (
24
24
v1 "k8s.io/api/core/v1"
25
25
"k8s.io/apimachinery/pkg/api/resource"
26
26
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
+ utilfeature "k8s.io/apiserver/pkg/util/feature"
28
+ "k8s.io/kubernetes/pkg/features"
27
29
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
28
30
"k8s.io/kubernetes/test/e2e/framework"
29
31
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
@@ -117,6 +119,18 @@ func runOomKillerTest(f *framework.Framework, testCase testCase, kubeReservedMem
117
119
})
118
120
119
121
ginkgo .It ("The containers terminated by OOM killer should have the reason set to OOMKilled" , func () {
122
+ cfg , configErr := getCurrentKubeletConfig (context .TODO ())
123
+ framework .ExpectNoError (configErr )
124
+ if utilfeature .DefaultFeatureGate .Enabled (features .NodeSwap ) {
125
+ // If Swap is enabled, we should test OOM with LimitedSwap.
126
+ // UnlimitedSwap allows for workloads to use unbounded swap which
127
+ // makes testing OOM challenging.
128
+ // We are not able to change the default for these conformance tests,
129
+ // so we will skip these tests if swap is enabled.
130
+ if cfg .MemorySwap .SwapBehavior == "" || cfg .MemorySwap .SwapBehavior == "UnlimitedSwap" {
131
+ ginkgo .Skip ("OOMKiller should not run with UnlimitedSwap" )
132
+ }
133
+ }
120
134
ginkgo .By ("Waiting for the pod to be failed" )
121
135
err := e2epod .WaitForPodTerminatedInNamespace (context .TODO (), f .ClientSet , testCase .podSpec .Name , "" , f .Namespace .Name )
122
136
framework .ExpectNoError (err , "Failed waiting for pod to terminate, %s/%s" , f .Namespace .Name , testCase .podSpec .Name )
0 commit comments