Merge pull request #128263 from ShazaAldawamneh/typecheck-retry-generation

CRD type check test fix
This commit is contained in:
Kubernetes Prow Robot 2024-10-31 13:53:33 +00:00 committed by GitHub
commit 69e30cd642
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -366,10 +366,15 @@ var _ = SIGDescribe("ValidatingAdmissionPolicy [Privileged:ClusterAdmin]", func(
// 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": fmt.Sprintf("a%d", time.Now().UnixMilli()),
"random": fmt.Sprintf("a%d", rand.Int()),
})
randomValue := fmt.Sprintf(`"%d"`, rand.Int())
// Use a fixed key and change only the value
applyConfig := applyadmissionregistrationv1.ValidatingAdmissionPolicy(policy.Name).
WithSpec(applyadmissionregistrationv1.ValidatingAdmissionPolicySpec().
WithAuditAnnotations(applyadmissionregistrationv1.AuditAnnotation().
WithKey("key").
WithValueExpression(randomValue),
),
)
_, err := client.AdmissionregistrationV1().ValidatingAdmissionPolicies().Apply(ctx, applyConfig, metav1.ApplyOptions{FieldManager: "validatingadmissionpolicy-e2e"})
return false, err
}