Skip to content

fix(openshift): delete operator webhooks before namespace cleanup on uninstall#3472

Merged
tekton-robot merged 1 commit into
tektoncd:mainfrom
jkhelil:SRVKP-12010
Jun 8, 2026
Merged

fix(openshift): delete operator webhooks before namespace cleanup on uninstall#3472
tekton-robot merged 1 commit into
tektoncd:mainfrom
jkhelil:SRVKP-12010

Conversation

@jkhelil

@jkhelil jkhelil commented Jun 4, 2026

Copy link
Copy Markdown
Member

Problem

When uninstalling via the Console UI, `TektonConfig` finalization calls
`rbac.cleanUp()` which updates user namespaces to strip the
`openshift-pipelines.tekton.dev/namespace-reconcile-version` label.
The `namespace.operator.tekton.dev` ValidatingWebhookConfiguration
intercepts every namespace update and calls the
`tekton-operator-proxy-webhook` service in `openshift-pipelines`.

When the UI removes `openshift-pipelines` before finalization completes,
the VWH still exists (GC lag) but the backend service is already gone:

```
Failed to finalize platform resources failed to update namespace default:
failed calling webhook "namespace.operator.tekton.dev":
service "tekton-operator-proxy-webhook" not found
```

Result: finalization stuck → Subscription/CSV never deleted → operator pod,
deployments, CRDs and ClusterRoles remain in `openshift-operators`.

Root cause

The VWH/MWH are owned by the `openshift-pipelines` Namespace (SRVKP-8901)
and are GC'd when it is deleted — but there is a window where the namespace
is Terminating (services gone) while the webhook configs still exist.
`cleanUp()` namespace updates fail during that window.

Fix

Delete `namespace.operator.tekton.dev` (VWH) and `proxy.operator.tekton.dev`
(MWH) at the start of `openshiftExtension.Finalize`, before
`rbac.cleanUp()` runs. `NotFound` is ignored (already GC'd). The
ownerRef-based GC from SRVKP-8901 is kept as the normal cleanup path.

Also propagate errors from `extension.Finalize` in `FinalizeKind` so the
finalizer retries on failure instead of silently continuing.

Testing

Verified on OpenShift 4.20 (AWS) — installed OSP 1.22.2 via OperatorHub,
patched operator image with this fix, triggered UI uninstall. Confirmed:

  • No `service "tekton-operator-proxy-webhook" not found` errors in logs ✅
  • VWH `namespace.operator.tekton.dev` removed ✅
  • MWH `proxy.operator.tekton.dev` removed ✅
  • Subscription, CSV, operator deployments all removed ✅
  • `openshift-pipelines` namespace removed ✅
  • CRDs remain (expected — OLM does not delete CRDs on uninstall)

Unit tests: `TestRemoveOperatorAdmissionWebhooks` (delete both, already-absent, delete-failure).

Fixes: SRVKP-12010

Made with Cursor

Bug fix: OpenShift Pipelines operator now uninstalls cleanly via the Console UI.
Previously, operator admission webhooks (namespace.operator.tekton.dev,
proxy.operator.tekton.dev) could still be registered while their backend service
was already removed during uninstall, causing TektonConfig finalization to fail
and leaving the Subscription, CSV, and operator deployment behind in
openshift-operators. The webhooks are now explicitly removed at the start of
finalization before namespace label cleanup runs.

@tekton-robot tekton-robot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 4, 2026
@jkhelil

jkhelil commented Jun 4, 2026

Copy link
Copy Markdown
Member Author

/kind bug

@tekton-robot tekton-robot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jun 4, 2026
…uninstall

During TektonConfig finalization, rbac.cleanUp() updates user namespaces
to remove the openshift-pipelines.tekton.dev/namespace-reconcile-version
label. The namespace.operator.tekton.dev ValidatingWebhookConfiguration
intercepts every namespace update and calls the tekton-operator-proxy-webhook
service in openshift-pipelines. When the UI uninstall removes that namespace
(and its webhook service) before finalization completes, the webhook call
fails and cleanUp() cannot finish, leaving the Subscription, CSV, and
operator deployment behind.

Fix: explicitly delete namespace.operator.tekton.dev (VWH) and
proxy.operator.tekton.dev (MWH) at the start of openshiftExtension.Finalize,
before cleanUp() runs. Also propagate the error from extension.Finalize so
FinalizeKind retries instead of silently continuing on failure.

The ownerRef-based GC introduced in SRVKP-8901 remains as the normal cleanup
path; the explicit delete handles the race between namespace termination and
finalization.

Fixes: SRVKP-12010
Co-authored-by: Cursor <cursoragent@cursor.com>
@tekton-robot tekton-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 4, 2026
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 4, 2026
@jkhelil

jkhelil commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

/retest

@pratap0007

Copy link
Copy Markdown
Contributor

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 8, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 8, 2026
@tekton-robot tekton-robot merged commit 62864a7 into tektoncd:main Jun 8, 2026
35 of 37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants