Skip to content

OCPBUGS-61061: add blank line before error in upgrade recommend --version output - #2338

Open
savio87 wants to merge 2 commits into
openshift:mainfrom
savio87:OCPBUGS-61061
Open

OCPBUGS-61061: add blank line before error in upgrade recommend --version output#2338
savio87 wants to merge 2 commits into
openshift:mainfrom
savio87:OCPBUGS-61061

Conversation

@savio87

@savio87 savio87 commented Aug 3, 2026

Copy link
Copy Markdown

Summary

When running oc adm upgrade recommend --version, the conditional-update risk message runs directly into the error line with no visual separation. This adds a blank line between the output and the error to improve readability.

Bug: https://redhat.atlassian.net/browse/OCPBUGS-61061

Changes

  • Added fmt.Fprintln(o.Out) before the error return in the --version path of recommend.go (only when not in quiet mode)
  • Updated 5 golden test fixtures to include the new blank line

Summary by CodeRabbit

  • Bug Fixes
    • Improved non-quiet upgrade recommendation output by adding clearer spacing before error messages.
    • Standardized error formatting when unaccepted issues remain or no updates are available.
  • Tests
    • Updated command output examples to reflect the revised formatting.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels Aug 3, 2026
@openshift-ci-robot

Copy link
Copy Markdown

@savio87: This pull request references Jira Issue OCPBUGS-61061, which is invalid:

  • expected the bug to target either version "5.0." or "openshift-5.0.", but it targets "4.20.z" instead

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

When running oc adm upgrade recommend --version, the conditional-update risk message runs directly into the error line with no visual separation. This adds a blank line between the output and the error to improve readability.

Bug: https://redhat.atlassian.net/browse/OCPBUGS-61061

Changes

  • Added fmt.Fprintln(o.Out) before the error return in the --version path of recommend.go (only when not in quiet mode)
  • Updated 5 golden test fixtures to include the new blank line

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 requested review from atiratree and tchap August 3, 2026 09:13
@openshift-ci

openshift-ci Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 3, 2026
@openshift-ci

openshift-ci Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Hi @savio87. Thanks for your PR.

I'm waiting for a openshift 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.

I understand the commands that are listed here.

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.

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e25e6e4-0d6d-4041-96e7-c6fe32549d5b

📥 Commits

Reviewing files that changed from the base of the PR and between ef45959 and 3217d7f.

📒 Files selected for processing (4)
  • pkg/cli/admin/upgrade/recommend/examples/4.14.1-all-recommended.version-4.12.51-output
  • pkg/cli/admin/upgrade/recommend/examples/4.22.0-extend-recommended-alert.version-1.2.3-not-important-output
  • pkg/cli/admin/upgrade/recommend/examples/4.22.0-extend-recommended-critical-alert.version-1.2.3-not-important-output
  • pkg/cli/admin/upgrade/recommend/examples_test.go
💤 Files with no reviewable changes (3)
  • pkg/cli/admin/upgrade/recommend/examples/4.14.1-all-recommended.version-4.12.51-output
  • pkg/cli/admin/upgrade/recommend/examples/4.22.0-extend-recommended-alert.version-1.2.3-not-important-output
  • pkg/cli/admin/upgrade/recommend/examples/4.22.0-extend-recommended-critical-alert.version-1.2.3-not-important-output

Walkthrough

The recommend command now adds a blank line before unaccepted-issue errors in non-quiet mode. Related output fixtures and test comparisons reflect the adjusted spacing.

Changes

Recommend command output

