Skip to content

NO-JIRA: Use %w for error wrapping consistently#946

Merged
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
tchap:fix/error-wrapping
Jun 29, 2026
Merged

NO-JIRA: Use %w for error wrapping consistently#946
openshift-merge-bot[bot] merged 1 commit into
openshift:mainfrom
tchap:fix/error-wrapping

Conversation

@tchap

@tchap tchap commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Replace %v with %w in fmt.Errorf calls that wrap errors, enabling errors.Is/As unwrapping throughout the operator. Also fix a stray extra space in csrcontroller.go ("failed with : " -> "failed with: ").

This is fixing issues found when creating #945 . This is fixing error wrapping that is against conventions.

Summary by CodeRabbit

  • Bug Fixes
    • Improved error reporting across several controller and rendering paths by preserving underlying error details.
    • Standardized a few log/error messages for cleaner, more consistent output.
    • Enhanced troubleshooting for config parsing, alert queries, secret access, and policy/config generation failures.

Replace %v with %w in fmt.Errorf calls that wrap errors, enabling
errors.Is/As unwrapping throughout the operator. Also fix a stray
extra space in csrcontroller.go ("failed with : " -> "failed with: ").
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jun 26, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@tchap: This pull request explicitly references no jira issue.

Details

In response to this:

Replace %v with %w in fmt.Errorf calls that wrap errors, enabling errors.Is/As unwrapping throughout the operator. Also fix a stray extra space in csrcontroller.go ("failed with : " -> "failed with: ").

This is fixing issues found when creating #945 . This is fixing error wrapping that is against conventions.

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 openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: ed2cbbe0-0e10-496c-bd95-36d3c0ebd756

📥 Commits

Reviewing files that changed from the base of the PR and between c35307f and c3f74d9.

📒 Files selected for processing (4)
  • pkg/cmd/recoverycontroller/csrcontroller.go
  • pkg/cmd/render/render.go
  • pkg/operator/gcwatchercontroller/gcwatcher_controller.go
  • pkg/operator/targetconfigcontroller/targetconfigcontroller.go

Walkthrough

This pull request updates several error paths to wrap underlying failures with %w and adjusts one CSR controller log message formatting. Control flow is otherwise unchanged.

Changes

Error wrapping and log formatting

Layer / File(s) Summary
Command error reporting
pkg/cmd/render/render.go, pkg/cmd/recoverycontroller/csrcontroller.go
renderOpts.Run now wraps restricted CIDR parsing, FeatureGate lookup, kube-controller-manager config unmarshal, bootstrap kubeconfig read, and merged config write errors; CSRController.processNextItem removes the extra space in its failure log message.
Alert query wrapping
pkg/operator/gcwatchercontroller/gcwatcher_controller.go
getAlertingRulesCached and checkFiringAlerts now wrap Prometheus query errors with %w.
Target config setup
pkg/operator/targetconfigcontroller/targetconfigcontroller.go
isRequiredConfigPresent wraps config parse and path lookup failures, and createTargetConfigController wraps managed-resource and override-processing errors.
Target config runtime
pkg/operator/targetconfigcontroller/targetconfigcontroller.go
removeCloudControllerOwnerCondition and managePod wrap operator-state lookup, YAML parsing, field extraction, and proxy config errors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 15
✅ Passed checks (15 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: standardizing error wrapping with %w across the operator.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed No test files or Ginkgo titles were changed; the touched files are production code only.
Test Structure And Quality ✅ Passed PASS: The PR only changes non-test Go files; no _test.go or Ginkgo blocks were touched, so this test-quality check is not applicable.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the touched files only change error wrapping/formatting in controller code.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the PR only changes controller/render error wrapping and a log message.
Topology-Aware Scheduling Compatibility ✅ Passed Only error-wrapping/formatting changes were made in controller/render code; no scheduling, replica, affinity, nodeSelector, or topology logic was introduced.
Ote Binary Stdout Contract ✅ Passed Touched files only change error wrapping/formatting; no fmt.Print, os.Stdout, init/main/TestMain, or suite setup writes were added in process-level code.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed New Ginkgo e2e tests were added, but they only use cluster-internal clients/resources and show no hardcoded IPv4 or public-internet dependencies.
No-Weak-Crypto ✅ Passed Changed hunks are error-wrapping only; scans found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB or constant-time comparison issues.
Container-Privileges ✅ Passed PASS: The PR only changes Go error-wrapping/formatting in four source files; no K8s/container manifests or privilege settings were added or modified.
No-Sensitive-Data-In-Logs ✅ Passed Only error-wrap/formatting changes were made; no new logging of passwords, tokens, PII, hostnames, or customer data appears in the touched code.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@tchap

tchap commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci

openshift-ci Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

@tchap: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 understand the commands that are listed here.

@everettraven everettraven left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

/lgtm
/approve

@tchap

tchap commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jun 29, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@tchap: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jun 29, 2026
@openshift-ci

openshift-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: everettraven

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

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 29, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit 8bef981 into openshift:main Jun 29, 2026
13 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. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants