Merge pull request #106671 from wzshiming/test/e2e-graceful-node-shutdown-based-on-pod-priority

Fix flaky test - when gracefully shutting down with Pod priority should be able to gracefully shutdown pods with various grace periods
This commit is contained in:
Kubernetes Prow Robot 2022-02-17 22:32:26 -08:00 committed by GitHub
commit 2078864d08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,6 +28,7 @@ import (
"strconv" "strconv"
"time" "time"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/fields" "k8s.io/apimachinery/pkg/fields"
"github.com/onsi/ginkgo" "github.com/onsi/ginkgo"
@ -223,8 +224,9 @@ var _ = SIGDescribe("GracefulNodeShutdown [Serial] [NodeFeature:GracefulNodeShut
ginkgo.Context("when gracefully shutting down with Pod priority", func() { ginkgo.Context("when gracefully shutting down with Pod priority", func() {
const ( const (
pollInterval = 1 * time.Second pollInterval = 1 * time.Second
podStatusUpdateTimeout = 10 * time.Second podStatusUpdateTimeout = 10 * time.Second
priorityClassesCreateTimeout = 10 * time.Second
) )
var ( var (
@ -271,11 +273,22 @@ var _ = SIGDescribe("GracefulNodeShutdown [Serial] [NodeFeature:GracefulNodeShut
ginkgo.By("Wait for the node to be ready") ginkgo.By("Wait for the node to be ready")
waitForNodeReady() waitForNodeReady()
customClasses := []*schedulingv1.PriorityClass{customClassA, customClassB, customClassC}
for _, customClass := range []*schedulingv1.PriorityClass{customClassA, customClassB, customClassC} { for _, customClass := range customClasses {
_, err := f.ClientSet.SchedulingV1().PriorityClasses().Create(context.Background(), customClass, metav1.CreateOptions{}) _, err := f.ClientSet.SchedulingV1().PriorityClasses().Create(context.Background(), customClass, metav1.CreateOptions{})
framework.ExpectNoError(err) if err != nil && !apierrors.IsAlreadyExists(err) {
framework.ExpectNoError(err)
}
} }
gomega.Eventually(func() error {
for _, customClass := range customClasses {
_, err := f.ClientSet.SchedulingV1().PriorityClasses().Get(context.Background(), customClass.Name, metav1.GetOptions{})
if err != nil {
return err
}
}
return nil
}, priorityClassesCreateTimeout, pollInterval).Should(gomega.BeNil())
}) })
ginkgo.AfterEach(func() { ginkgo.AfterEach(func() {