Skip to content

CNF-23437: Wrap bare error returns for better debuggability#6319

Open
sebrandon1 wants to merge 1 commit into
openshift-kni:mainfrom
sebrandon1:CNF-23437
Open

CNF-23437: Wrap bare error returns for better debuggability#6319
sebrandon1 wants to merge 1 commit into
openshift-kni:mainfrom
sebrandon1:CNF-23437

Conversation

@sebrandon1
Copy link
Copy Markdown
Contributor

Summary

  • Wrap 20 bare return err statements with fmt.Errorf("context: %w", err) across 5 files
  • Improves error traceability in logs — when errors surface at the controller level, the full call chain is now visible
  • No behavior change; errors are wrapped with %w so errors.Is/errors.As still work

Test plan

  • go build ./... — compiles
  • go test ./controllers/... ./internal/clusterconfig/... — all tests pass
  • make golangci-lint — 0 issues

Jira: https://redhat.atlassian.net/browse/CNF-23437

@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented May 1, 2026

@sebrandon1: This pull request references CNF-23437 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

  • Wrap 20 bare return err statements with fmt.Errorf("context: %w", err) across 5 files
  • Improves error traceability in logs — when errors surface at the controller level, the full call chain is now visible
  • No behavior change; errors are wrapped with %w so errors.Is/errors.As still work

Test plan

  • go build ./... — compiles
  • go test ./controllers/... ./internal/clusterconfig/... — all tests pass
  • make golangci-lint — 0 issues

Jira: https://redhat.atlassian.net/browse/CNF-23437

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
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 1, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign imiller0 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:

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

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 1, 2026

Review Change Stack

Warning

Review limit reached

@sebrandon1, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 44 minutes and 37 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 4e9aad05-f7bb-45a8-adca-955fd948a7c1

📥 Commits

Reviewing files that changed from the base of the PR and between ecaa9e3 and 73b9a52.

📒 Files selected for processing (5)
  • controllers/ipc_config_handlers.go
  • controllers/ipc_idle_handlers.go
  • controllers/ipc_rollback_handlers.go
  • internal/clusterconfig/clusterconfig.go
  • internal/clusterconfig/lvmconfig.go
📝 Walkthrough

Walkthrough

This PR replaces direct error returns with contextual wrapped errors (using %w) across IPC controller handlers and cluster configuration/LVM fetch functions.

Changes

Controller handlers

Layer / File(s) Summary
Validation & cleanup error wrapping
controllers/ipc_config_handlers.go, controllers/ipc_idle_handlers.go, controllers/ipc_rollback_handlers.go
validateAddressChanges, idle cleanup, and rollback start validation now wrap underlying errors with contextual messages while preserving error chains.

Cluster configuration

Layer / File(s) Summary
FetchClusterConfig and helpers
internal/clusterconfig/clusterconfig.go
FetchClusterConfig, fetchClusterInfo, fetchIDMS, and fetchICSPs now return errors wrapped with specific failed to ...: %w messages; per-ICSP errors include the ICSP name.

LVM configuration

Layer / File(s) Summary
FetchLvmConfig error wrapping
internal/clusterconfig/lvmconfig.go
FetchLvmConfig wraps errors from fetchLvmDevices and fetchLocalVolumes with contextual messages using %w.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: wrapping bare error returns with context for improved debuggability.
Description check ✅ Passed The description provides a clear summary, test plan, and Jira link, but lacks detailed context and implementation details suggested by the template.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/clusterconfig/clusterconfig.go`:
- Around line 77-78: FetchClusterConfig wraps fetchIDMS but fetchIDMS currently
drops the original error; update fetchIDMS to return a wrapped error using
fmt.Errorf with %w (e.g., fmt.Errorf("failed to fetch IDMS: %w", err)) so the
original error chain is preserved when FetchClusterConfig returns. Locate the
fetchIDMS function and replace the plain error construction that loses the root
cause with a wrapped error that includes the original err.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: dbf7ea15-a7cc-4875-9301-a649b953df30

📥 Commits

Reviewing files that changed from the base of the PR and between 8954604 and 9dad0c9.

📒 Files selected for processing (5)
  • controllers/ipc_config_handlers.go
  • controllers/ipc_idle_handlers.go
  • controllers/ipc_rollback_handlers.go
  • internal/clusterconfig/clusterconfig.go
  • internal/clusterconfig/lvmconfig.go

Comment thread internal/clusterconfig/clusterconfig.go
@sebrandon1
Copy link
Copy Markdown
Contributor Author

/retest ci/prow/ipc-e2e-flow

@sebrandon1
Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@sebrandon1
Copy link
Copy Markdown
Contributor Author

/retest

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

Actionable comments posted: 0

Wrap 20 bare `return err` statements with fmt.Errorf context
in controllers/ and internal/clusterconfig/ so that errors
surfacing at the controller level carry the full call chain
for easier debugging in logs.
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 29, 2026

@sebrandon1: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ibu-e2e-flow-v6v4 73b9a52 link false /test ibu-e2e-flow-v6v4
ci/prow/ibi-e2e-flow-v4v6 73b9a52 link false /test ibi-e2e-flow-v4v6
ci/prow/ibu-e2e-flow 73b9a52 link false /test ibu-e2e-flow
ci/prow/ipc-e2e-flow-v6v4 73b9a52 link false /test ipc-e2e-flow-v6v4
ci/prow/ibu-e2e-flow-v4v6 73b9a52 link false /test ibu-e2e-flow-v4v6
ci/prow/ipc-e2e-flow 73b9a52 link true /test ipc-e2e-flow
ci/prow/ibi-e2e-flow-v6v4 73b9a52 link false /test ibi-e2e-flow-v6v4
ci/prow/ibi-e2e-flow 73b9a52 link false /test ibi-e2e-flow
ci/prow/ipc-e2e-flow-v4v6 73b9a52 link false /test ipc-e2e-flow-v4v6

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants