You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
olm: return webhook cleanup delete failures instead of swallowing them - #3950
This is the opposite of the convention used everywhere else in the tree (if err != nil && !apierrors.IsNotFound(err)). Negate the condition in both loops (validating and mutating) so that:
a genuine delete failure (Forbidden, Conflict, apiserver 5xx) is returned rather than silently discarded, and
a NotFound delete — the normal benign race where the object is already gone — is treated as success.
Adds TestCleanUpRemovedWebhooks in a new pkg/controller/operators/olm/apiservices_test.go, covering stale validating and mutating config deletion, retention of configs still referenced by the CSV, Forbidden delete failures returning an error with the object left in place, and NotFound being treated as success.
Motivation for the change:
With the inverted check, a failed delete of a ValidatingWebhookConfiguration / MutatingWebhookConfiguration owned by a CSV whose webhook definition was removed is swallowed. The stale config stays registered and keeps intercepting matching CREATE/UPDATE requests after its backing Service is gone — the cluster-wide "failed calling webhook" outage class. In the other direction, a benign NotFound was surfaced as a hard error, causing areWebhooksAvailable to fail and the CSV install to retry pointlessly.
Architectural changes:
None. Error-handling only; no signatures, APIs, or install logic change.
Testing remarks:
go test ./pkg/controller/operators/olm/ -run TestCleanUpRemovedWebhooks -count=1 — passes (6 subtests).
go test ./pkg/controller/operators/olm/... -count=1 — 334 tests pass.
Regression proof: with the pre-fix condition restored, 4 subtests fail (both swallowed-failure cases and both NotFound cases); the fix makes them pass.
go vet ./pkg/controller/operators/olm/ and gofmt are clean. Note make lint in this environment fails repo-wide on a golangci-lint/Go toolchain mismatch (export data version 5 is greater than maximum supported version 2) unrelated to this change.
This is the opposite of the convention used everywhere else in the tree (if err != nil && !apierrors.IsNotFound(err)). Negate the condition in both loops (validating and mutating) so that:
a genuine delete failure (Forbidden, Conflict, apiserver 5xx) is returned rather than silently discarded, and
a NotFound delete — the normal benign race where the object is already gone — is treated as success.
Adds TestCleanUpRemovedWebhooks in a new pkg/controller/operators/olm/apiservices_test.go, covering stale validating and mutating config deletion, retention of configs still referenced by the CSV, Forbidden delete failures returning an error with the object left in place, and NotFound being treated as success.
Motivation for the change:
With the inverted check, a failed delete of a ValidatingWebhookConfiguration / MutatingWebhookConfiguration owned by a CSV whose webhook definition was removed is swallowed. The stale config stays registered and keeps intercepting matching CREATE/UPDATE requests after its backing Service is gone — the cluster-wide "failed calling webhook" outage class. In the other direction, a benign NotFound was surfaced as a hard error, causing areWebhooksAvailable to fail and the CSV install to retry pointlessly.
Architectural changes:
None. Error-handling only; no signatures, APIs, or install logic change.
Testing remarks:
go test ./pkg/controller/operators/olm/ -run TestCleanUpRemovedWebhooks -count=1 — passes (6 subtests).
go test ./pkg/controller/operators/olm/... -count=1 — 334 tests pass.
Regression proof: with the pre-fix condition restored, 4 subtests fail (both swallowed-failure cases and both NotFound cases); the fix makes them pass.
go vet ./pkg/controller/operators/olm/ and gofmt are clean. Note make lint in this environment fails repo-wide on a golangci-lint/Go toolchain mismatch (export data version 5 is greater than maximum supported version 2) unrelated to this change.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
I'm waiting for a operator-framework member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.
Regular contributors should join the org to skip this step.
Once the patch is verified, the new status will be reflected by the ok-to-test label.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.
Reviewing files that changed from the base of the PR and between 32bd2df and 932967e.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
Webhook cleanup now ignores NotFound errors when deleting obsolete validating and mutating webhook configurations. It returns other deletion errors. Added tests cover cleanup outcomes and remaining configurations.
Changes: Webhook Cleanup
Layer / File(s)
Summary
Cleanup behavior and validation pkg/controller/operators/olm/apiservices.go, pkg/controller/operators/olm/apiservices_test.go
Cleanup ignores NotFound deletion errors and returns other deletion errors. Tests cover stale and referenced configurations, forbidden and NotFound errors, and the resulting configuration lists.
No merge-blocking issue is established in the webhook cleanup change.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly describes the main change: webhook cleanup now returns genuine delete failures instead of ignoring them.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 2 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Finishing Touches
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Enterprise
Run ID: ad625a0e-1eea-4ea9-b0f9-85836cf13c17
Commits
Reviewing files that changed from the base of the PR and between e046b5c and 9f187fd.
Files selected for processing: 2
pkg/controller/operators/olm/apiservices.go
pkg/controller/operators/olm/apiservices_test.go
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.
This pull-request has been approved by: Once this PR has been reviewed and has the lgtm label, please assign tmshort for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Details
Needs approval from an approver in each of these files:
openshift-ciBot
added
ok-to-test
Indicates a non-member PR verified by an org member that is safe to test.
and removed
needs-ok-to-test
Indicates a PR that requires an org member to verify it is safe to test.
labels
Dec 1, 2026
cleanUpRemovedWebhooks treated a Delete error as fatal only when it was
a NotFound, which is backwards from the rest of the tree:
if err != nil && apierrors.IsNotFound(err) { return err }
As a result a real delete failure (Forbidden, Conflict, apiserver 5xx)
was silently discarded, leaving a stale ValidatingWebhookConfiguration
or MutatingWebhookConfiguration owned by a CSV whose webhook definition
had been removed. Such a leftover config keeps intercepting matching
CREATE/UPDATE requests after its backing Service is gone, which is the
cluster-wide "failed calling webhook" outage class. Conversely a benign
NotFound (object already deleted) was surfaced as a hard error and made
areWebhooksAvailable retry the CSV install pointlessly.
Negate the condition in both loops so genuine failures propagate and
NotFound is treated as success.
Add TestCleanUpRemovedWebhooks covering stale-config deletion, retention
of configs still referenced by the CSV, Forbidden delete failures, and
NotFound deletes.
Signed-off-by: Brandon Palm <bpalm@redhat.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ok-to-testIndicates a non-member PR verified by an org member that is safe to test.
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the change:
cleanUpRemovedWebhooksguarded both webhook delete loops with an inverted error check:This is the opposite of the convention used everywhere else in the tree (
if err != nil && !apierrors.IsNotFound(err)). Negate the condition in both loops (validating and mutating) so that:Adds
TestCleanUpRemovedWebhooksin a newpkg/controller/operators/olm/apiservices_test.go, covering stale validating and mutating config deletion, retention of configs still referenced by the CSV, Forbidden delete failures returning an error with the object left in place, and NotFound being treated as success.Motivation for the change:
With the inverted check, a failed delete of a
ValidatingWebhookConfiguration/MutatingWebhookConfigurationowned by a CSV whose webhook definition was removed is swallowed. The stale config stays registered and keeps intercepting matching CREATE/UPDATE requests after its backing Service is gone — the cluster-wide "failed calling webhook" outage class. In the other direction, a benign NotFound was surfaced as a hard error, causingareWebhooksAvailableto fail and the CSV install to retry pointlessly.Architectural changes:
None. Error-handling only; no signatures, APIs, or install logic change.
Testing remarks:
go test ./pkg/controller/operators/olm/ -run TestCleanUpRemovedWebhooks -count=1— passes (6 subtests).go test ./pkg/controller/operators/olm/... -count=1— 334 tests pass.go vet ./pkg/controller/operators/olm/andgofmtare clean. Notemake lintin this environment fails repo-wide on a golangci-lint/Go toolchain mismatch (export data version 5 is greater than maximum supported version 2) unrelated to this change.Fixes: https://redhat.atlassian.net/browse/CNF-29070
/cc @sebrandon1
Summary by CodeRabbit
Bug Fixes
Tests