Skip to content

OCPBUGS-84327: Product-cli missing controller-runtime logger initialization causes noisy warning#8491

Open
amogh-redhat wants to merge 1 commit into
openshift:mainfrom
amogh-redhat:fix-OCPBUGS-84327
Open

OCPBUGS-84327: Product-cli missing controller-runtime logger initialization causes noisy warning#8491
amogh-redhat wants to merge 1 commit into
openshift:mainfrom
amogh-redhat:fix-OCPBUGS-84327

Conversation

@amogh-redhat
Copy link
Copy Markdown

@amogh-redhat amogh-redhat commented May 12, 2026

What this PR does / why we need it:

product-cli/main.go does not initialize the controller-runtime logger, while the hypershift CLI (main.go) properly initializes it at line 43 with ctrl.SetLogger(zap.New(...)). This causes a noisy warning to be emitted during operations like create infra when using the product-cli:

[controller-runtime] log.SetLogger(...) was never called; logs will not be displayed.
The hypershift CLI does not produce this warning because the logger is properly initialized.

Added "ctrl.SetLogger(zap.New(...))." to the product-cli/main.go to fix the above mentioned issue.

Which issue(s) this PR fixes:

Fixes : https://redhat.atlassian.net/browse/OCPBUGS-84327

Special notes for your reviewer:

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Summary by CodeRabbit

  • Chores
    • CLI now initializes structured JSON logging at startup, improving machine-readability and consistency of log output.
    • Timestamps in logs use RFC3339 formatting for better interoperability and easier correlation across systems.
    • Result: clearer, more parseable logs to aid debugging and monitoring of CLI behavior.

@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 openshift-ci Bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 12, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

Please specify an area label

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

coderabbitai Bot commented May 12, 2026

📝 Walkthrough

Walkthrough

The pull request updates product-cli/main.go to configure controller-runtime logging at startup. It adds imports for sigs.k8s.io/controller-runtime and Zap logging (including zapcore) and, in main(), initializes a Zap JSON logger with RFC3339 time encoding and sets it as the controller-runtime logger via ctrl.SetLogger().

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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 Custom check is not applicable. PR modifies only product-cli/main.go for logger initialization. No Ginkgo tests are involved—tests in product-cli use standard Go testing package, not Ginkgo.
Test Structure And Quality ✅ Passed Custom check for Ginkgo test code quality is not applicable. This PR only modifies product-cli/main.go to add controller-runtime logger initialization with no test code changes.
Microshift Test Compatibility ✅ Passed PR modifies product-cli/main.go to initialize controller-runtime logger. No Ginkgo e2e tests are added. Custom check for MicroShift test compatibility is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR only modifies product-cli/main.go to initialize controller-runtime logging. No Ginkgo e2e tests are added, so the SNO test compatibility check is not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies only product-cli/main.go to initialize controller-runtime logger. No deployment manifests, operators, or controllers introducing scheduling constraints are added/modified.
Ote Binary Stdout Contract ✅ Passed The PR initializes zap logging with default stderr output. No WriteTo() option or stdout configuration exists. Initialization produces no output. Matches reference implementation in main.go.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Custom check does not apply. This PR does not add any Ginkgo e2e tests—it only modifies product-cli/main.go to initialize controller-runtime logger.
Title check ✅ Passed The title clearly and specifically describes the main change: adding controller-runtime logger initialization to product-cli to eliminate a warning message.

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

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 39.85%. Comparing base (8c2d0c8) to head (f2285ae).
⚠️ Report is 49 commits behind head on main.

Files with missing lines Patch % Lines
product-cli/main.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8491      +/-   ##
==========================================
+ Coverage   37.55%   39.85%   +2.30%     
==========================================
  Files         751      751              
  Lines       92029    92559     +530     
==========================================
+ Hits        34557    36888    +2331     
+ Misses      54830    52997    -1833     
- Partials     2642     2674      +32     
Files with missing lines Coverage Δ
product-cli/main.go 0.00% <0.00%> (ø)

... and 47 files with indirect coverage changes

