mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
retry policy creation for CRD type checking E2E test
This commit is contained in:
parent
e062f925ae
commit
dc2974c646
@ -18,6 +18,8 @@ package apimachinery
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/rand/v2"
|
||||
"time"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
@ -32,6 +34,7 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
applyadmissionregistrationv1 "k8s.io/client-go/applyconfigurations/admissionregistration/v1"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
"k8s.io/client-go/openapi3"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
@ -356,6 +359,16 @@ var _ = SIGDescribe("ValidatingAdmissionPolicy [Privileged:ClusterAdmin]", func(
|
||||
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 := applyadmissionregistrationv1.ValidatingAdmissionPolicy(policy.Name).WithLabels(map[string]string{
|
||||
"touched": time.Now().String(),
|
||||
"random": fmt.Sprintf("%d", rand.Int()),
|
||||
})
|
||||
_, err := client.AdmissionregistrationV1().ValidatingAdmissionPolicies().Apply(ctx, applyConfig, metav1.ApplyOptions{})
|
||||
return false, err
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
return false, nil
|
||||
|
Loading…
Reference in New Issue
Block a user