Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions openshift/tests-extension/test/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServi
}
})

AfterAll(func(ctx SpecContext) {
helpers.EnsureCleanupClusterCatalog(ctx, webhookCatalogName)
Copy link
Contributor Author

@camilamacedo86 camilamacedo86 Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tmshort

I have one concern:
The only way to clean it is with AfterALL
However, can we really use AfterAll with OTE?

If I remember correctly, I read in a comment that it might not work well, which is why it was not added in the first place.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are you trying to clean up here? The catalogs are not all cleaned up?

Copy link
Contributor Author

@camilamacedo86 camilamacedo86 Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the webhook tests, we create a Catalog.
This Catalog is shared across all tests. That is why we can only clean AfterAll

By design, it was not cleaned up before.
(I am not sure if we can use AfterAll, but if we can, that might be the only way.)

Please see EnsureCleanupClusterCatalog.
This helper makes sure the Catalog is cleaned up:

func EnsureCleanupClusterCatalog(ctx context.Context, name string) {
k8s := env.Get().K8sClient
cc := &olmv1.ClusterCatalog{}
key := client.ObjectKey{Name: name}
if err := k8s.Get(ctx, key, cc); err != nil {
if !errors.IsNotFound(err) {
fmt.Fprintf(GinkgoWriter, "Warning: failed to get ClusterCatalog %q during cleanup: %v\n", name, err)
}
return
}
By(fmt.Sprintf("deleting lingering ClusterCatalog %q", name))
if err := k8s.Delete(ctx, cc); err != nil && !errors.IsNotFound(err) {
fmt.Fprintf(GinkgoWriter, "Warning: failed to delete ClusterCatalog %q: %v\n", name, err)
}
Eventually(func() bool {
err := k8s.Get(ctx, key, &olmv1.ClusterCatalog{})
return errors.IsNotFound(err)
}).WithTimeout(3*time.Minute).WithPolling(2*time.Second).
Should(BeTrue(), "ClusterCatalog %q failed to delete", name)
}

Why was this not added earlier?
There is some history here:
👉 openshift/origin#30059 (comment)

Because of that, I am not sure if it is completely safe to add now.
I think we need confirm.

So, for now, I would suggest:

  • Put this PR on /hold
  • It doesn’t seem safe to take the risk before TDB
  • Our checks already confirm that everything is cleaned properly

})

It("should have a working validating webhook", func(ctx SpecContext) {
By("creating a webhook test resource that will be rejected by the validating webhook")
Eventually(func() error {
Expand Down