Merge pull request #121706 from kannon92/fix-oom-swap-fedora
Skip OOMKilled Jobs if Swap is enabled.
This commit is contained in:
		@@ -24,6 +24,8 @@ import (
 | 
				
			|||||||
	v1 "k8s.io/api/core/v1"
 | 
						v1 "k8s.io/api/core/v1"
 | 
				
			||||||
	"k8s.io/apimachinery/pkg/api/resource"
 | 
						"k8s.io/apimachinery/pkg/api/resource"
 | 
				
			||||||
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
						metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 | 
				
			||||||
 | 
						utilfeature "k8s.io/apiserver/pkg/util/feature"
 | 
				
			||||||
 | 
						"k8s.io/kubernetes/pkg/features"
 | 
				
			||||||
	kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
 | 
						kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
 | 
				
			||||||
	"k8s.io/kubernetes/test/e2e/framework"
 | 
						"k8s.io/kubernetes/test/e2e/framework"
 | 
				
			||||||
	e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
 | 
						e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
 | 
				
			||||||
@@ -117,6 +119,18 @@ func runOomKillerTest(f *framework.Framework, testCase testCase, kubeReservedMem
 | 
				
			|||||||
		})
 | 
							})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ginkgo.It("The containers terminated by OOM killer should have the reason set to OOMKilled", func() {
 | 
							ginkgo.It("The containers terminated by OOM killer should have the reason set to OOMKilled", func() {
 | 
				
			||||||
 | 
								cfg, configErr := getCurrentKubeletConfig(context.TODO())
 | 
				
			||||||
 | 
								framework.ExpectNoError(configErr)
 | 
				
			||||||
 | 
								if utilfeature.DefaultFeatureGate.Enabled(features.NodeSwap) {
 | 
				
			||||||
 | 
									// If Swap is enabled, we should test OOM with LimitedSwap.
 | 
				
			||||||
 | 
									// UnlimitedSwap allows for workloads to use unbounded swap which
 | 
				
			||||||
 | 
									// makes testing OOM challenging.
 | 
				
			||||||
 | 
									// We are not able to change the default for these conformance tests,
 | 
				
			||||||
 | 
									// so we will skip these tests if swap is enabled.
 | 
				
			||||||
 | 
									if cfg.MemorySwap.SwapBehavior == "" || cfg.MemorySwap.SwapBehavior == "UnlimitedSwap" {
 | 
				
			||||||
 | 
										ginkgo.Skip("OOMKiller should not run with UnlimitedSwap")
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
			ginkgo.By("Waiting for the pod to be failed")
 | 
								ginkgo.By("Waiting for the pod to be failed")
 | 
				
			||||||
			err := e2epod.WaitForPodTerminatedInNamespace(context.TODO(), f.ClientSet, testCase.podSpec.Name, "", f.Namespace.Name)
 | 
								err := e2epod.WaitForPodTerminatedInNamespace(context.TODO(), f.ClientSet, testCase.podSpec.Name, "", f.Namespace.Name)
 | 
				
			||||||
			framework.ExpectNoError(err, "Failed waiting for pod to terminate, %s/%s", f.Namespace.Name, testCase.podSpec.Name)
 | 
								framework.ExpectNoError(err, "Failed waiting for pod to terminate, %s/%s", f.Namespace.Name, testCase.podSpec.Name)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user