Skip to content

Commit

Permalink
Merge pull request kubernetes#124110 from benluddy/automated-cherry-p…
Browse files Browse the repository at this point in the history
…ick-of-#123873-kubernetes-release-1.29

Automated cherry pick of kubernetes#123873: retry policy creation for CRD type checking E2E test
  • Loading branch information
k8s-ci-robot committed Apr 5, 2024
2 parents c3e84fd + cd9f653 commit bddce43
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/e2e/apimachinery/validatingadmissionpolicy.go
Expand Up @@ -19,6 +19,7 @@ package apimachinery
import (
"context"
"fmt"
"math/rand"
"time"

"github.com/onsi/ginkgo/v2"
Expand All @@ -35,6 +36,7 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apiserver/pkg/features"
applyadmissionregistrationv1beta1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1beta1"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/openapi3"
"k8s.io/kubernetes/test/e2e/framework"
Expand Down Expand Up @@ -340,6 +342,16 @@ var _ = SIGDescribe("ValidatingAdmissionPolicy [Privileged:ClusterAdmin]", frame
return false, err
}
if policy.Status.TypeChecking != nil {
// TODO(#123829) Remove once the schema watcher is merged.
// If the warnings are empty, touch the policy to retry type checking
if len(policy.Status.TypeChecking.ExpressionWarnings) == 0 {
applyConfig := applyadmissionregistrationv1beta1.ValidatingAdmissionPolicy(policy.Name).WithLabels(map[string]string{
"touched": time.Now().String(),
"random": fmt.Sprintf("%d", rand.Int()),
})
_, err := client.AdmissionregistrationV1beta1().ValidatingAdmissionPolicies().Apply(ctx, applyConfig, metav1.ApplyOptions{})
return false, err
}
return true, nil
}
return false, nil
Expand Down

0 comments on commit bddce43

Please sign in to comment.