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: guard empty webhooks slice in getWebhookCABundle - #3951
Both the mutating and validating arms now also require len(existingWebhooks.Items[0].Webhooks) > 0. When the matching webhook configuration carries no webhooks, the function falls through to its existing unable to find CA error instead of panicking, and the caller wraps it as could not retrieve caBundle for WebhookDescription <name> — the same result as a missing configuration.
Motivation for the change:
A ValidatingWebhookConfiguration or MutatingWebhookConfiguration that still matches OLM's owner and olm.webhook-description-generate-name labels but has an empty Webhooks slice — hand-edited, partially applied, or left behind by an older OLM version — panics the OLM operator via updateDeploymentSpecsWithAPIServiceData → getWebhookCABundle on the CSV reconcile path. The result is a crashloop, so a single stale object takes down CSV management cluster-wide.
Architectural changes:
None. The two duplicated switch arms are left as they are; folding them behind a shared helper would be a refactor this maintenance-mode change does not need.
Testing remarks:
Three cases added to the existing TestWebhookCABundleRetrieval table in pkg/controller/operators/olm/operator_test.go:
FailFromValidatingAdmissionWebhookWithNoWebhooks
FailFromMutatingAdmissionWebhookWithNoWebhooks
MissingMutatingCAResource (the mutating arm previously had no missing-configuration case; only the validating arm did)
With the guard reverted, FailFromValidatingAdmissionWebhookWithNoWebhooks reproduces the defect: panic: runtime error: index out of range [0] with length 0. With the guard it returns unable to find CA. go test ./pkg/controller/operators/olm/ -race -count=1 passes (275 tests); gofmt and go vet clean. make lint cannot run in my environment due to a pre-existing toolchain export-data version mismatch unrelated to this diff.
Reviewer Checklist
Implementation matches the proposed design, or proposal is updated to match implementation
Sufficient unit test coverage
Sufficient end-to-end test coverage
Bug fixes are accompanied by regression test(s)
e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
Docs updated or added to /doc
Commit messages sensible and descriptive
Tests marked as [FLAKE] are truly flaky and have an issue
Code is properly formatted
Summary by CodeRabbit
Bug Fixes
Corrected webhook CA bundle handling when a matching configuration has no webhooks or no CA resource. These cases now return the existing missing-CA error instead of attempting to access an empty webhook list.
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:
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 be30461 and 9597f08.
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 CA bundle retrieval now checks that the matching configuration contains a webhook before reading its CA bundle. Tests cover missing configurations and empty webhook lists.
Changes: Webhook CA bundle lookup
Layer / File(s)
Summary
Guard webhook CA bundle access pkg/controller/operators/olm/apiservices.go, pkg/controller/operators/olm/operator_test.go
The mutating and validating lookups check for a non-empty webhook list before accessing the first webhook’s CA bundle. Tests verify that missing configurations and empty lists return a nil bundle and missingCAError.
The empty-webhook panic is prevented for both validating and mutating configurations, with focused test coverage.
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 and concisely describes the main change: preventing an empty webhooks slice from being indexed in getWebhookCABundle.
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 1 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: d2f0f60e-42f7-477e-9b15-5fcc639a3fac
Commits
Reviewing files that changed from the base of the PR and between e046b5c and 6ea7b8e.
Files selected for processing: 2
pkg/controller/operators/olm/apiservices.go
pkg/controller/operators/olm/operator_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.
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
Nov 23, 2026
getWebhookCABundle indexes existingWebhooks.Items[0].Webhooks[0] after
checking only that Items is non-empty. A webhook configuration that
matches the OLM owner and generate-name labels but carries no webhooks
(hand-edited, partially applied, or left behind by an older OLM version)
panics the OLM operator on the CSV reconcile path, turning a single stale
object into a crashloop.
Require a non-empty Webhooks slice before indexing so the function falls
through to its existing "unable to find CA" error, matching the behavior
for a missing configuration.
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:
getWebhookCABundleguards only the outer slice before indexing the inner one:Both the mutating and validating arms now also require
len(existingWebhooks.Items[0].Webhooks) > 0. When the matching webhook configuration carries no webhooks, the function falls through to its existingunable to find CAerror instead of panicking, and the caller wraps it ascould not retrieve caBundle for WebhookDescription <name>— the same result as a missing configuration.Motivation for the change:
A
ValidatingWebhookConfigurationorMutatingWebhookConfigurationthat still matches OLM's owner andolm.webhook-description-generate-namelabels but has an emptyWebhooksslice — hand-edited, partially applied, or left behind by an older OLM version — panics the OLM operator viaupdateDeploymentSpecsWithAPIServiceData→getWebhookCABundleon the CSV reconcile path. The result is a crashloop, so a single stale object takes down CSV management cluster-wide.Architectural changes:
None. The two duplicated switch arms are left as they are; folding them behind a shared helper would be a refactor this maintenance-mode change does not need.
Testing remarks:
Three cases added to the existing
TestWebhookCABundleRetrievaltable inpkg/controller/operators/olm/operator_test.go:FailFromValidatingAdmissionWebhookWithNoWebhooksFailFromMutatingAdmissionWebhookWithNoWebhooksMissingMutatingCAResource(the mutating arm previously had no missing-configuration case; only the validating arm did)With the guard reverted,
FailFromValidatingAdmissionWebhookWithNoWebhooksreproduces the defect:panic: runtime error: index out of range [0] with length 0. With the guard it returnsunable to find CA.go test ./pkg/controller/operators/olm/ -race -count=1passes (275 tests);gofmtandgo vetclean.make lintcannot run in my environment due to a pre-existing toolchain export-data version mismatch unrelated to this diff.Reviewer Checklist
/doc[FLAKE]are truly flaky and have an issueSummary by CodeRabbit