Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5ed8cf4
add PDB to make sure at least 1 pod is always available during upgrad…
jianzhangbjz Nov 27, 2025
4355cde
Update ClusterExtensionRevision API docs (#2350)
perdasilva Nov 27, 2025
91b03c7
🌱 new tag symmetry and required validations (#2358)
grokspawn Dec 1, 2025
4e5542f
:seedling: Bump pymdown-extensions from 10.17.1 to 10.17.2 (#2364)
dependabot[bot] Dec 1, 2025
b23e124
institute 2wk dependency cooldown policy (#2363)
grokspawn Dec 1, 2025
34394ce
Fix testCatalogName conflict in parallel e2e tests (#2367)
jianzhangbjz Dec 2, 2025
0072857
Merge branch 'main' into synchronize
Dec 2, 2025
4a547db
UPSTREAM: <carry>: Add OpenShift specific files
dtfranz Oct 26, 2023
b6f4da7
UPSTREAM: <carry>: Add new tests for single/own namespaces install modes
camilamacedo86 Oct 6, 2025
93b3929
UPSTREAM: <carry>: Upgrade OCP image from 4.20 to 4.21
camilamacedo86 Oct 13, 2025
b3b6d06
UPSTREAM: <carry>: [Default Catalog Tests] - Change logic to get ocp …
camilamacedo86 Oct 13, 2025
58c2f61
UPSTREAM: <carry>: Update OCP catalogs to v4.21
tmshort Oct 13, 2025
3fa03ea
UPSTREAM: <carry>: support singleown cases in disconnected
kuiwang02 Oct 16, 2025
9d58caa
UPSTREAM: <carry>: fix cases 81696 and 74618 for product code changes
kuiwang02 Oct 17, 2025
84201cb
UPSTREAM: <carry>: Define Default timeouts and apply their usage accr…
camilamacedo86 Oct 22, 2025
ec5a401
UPSTREAM: <carry>: Update to new feature-gate options in helm
tmshort Oct 22, 2025
df6d7d4
UPSTREAM: <carry>: Fix flake for single/own ns tests by ensuring uniq…
camilamacedo86 Oct 22, 2025
27c04e5
UPSTREAM: <carry>: [OTE]: Enhance single/own ns based on review comme…
camilamacedo86 Oct 24, 2025
9393d7f
UPSTREAM: <carry>: Update OwnSingle template to use spec.config.inlin…
kuiwang02 Nov 3, 2025
1a4b54e
UPSTREAM: <carry>: [OTE]: Add webhook cleanup validation on extension…
camilamacedo86 Nov 4, 2025
be96547
UPSTREAM: <carry>: Add [OTP] to migrated cases
kuiwang02 Nov 7, 2025
f3f9743
UPSTREAM: <carry>: [OTE]: Upgrade dependencies used
camilamacedo86 Nov 5, 2025
0ae57c7
UPSTREAM: <carry>: fix(OTE): fix OpenShift Kubernetes replace version…
camilamacedo86 Nov 10, 2025
31c8501
UPSTREAM: <carry>: [Default Catalog Tests] Upgrade go 1.24.6 and depe…
camilamacedo86 Nov 11, 2025
f7ae9c3
UPSTREAM: <carry>: add disconnected environment support with custom p…
kuiwang02 Nov 12, 2025
63848dc
UPSTREAM: <carry>: migrate jiazha test cases to OTE
jianzhangbjz Nov 14, 2025
bac284b
UPSTREAM: <carry>: migrate clustercatalog case to ote
Xia-Zhao-rh Oct 17, 2025
7ad780d
UPSTREAM: <carry>: migrate olmv1 QE stress cases
kuiwang02 Nov 20, 2025
e037806
UPSTREAM: <carry>: Use busybox/httpd to simulate probes
tmshort Nov 25, 2025
ed96aa9
UPSTREAM: <carry>: migrate olmv1 QE cases
Xia-Zhao-rh Nov 25, 2025
71859c9
UPSTREAM: <carry>: add agent for olmv1 qe cases
kuiwang02 Oct 21, 2025
e4972ac
UPSTREAM: <drop>: go mod vendor
Dec 2, 2025
0176527
UPSTREAM: <drop>: remove upstream GitHub configuration
Dec 2, 2025
f45bd14
UPSTREAM: <drop>: configure the commit-checker
Dec 2, 2025
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
Prev Previous commit
Next Next commit
UPSTREAM: <carry>: [OTE]: Add webhook cleanup validation on extension…
… uninstall

Assisted-by: Cursor
  • Loading branch information
camilamacedo86 authored and ci-robot committed Dec 2, 2025
commit 1a4b54ed4345afe15a2f8f7f1be4a0314322d959
Original file line number Diff line number Diff line change
Expand Up @@ -590,5 +590,15 @@
"source": "openshift:payload:olmv1",
"lifecycle": "blocking",
"environmentSelector": {}
},
{
"name": "[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServiceCA] OLMv1 operator with webhooks should clean up webhooks when the extension is uninstalled [Serial]",
"labels": {},
"resources": {
"isolation": {}
},
"source": "openshift:payload:olmv1",
"lifecycle": "blocking",
"environmentSelector": {}
}
]
2 changes: 2 additions & 0 deletions openshift/tests-extension/pkg/env/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
configv1 "github.com/openshift/api/config/v1"
imagev1 "github.com/openshift/api/image/v1"
operatorv1 "github.com/openshift/api/operator/v1"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -88,6 +89,7 @@ func initTestEnv() *TestEnv {
utilruntime.Must(rbacv1.AddToScheme(scheme))
utilruntime.Must(batchv1.AddToScheme(scheme))
utilruntime.Must(apiextensionsv1.AddToScheme(scheme))
utilruntime.Must(admissionregistrationv1.AddToScheme(scheme))
utilruntime.Must(olmv1.AddToScheme(scheme))

if isOcp {
Expand Down
140 changes: 140 additions & 0 deletions openshift/tests-extension/test/webhooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
//nolint:staticcheck // ST1001: dot-imports for readability
. "github.com/onsi/gomega"

admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -64,6 +65,8 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServi

By("ensuring no ClusterExtension and CRD from a previous run")
helpers.EnsureCleanupClusterExtension(ctx, webhookOperatorPackageName, webhookOperatorCRDName)
By("ensuring no stale webhook configurations from previous tests")
ensureCleanupWebhookConfigurations(ctx, k8sClient, "vwebhooktest", "mwebhooktest")

// Build webhook operator bundle and catalog using the consolidated helper
// Note: {{ TEST-BUNDLE }} and {{ NAMESPACE }} will be auto-filled
Expand Down Expand Up @@ -237,8 +240,145 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMWebhookProviderOpenshiftServi
g.Expect(client.IgnoreNotFound(err)).ToNot(HaveOccurred(), fmt.Sprintf("failed to delete test resource %s: %v", resourceName, err))
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
})

// Test that OLMv1 cleans up webhook configurations when an extension is uninstalled.
// This validates that no webhook configurations are left behind after ClusterExtension deletion.
It("should clean up webhooks when the extension is uninstalled [Serial]", func(ctx SpecContext) {
By("verifying that the webhook operator's webhooks are present")
Eventually(func(g Gomega) {
whList := &admissionregistrationv1.ValidatingWebhookConfigurationList{}
err := k8sClient.List(ctx, whList)
g.Expect(err).ToNot(HaveOccurred(), "failed to list ValidatingWebhookConfigurations")
operatorWebhookFound := false
for _, wh := range whList.Items {
if strings.HasPrefix(wh.Name, "vwebhooktest") {
operatorWebhookFound = true
break
}
}
g.Expect(operatorWebhookFound).To(BeTrue(), "operator validating webhooks should exist")
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())

By("verifying that the webhook operator's mutating webhooks are present")
Eventually(func(g Gomega) {
mwhList := &admissionregistrationv1.MutatingWebhookConfigurationList{}
err := k8sClient.List(ctx, mwhList)
g.Expect(err).ToNot(HaveOccurred(), "failed to list MutatingWebhookConfigurations")
operatorMutatingWebhookFound := false
for _, mwh := range mwhList.Items {
if strings.HasPrefix(mwh.Name, "mwebhooktest") {
operatorMutatingWebhookFound = true
break
}
}
g.Expect(operatorMutatingWebhookFound).To(BeTrue(), "operator mutating webhooks should exist")
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())

By("uninstalling the ClusterExtension")
ceName := webhookOperatorInstallNamespace
ce := &olmv1.ClusterExtension{
ObjectMeta: metav1.ObjectMeta{Name: ceName},
}
err := k8sClient.Delete(ctx, ce, client.PropagationPolicy(metav1.DeletePropagationBackground))
Expect(err).ToNot(HaveOccurred(), "failed to delete ClusterExtension")

By("waiting for ClusterExtension to be fully deleted")
Eventually(func(g Gomega) {
tempCE := &olmv1.ClusterExtension{}
err := k8sClient.Get(ctx, client.ObjectKey{Name: ceName}, tempCE)
g.Expect(apierrors.IsNotFound(err)).To(BeTrue(), "ClusterExtension should be deleted")
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())

By("verifying that operator-created webhook configurations are cleaned up")
Eventually(func(g Gomega) {
whList := &admissionregistrationv1.ValidatingWebhookConfigurationList{}
err := k8sClient.List(ctx, whList)
g.Expect(err).ToNot(HaveOccurred(), "failed to list ValidatingWebhookConfigurations")
operatorWebhookFound := false
for _, wh := range whList.Items {
if strings.HasPrefix(wh.Name, "vwebhooktest") {
operatorWebhookFound = true
break
}
}
g.Expect(operatorWebhookFound).To(BeFalse(), "operator validating webhooks should be deleted")
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())

By("verifying that mutating webhook configurations are cleaned up")
Eventually(func(g Gomega) {
mwhList := &admissionregistrationv1.MutatingWebhookConfigurationList{}
err := k8sClient.List(ctx, mwhList)
g.Expect(err).ToNot(HaveOccurred(), "failed to list MutatingWebhookConfigurations")
operatorMutatingWebhookFound := false
for _, mwh := range mwhList.Items {
if strings.HasPrefix(mwh.Name, "mwebhooktest") {
operatorMutatingWebhookFound = true
break
}
}
g.Expect(operatorMutatingWebhookFound).To(BeFalse(), "operator mutating webhooks should be deleted")
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())

})
})

func ensureCleanupWebhookConfigurations(ctx context.Context, k8sClient client.Client, validatingPrefix, mutatingPrefix string) {
// Clean up any stale validating webhooks
whList := &admissionregistrationv1.ValidatingWebhookConfigurationList{}
if err := k8sClient.List(ctx, whList); err == nil {
for _, wh := range whList.Items {
if validatingPrefix != "" && strings.HasPrefix(wh.Name, validatingPrefix) {
By(fmt.Sprintf("deleting stale validating webhook: %s", wh.Name))
if err := k8sClient.Delete(ctx, &wh, client.PropagationPolicy(metav1.DeletePropagationBackground)); err != nil && !apierrors.IsNotFound(err) {
fmt.Fprintf(GinkgoWriter, "Warning: Failed to delete stale validating webhook %s: %v\n", wh.Name, err)
}
}
}
} else if !apierrors.IsNotFound(err) {
fmt.Fprintf(GinkgoWriter, "Warning: Failed to list ValidatingWebhookConfigurations during cleanup: %v\n", err)
}

// Clean up any stale mutating webhooks
mwhList := &admissionregistrationv1.MutatingWebhookConfigurationList{}
if err := k8sClient.List(ctx, mwhList); err == nil {
for _, mwh := range mwhList.Items {
if mutatingPrefix != "" && strings.HasPrefix(mwh.Name, mutatingPrefix) {
By(fmt.Sprintf("deleting stale mutating webhook: %s", mwh.Name))
if err := k8sClient.Delete(ctx, &mwh, client.PropagationPolicy(metav1.DeletePropagationBackground)); err != nil && !apierrors.IsNotFound(err) {
fmt.Fprintf(GinkgoWriter, "Warning: Failed to delete stale mutating webhook %s: %v\n", mwh.Name, err)
}
}
}
} else if !apierrors.IsNotFound(err) {
fmt.Fprintf(GinkgoWriter, "Warning: Failed to list MutatingWebhookConfigurations during cleanup: %v\n", err)
}

// Verify all stale webhooks are gone
Eventually(func(g Gomega) {
whList := &admissionregistrationv1.ValidatingWebhookConfigurationList{}
err := k8sClient.List(ctx, whList)
g.Expect(err).ToNot(HaveOccurred(), "failed to list ValidatingWebhookConfigurations")
staleWebhooks := []string{}
for _, wh := range whList.Items {
if validatingPrefix != "" && strings.HasPrefix(wh.Name, validatingPrefix) {
staleWebhooks = append(staleWebhooks, wh.Name)
}
}
g.Expect(staleWebhooks).To(BeEmpty(), "stale validating webhooks still exist: %v", staleWebhooks)

mwhList := &admissionregistrationv1.MutatingWebhookConfigurationList{}
err = k8sClient.List(ctx, mwhList)
g.Expect(err).ToNot(HaveOccurred(), "failed to list MutatingWebhookConfigurations")
staleMutatingWebhooks := []string{}
for _, mwh := range mwhList.Items {
if mutatingPrefix != "" && strings.HasPrefix(mwh.Name, mutatingPrefix) {
staleMutatingWebhooks = append(staleMutatingWebhooks, mwh.Name)
}
}
g.Expect(staleMutatingWebhooks).To(BeEmpty(), "stale mutating webhooks still exist: %v", staleMutatingWebhooks)
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
}

var webhookTestV1 = schema.GroupVersionResource{
Group: "webhook.operators.coreos.io",
Version: "v1",
Expand Down