Skip to content

Conversation

@cheina97
Copy link
Member

@cheina97 cheina97 commented Sep 22, 2025

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

@adamjensenbot
Copy link
Collaborator

Hi @cheina97. Thanks for your PR!

I am @adamjensenbot.
You can interact with me issuing a slash command in the first line of a comment.
Currently, I understand the following commands:

  • /rebase: Rebase this PR onto the master branch (You can add the option test=true to launch the tests
    when the rebase operation is completed)
  • /merge: Merge this PR into the master branch
  • /build Build Liqo components
  • /test Launch the E2E and Unit tests
  • /hold, /unhold Add/remove the hold label to prevent merging with /merge

Make sure this PR appears in the liqo changelog, adding one of the following labels:

  • feat: 🚀 New Feature
  • fix: 🐛 Bug Fix
  • refactor: 🧹 Code Refactoring
  • docs: 📝 Documentation
  • style: 💄 Code Style
  • perf: 🐎 Performance Improvement
  • test: ✅ Tests
  • chore: 🚚 Dependencies Management
  • build: 📦 Builds Management
  • ci: 👷 CI/CD
  • revert: ⏪ Reverts Previous Changes

@github-actions github-actions bot added the feat Adds a new feature to the codebase label Sep 22, 2025
@cheina97
Copy link
Member Author

/rebase test=true

Comment on lines +48 to 81
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))
}
}
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feat Adds a new feature to the codebase size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants