Skip to content

Conversation

@arnavgogia20
Copy link

@arnavgogia20 arnavgogia20 commented Jan 26, 2026

What type of PR is this?
/kind bug

What this PR does / why we need it:
This PR reduces the log verbosity of the init() function in operator/pkg/apis/operator/v1alpha1/defaults.go from Info to V(4). Previously, importing this package would unconditionally print the "default Karmada Image Version" log, causing unwanted noise for downstream consumers. A comment has been added to explain this decision.

Which issue(s) this PR fixes:
Fixes #6957

Special notes for your reviewer:
None

Does this PR introduce a user-facing change?:
NONE

@karmada-bot
Copy link
Contributor

Welcome @arnavgogia20! It looks like this is your first PR to karmada-io/karmada 🎉

@gemini-code-assist
Copy link

Summary of Changes

Hello @arnavgogia20, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an issue where importing Karmada operator API types would unconditionally emit an Info-level log message during package initialization. This behavior is undesirable for a library package as it creates unsolicited noise for consumers. The change modifies the log statement to use a verbose log level (klog.V(4)), ensuring it is only emitted when explicitly enabled, thereby aligning with standard Go and Kubernetes logging practices and improving the library's import behavior.

Highlights

  • Logging Verbosity: Reduced the log verbosity in the init() function within the operator API types to klog.V(4).
  • Functional Behavior: No functional behavior or APIs were modified as part of this change.
  • Configuration: No additional configuration or flags were introduced.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@karmada-bot karmada-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jan 26, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses an issue where logging during package initialization was causing undesirable side effects for consumers. By changing the log level from Info to V(4), the log message will now only appear when verbose logging is explicitly enabled, which is the correct behavior for a library package. I've added one suggestion to make the code comment more descriptive, aligning it better with the repository's style guide. Overall, this is a valuable improvement.

}
DefaultKarmadaImageVersion = releaseVer.ReleaseVersion()
klog.Infof("default Karmada Image Version: %s", DefaultKarmadaImageVersion)
// Use V(4) to avoid pollution during init

Choose a reason for hiding this comment

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

medium

While the comment is helpful, it could be more descriptive to better align with the style guide's preference for comments that thoroughly explain the 'why'. A more detailed comment would better clarify why logging during init is being avoided.

Suggested change
// Use V(4) to avoid pollution during init
// Use a verbose log level to avoid side effects (unconditional logging) for consumers importing this package.
References
  1. The style guide encourages comments that explain the intention of the code, rather than just stating the obvious. The provided examples show a preference for more descriptive comments explaining the rationale. (link)

Copy link
Member

Choose a reason for hiding this comment

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

This comment seems reasonable.

Copy link
Author

Choose a reason for hiding this comment

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

This comment seems reasonable.

Yes, i've done it, pls check....thankyouu

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 46.55%. Comparing base (437e37e) to head (9ad5262).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
operator/pkg/apis/operator/v1alpha1/defaults.go 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #7132   +/-   ##
=======================================
  Coverage   46.54%   46.55%           
=======================================
  Files         700      700           
  Lines       48134    48136    +2     
=======================================
+ Hits        22403    22408    +5     
+ Misses      24045    24043    -2     
+ Partials     1686     1685    -1     
Flag Coverage Δ
unittests 46.55% <0.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@arnavgogia20
Copy link
Author

Hii @lonelyCZ @calvin0327, may you please consider reviewing this PR, thankyouu

@RainbowMango RainbowMango added this to the v1.17 milestone Jan 26, 2026
@RainbowMango
Copy link
Member

@arnavgogia20 Could you please use the template for PR description?

In addition, please squash your commits after fixing the comments.

The init function logs the Karmada image version at Info level, which causes noise during import. This change reduces the log level to V(4) and adds a descriptive comment to explain the decision, preventing side effects for downstream consumers.

Signed-off-by: arnavgogia20 <arnavgogia404@gmail.com>
@arnavgogia20 arnavgogia20 force-pushed the fix/issue-6957-log-noise branch from 4985ef7 to d910185 Compare January 26, 2026 06:36
@arnavgogia20
Copy link
Author

arnavgogia20 commented Jan 26, 2026

@arnavgogia20 Could you please use the template for PR description?

In addition, please squash your commits after fixing the comments.

@RainbowMango Yes, i'm done with both these fixes aswell, kindly check....thankyouu

Relaxes a strict monotonic time check in TestGracefulEvictionRateLimiter_ExponentialBackoff that causes failures in CI environments with high CPU contention.

Signed-off-by: arnavgogia20 <arnavgogia404@gmail.com>
@karmada-bot
Copy link
Contributor

[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 mszacillo, rainbowmango 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

@karmada-bot karmada-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unexpected log output from the init function when importing Karmada types

4 participants