Flag Coverage Δ
cmd-support 34.03% <ø> (+1.27%) ⬆️
cpo-hostedcontrolplane 40.52% <ø> (+3.73%) ⬆️
cpo-other 40.08% <ø> (+2.24%) ⬆️
hypershift-operator 50.38% <ø> (+2.44%) ⬆️
other 30.69% <0.00%> (+2.91%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

product-cli's main.go lacks controller-runtime logger initialization,
unlike the hypershift CLI. This generates an unnecessary warning:
"log.SetLogger(...) was never called; logs will not be displayed."
Add structured logging with JSON output and RFC3339 timestamps to
align with the hypershift CLI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@amogh-redhat amogh-redhat marked this pull request as ready for review May 12, 2026 14:23
@openshift-ci openshift-ci Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 12, 2026
@openshift-ci openshift-ci Bot requested review from muraee and sdminonne May 12, 2026 14:24
@muraee
Copy link
Copy Markdown
Contributor

muraee commented May 12, 2026

/approve

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amogh-redhat, muraee

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 May 12, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 12, 2026

@amogh-redhat: 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.

@vsolanki12
Copy link
Copy Markdown
Contributor

/retitle OCPBUGS-84327: Product-cli missing controller-runtime logger initialization causes noisy warning

@openshift-ci openshift-ci Bot changed the title OCPBUGS-84327 : Product-cli missing controller-runtime logger initialization causes noisy warning OCPBUGS-84327: Product-cli missing controller-runtime logger initialization causes noisy warning May 13, 2026
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label May 13, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@amogh-redhat: This pull request references Jira Issue OCPBUGS-84327, which is invalid:

  • expected the bug to target the "5.0.0" version, but no target version was set

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:

What this PR does / why we need it:

product-cli/main.go does not initialize the controller-runtime logger, while the hypershift CLI (main.go) properly initializes it at line 43 with ctrl.SetLogger(zap.New(...)). This causes a noisy warning to be emitted during operations like create infra when using the product-cli:

[controller-runtime] log.SetLogger(...) was never called; logs will not be displayed.
The hypershift CLI does not produce this warning because the logger is properly initialized.

Added "ctrl.SetLogger(zap.New(...))." to the product-cli/main.go to fix the above mentioned issue.

Which issue(s) this PR fixes:

Fixes : https://redhat.atlassian.net/browse/OCPBUGS-84327

Special notes for your reviewer:

Checklist:

  • Subject and description added to both, commit and PR.
  • Relevant issues have been referenced.
  • This change includes docs.
  • This change includes unit tests.

Summary by CodeRabbit

  • Chores
  • CLI now initializes structured JSON logging at startup, improving machine-readability and consistency of log output.
  • Timestamps in logs use RFC3339 formatting for better interoperability and easier correlation across systems.
  • Result: clearer, more parseable logs to aid debugging and monitoring of CLI behavior.

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-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label May 13, 2026
@vsolanki12
Copy link
Copy Markdown
Contributor

/jira refresh

@openshift-ci-robot openshift-ci-robot added jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. and removed jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. labels May 13, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@vsolanki12: This pull request references Jira Issue OCPBUGS-84327, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)
Details

In response to this:

/jira refresh

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.

@hypershift-jira-solve-ci
Copy link
Copy Markdown

Test Failure Analysis Complete

Job Information

  • Prow Job: codecov/patch (Codecov GitHub App check — not a Prow CI job)
  • Build ID: GitHub Check Run 75721875541
  • PR: #8491OCPBUGS-84327: Product-cli missing controller-runtime logger initialization causes noisy warning
  • File Changed: product-cli/main.go (+7 lines, 0 deletions)

Test Failure Analysis

Error

codecov/patch: 0.00% of diff hit (target 37.55%)
3 lines in product-cli/main.go have 0% test coverage.

Summary

The codecov/patch check failed because the 3 new executable lines added inside the main() function of product-cli/main.go are not exercised by any unit test, yielding 0% patch coverage against a 37.55% target. This is a code-coverage gate failure, not a test execution or product failure. The product-cli/main.go file already had 0% overall coverage before this PR — main() entrypoints in Go CLI binaries are structurally not called during go test — so this PR introduces no coverage regression. All other CI checks (build, unit tests, lint, verify, e2e) pass.

Root Cause

The PR adds a ctrl.SetLogger(zap.New(...)) call at the top of main() in product-cli/main.go to initialize controller-runtime logging and suppress a noisy warning. The 3 new executable lines are:

ctrl.SetLogger(zap.New(zap.JSONEncoder(func(o *zapcore.EncoderConfig) {
    o.EncodeTime = zapcore.RFC3339TimeEncoder
})))

Codecov's patch status check measures the percentage of newly added or modified lines that are covered by tests. Because these lines live inside main() — the Go process entrypoint — they are never executed during go test runs. The file's overall coverage was already 0% before this PR (0.00% <0.00%> (ø) — no delta), confirming this is a pre-existing structural gap, not a regression.

The repository's codecov.yml does not define explicit status.patch thresholds or exclusions for CLI entrypoint files. Codecov therefore applies its default behavior: derive the patch target from the project's overall coverage (37.55%). With 0% of the 3 new lines hit, the check fails.

This is a false-positive gate failure. The code change is correct, minimal, and fixes a real user-facing issue (OCPBUGS-84327). The main() function cannot be unit-tested via standard Go patterns without refactoring the logger initialization into a separately callable function — which would be over-engineering for a 3-line fix.

Recommendations
  1. Merge as-is: This is a false-positive coverage failure. The change is correct and all functional checks pass. A maintainer can override or dismiss this non-blocking check.

  2. Optional — suppress future false positives: Add product-cli/main.go to the ignore list in codecov.yml (the file is a CLI entrypoint with no testable logic), similar to other entrypoint files already ignored:

    ignore:
      - "product-cli/main.go"
  3. Optional — configure patch thresholds explicitly: Add a status.patch section to codecov.yml with threshold or target settings to prevent coverage-gate failures on trivially untestable code.

Evidence
Evidence Detail
Check run conclusion failure0.00% of diff hit (target 37.55%)
Lines missing coverage 3 lines in product-cli/main.go (the ctrl.SetLogger(...) block inside main())
File baseline coverage 0.00% — unchanged by this PR ((ø) delta)
Project coverage impact Project coverage increased from 37.55% → 39.85% (+2.30%) overall
Codecov config (codecov.yml) No status.patch threshold defined; product-cli/main.go not in ignore list
Other CI checks All passing — build, unit tests, lint, verify, e2e, CodeRabbit review
Nature of change 3-line logger initialization in main() — a Go CLI entrypoint structurally not exercised by go test

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. do-not-merge/needs-area jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants