Merge pull request #125981 from dims/cleanup-pods-after-test-runs

[e2e-node] Cleanup pods after the test runs
This commit is contained in:
Kubernetes Prow Robot 2024-07-09 15:01:01 -07:00 committed by GitHub
commit 672af9406e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 11 additions and 4 deletions

View File

@ -51,6 +51,7 @@ func prefixedName(namePrefix string, name string) string {
var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", func() { var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", func() {
f := framework.NewDefaultFramework("containers-lifecycle-test") f := framework.NewDefaultFramework("containers-lifecycle-test")
addAfterEachForCleaningUpPods(f)
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
ginkgo.It("should launch init container serially before a regular container", func() { ginkgo.It("should launch init container serially before a regular container", func() {
@ -909,6 +910,7 @@ var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", fun
var _ = SIGDescribe(framework.WithSerial(), "Containers Lifecycle", func() { var _ = SIGDescribe(framework.WithSerial(), "Containers Lifecycle", func() {
f := framework.NewDefaultFramework("containers-lifecycle-test-serial") f := framework.NewDefaultFramework("containers-lifecycle-test-serial")
addAfterEachForCleaningUpPods(f)
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) { ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) {
@ -1049,6 +1051,7 @@ var _ = SIGDescribe(framework.WithSerial(), "Containers Lifecycle", func() {
var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func() { var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func() {
f := framework.NewDefaultFramework("containers-lifecycle-test") f := framework.NewDefaultFramework("containers-lifecycle-test")
addAfterEachForCleaningUpPods(f)
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
ginkgo.When("using a Pod with restartPolicy=Never, three init container and two restartable init containers", ginkgo.Ordered, func() { ginkgo.When("using a Pod with restartPolicy=Never, three init container and two restartable init containers", ginkgo.Ordered, func() {
@ -3119,6 +3122,7 @@ var _ = SIGDescribe(nodefeature.SidecarContainers, "Containers Lifecycle", func(
var _ = SIGDescribe(nodefeature.SidecarContainers, framework.WithSerial(), "Containers Lifecycle", func() { var _ = SIGDescribe(nodefeature.SidecarContainers, framework.WithSerial(), "Containers Lifecycle", func() {
f := framework.NewDefaultFramework("containers-lifecycle-test-serial") f := framework.NewDefaultFramework("containers-lifecycle-test-serial")
addAfterEachForCleaningUpPods(f)
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) { ginkgo.It("should restart the containers in right order after the node reboot", func(ctx context.Context) {

View File

@ -128,5 +128,6 @@ var _ = SIGDescribe("PodPidsLimit", framework.WithSerial(), func() {
initialConfig.PodPidsLimit = int64(1024) initialConfig.PodPidsLimit = int64(1024)
}) })
runPodPidsLimitTests(f) runPodPidsLimitTests(f)
addAfterEachForCleaningUpPods(f)
}) })
}) })

View File

@ -58,7 +58,7 @@ var _ = SIGDescribe("Pod conditions managed by Kubelet", func() {
ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, true)) ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, true))
ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, true)) ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, true))
ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, true)) ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, true))
cleanupPods(f) addAfterEachForCleaningUpPods(f)
}) })
ginkgo.Context("without PodReadyToStartContainersCondition condition", func() { ginkgo.Context("without PodReadyToStartContainersCondition condition", func() {
@ -66,7 +66,7 @@ var _ = SIGDescribe("Pod conditions managed by Kubelet", func() {
ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, false)) ginkgo.It("a pod with init containers should report all conditions set in expected order after the pod is up", runPodReadyConditionsTest(f, true, false))
ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, false)) ginkgo.It("a pod failing to mount volumes and without init containers should report scheduled and initialized conditions set", runPodFailingConditionsTest(f, false, false))
ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, false)) ginkgo.It("a pod failing to mount volumes and with init containers should report just the scheduled condition set", runPodFailingConditionsTest(f, true, false))
cleanupPods(f) addAfterEachForCleaningUpPods(f)
}) })
}) })

View File

@ -103,6 +103,7 @@ var _ = SIGDescribe("LocalStorageCapacityIsolationFSQuotaMonitoring", framework.
f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged f.NamespacePodSecurityLevel = admissionapi.LevelPrivileged
runOneQuotaTest(f, true) runOneQuotaTest(f, true)
runOneQuotaTest(f, false) runOneQuotaTest(f, false)
addAfterEachForCleaningUpPods(f)
}) })
const ( const (

View File

@ -56,8 +56,9 @@ var (
noLimits *resource.Quantity = nil noLimits *resource.Quantity = nil
) )
var _ = SIGDescribe("Swap", "[LinuxOnly]", nodefeature.Swap, func() { var _ = SIGDescribe("Swap", "[LinuxOnly]", nodefeature.Swap, framework.WithSerial(), func() {
f := framework.NewDefaultFramework("swap-qos") f := framework.NewDefaultFramework("swap-qos")
addAfterEachForCleaningUpPods(f)
f.NamespacePodSecurityLevel = admissionapi.LevelBaseline f.NamespacePodSecurityLevel = admissionapi.LevelBaseline
ginkgo.BeforeEach(func() { ginkgo.BeforeEach(func() {

View File

@ -171,7 +171,7 @@ func getCurrentKubeletConfig(ctx context.Context) (*kubeletconfig.KubeletConfigu
return e2enodekubelet.GetCurrentKubeletConfig(ctx, framework.TestContext.NodeName, "", false, framework.TestContext.StandaloneMode) return e2enodekubelet.GetCurrentKubeletConfig(ctx, framework.TestContext.NodeName, "", false, framework.TestContext.StandaloneMode)
} }
func cleanupPods(f *framework.Framework) { func addAfterEachForCleaningUpPods(f *framework.Framework) {
ginkgo.AfterEach(func(ctx context.Context) { ginkgo.AfterEach(func(ctx context.Context) {
ginkgo.By("Deleting any Pods created by the test in namespace: " + f.Namespace.Name) ginkgo.By("Deleting any Pods created by the test in namespace: " + f.Namespace.Name)
l, err := e2epod.NewPodClient(f).List(ctx, metav1.ListOptions{}) l, err := e2epod.NewPodClient(f).List(ctx, metav1.ListOptions{})