-
Notifications
You must be signed in to change notification settings - Fork 128
feat: avoid kyverno dependency in tests #3128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
|
Hi @cheina97. Thanks for your PR! I am @adamjensenbot.
Make sure this PR appears in the liqo changelog, adding one of the following labels:
|
|
/rebase test=true |
f721cfc to
773623c
Compare
| if IsKyvernoAvailable(ctx, cl.ConsumerDynamic) { | ||
| policy := ForgeKyvernoPodAntiaffinityPolicy(cl.ConsumerName, false) | ||
| if _, err := cl.ConsumerDynamic.Resource(KyvernoPolicyGroupVersionResource). | ||
| Namespace(NamespaceName).Create(ctx, policy, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) { | ||
| return fmt.Errorf("consumer failed to create policy: %w", err) | ||
| } | ||
|
|
||
| policy = ForgeKyvernoPodAntiaffinityPolicy(cl.ConsumerName, true) | ||
| if _, err := cl.ConsumerDynamic.Resource(KyvernoPolicyGroupVersionResource). | ||
| Namespace(NamespaceName).Create(ctx, policy, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) { | ||
| return fmt.Errorf("consumer failed to create policy: %w", err) | ||
| policy = ForgeKyvernoPodAntiaffinityPolicy(cl.ConsumerName, true) | ||
| if _, err := cl.ConsumerDynamic.Resource(KyvernoPolicyGroupVersionResource). | ||
| Namespace(NamespaceName).Create(ctx, policy, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) { | ||
| return fmt.Errorf("consumer failed to create policy: %w", err) | ||
| } | ||
| } else { | ||
| kyvernoNotInstalled = true | ||
| printer.Logger.Warn("Kyverno not available on consumer, skipping policy creation.") | ||
| } | ||
|
|
||
| for k := range cl.Providers { | ||
| policy := ForgeKyvernoPodAntiaffinityPolicy(k, false) | ||
| if _, err := cl.ProvidersDynamic[k].Resource(KyvernoPolicyGroupVersionResource). | ||
| Namespace(NamespaceName).Create(ctx, policy, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) { | ||
| return fmt.Errorf("provider %q failed to create policy: %w", k, err) | ||
| } | ||
| policy = ForgeKyvernoPodAntiaffinityPolicy(k, true) | ||
| if _, err := cl.ProvidersDynamic[k].Resource(KyvernoPolicyGroupVersionResource). | ||
| Namespace(NamespaceName).Create(ctx, policy, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) { | ||
| return fmt.Errorf("provider %q failed to create policy: %w", k, err) | ||
| if IsKyvernoAvailable(ctx, cl.ProvidersDynamic[k]) { | ||
| policy := ForgeKyvernoPodAntiaffinityPolicy(k, false) | ||
| if _, err := cl.ProvidersDynamic[k].Resource(KyvernoPolicyGroupVersionResource). | ||
| Namespace(NamespaceName).Create(ctx, policy, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) { | ||
| return fmt.Errorf("provider %q failed to create policy: %w", k, err) | ||
| } | ||
| policy = ForgeKyvernoPodAntiaffinityPolicy(k, true) | ||
| if _, err := cl.ProvidersDynamic[k].Resource(KyvernoPolicyGroupVersionResource). | ||
| Namespace(NamespaceName).Create(ctx, policy, metav1.CreateOptions{}); err != nil && !apierrors.IsAlreadyExists(err) { | ||
| return fmt.Errorf("provider %q failed to create policy: %w", k, err) | ||
| } | ||
| } else { | ||
| kyvernoNotInstalled = true | ||
| printer.Logger.Warn(fmt.Sprintf("Kyverno not available on provider %q, skipping policy creation.", k)) | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: can we refactor it so that both consumer and providers call the same function, avoiding code duplicates?
Description
This PR removes the kyverno dependency from network tests.
If kyverno is not installed in one of the tested clusters a warning will be triggered.
In case you are not using kyverno you cannot be sure that all the pods will be scheduled one per node