Layer / File(s) Summary
Align error output and fixtures
pkg/cli/admin/upgrade/recommend/recommend.go, pkg/cli/admin/upgrade/recommend/examples_test.go, pkg/cli/admin/upgrade/recommend/examples/*
Non-quiet output adds a blank separator before unaccepted-issue errors. Expected fixture output removes the preceding newline before error: .

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: atiratree, tchap, hongkailiu

🚥 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 and concisely describes the main change: adding a blank line before the error in upgrade recommend version output.
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 The changed test uses source-controlled fixture paths and fixed variant names for subtests; titles contain no generated suffixes, timestamps, UUIDs, nodes, namespaces, or IPs.
Test Structure And Quality ✅ Passed The changed test uses standard testing.T, not Ginkgo; it uses mock fixtures, creates no cluster resources, has no waits, and includes scoped subtests with diagnostic failure messages.
Microshift Test Compatibility ✅ Passed The pull request adds no Ginkgo e2e tests. The only changed Go test uses standard testing.TestExamples and t.Run, so MicroShift API compatibility checks do not apply.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The patch adds no Ginkgo e2e tests; its only Go change is the standard-library TestExamples fixture harness, so SNO compatibility checks do not apply.
Topology-Aware Scheduling Compatibility ✅ Passed The pull request changes only CLI output formatting, test harness handling, and golden fixtures; it adds no deployment, operator, controller, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed The PR adds fmt.Fprintln(o.Out) inside options.Run and test-buffer handling; it changes no OTE main or suite setup, so it does not corrupt OTE JSON stdout.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The PR adds no Ginkgo e2e tests; its diff only changes CLI logic, Go fixture harness code, and output fixtures, with no IPv4 or external-connectivity assumptions.
No-Weak-Crypto ✅ Passed The complete PR diff only adds a blank-line print and adjusts fixture output; it adds no weak crypto, custom crypto, or secret comparison logic.
Container-Privileges ✅ Passed The complete PR diff adds only output formatting and test-fixture changes; no prohibited privilege setting is added. Existing privileged templates are unchanged.
No-Sensitive-Data-In-Logs ✅ Passed The PR-range diff adds only blank-line output, fixture separators, and test-harness formatting; it introduces no passwords, tokens, keys, PII, or new sensitive-data logging.
✨ 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.

@savio87

savio87 commented Aug 3, 2026

Copy link
Copy Markdown
Author

Hi, this is a small formatting fix that adds a blank line between the conditional-update risk message and the error line in oc adm upgrade recommend --version output.

The Jira issue (OCPBUGS-61061) currently targets 4.20.z, could a maintainer please update the target version to 5.0.0 and run /jira refresh?

Also requesting /ok-to-test when ready. Thanks!

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/cli/admin/upgrade/recommend/recommend.go`:
- Around line 369-371: Update the non-quiet output path in the recommendation
flow to check the error returned by fmt.Fprintln(o.Out), wrap it with context,
and return it before returning the unaccepted-issues failure; preserve the
existing blank-line output behavior when the write succeeds.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f427d4b-1e4b-41b2-bd10-e60e97aa6560

📥 Commits

Reviewing files that changed from the base of the PR and between 86ceecf and ef45959.

📒 Files selected for processing (6)
  • pkg/cli/admin/upgrade/recommend/examples/4.12.16-longest-not-recommended.version-4.12.51-output
  • pkg/cli/admin/upgrade/recommend/examples/4.12.16-longest-recommended.version-4.12.51-output
  • pkg/cli/admin/upgrade/recommend/examples/4.16.27-degraded-monitoring.version-4.16.32-output
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-cvo-handling-risks.version-5.0.0-ec.3-output
  • pkg/cli/admin/upgrade/recommend/examples/5.0.0-cvo-not-handling-risks.version-5.0.0-ec.3-output
  • pkg/cli/admin/upgrade/recommend/recommend.go

Comment thread pkg/cli/admin/upgrade/recommend/recommend.go
@tchap

tchap commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

According to the examples changes this is adding an extra newline where there already is one. Or were the examples wrong?

@savio87

savio87 commented Aug 3, 2026

Copy link
Copy Markdown
Author

Good question! The blank line before error: in the existing fixtures comes from the test harness, not from the actual CLI output. In examples_test.go (line 104), the test joins stdout and error with \nerror: — that \n creates the visual separation you see in the fixtures. But in real CLI usage, Cobra prints the error immediately after stdout with no blank line, so the output looks cramped. This change adds the blank line to the actual program output (via fmt.Fprintln(o.Out)), which means the fixtures now need the extra line to account for both the program's newline and the test harness's newline.

@tchap

tchap commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Could we align the test harness to be consistent with the actual CLI output?

@savio87

savio87 commented Aug 4, 2026

Copy link
Copy Markdown
Author

Good point — I've updated the test harness in examples_test.go to remove the extra \n before error:, so the fixtures now match the actual CLI output. The blank line separation now comes entirely from the program's fmt.Fprintln(o.Out). Pushed in 3217d7f.

@tchap

tchap commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

/ok-to-test

@openshift-ci openshift-ci Bot 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 Aug 4, 2026
@openshift-ci

openshift-ci Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

@savio87: 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.

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

Labels

jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants