Skip to content

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

Open
savio87 wants to merge 1 commit into
openshift:mainfrom
savio87:OCPBUGS-61061
Open

OCPBUGS-61061: add blank line before error in upgrade recommend --version output#2338
savio87 wants to merge 1 commit 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 upgrade recommendation output formatting by adding spacing before error messages and numbered entries.
    • Non-quiet mode now clearly separates unaccepted issue details from the resulting error.
  • Tests
    • Updated upgrade recommendation examples to reflect the improved output formatting across supported scenarios.

@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

Walkthrough

The upgrade recommendation command now prints a blank line before unaccepted issue errors in non-quiet mode. Five output fixtures reflect this formatting.

Changes

Upgrade recommendation output

Layer / File(s) Summary
Recommendation output spacing
pkg/cli/admin/upgrade/recommend/recommend.go, pkg/cli/admin/upgrade/recommend/examples/*
Non-quiet output adds a blank line before unaccepted issue errors. Five recommendation output fixtures include the matching blank lines.

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

Possibly related PRs

  • openshift/oc#2336: Modifies recommend.go and related upgrade recommendation fixtures for unaccepted upgrade risks.

Suggested reviewers: hongkailiu, nbottari9

🚥 Pre-merge checks | ✅ 5 | ❌ 10

❌ Failed checks (10 inconclusive)

Check name Status Explanation Resolution
Stable And Deterministic Test Names ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Test Structure And Quality ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Microshift Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Single Node Openshift (Sno) Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Topology-Aware Scheduling Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Ote Binary Stdout Contract ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Ipv6 And Disconnected Network Test Compatibility ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Weak-Crypto ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Container-Privileges ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Sensitive-Data-In-Logs ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (5 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: adding a blank line before the error output in upgrade recommendation commands.
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.
✨ 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?

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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants