feat: Allow making logs less verbose than default#2081
Conversation
|
Hi @tomasaschan. Thanks for your PR. I'm waiting for a GoogleContainerTools member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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/test-infra repository. |
Summary of ChangesHello, 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 enhances logging control within Config Sync by allowing users to reduce log verbosity beyond the default settings. It addresses a critical issue of excessive logging costs by enabling the complete suppression of specific log messages and relaxing CRD validation to support negative log levels, which Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
Code Review
This pull request introduces two changes to allow for less verbose logging. It modifies a high-frequency log statement in filteredwatcher.go to be V-leveled, and updates the ContainerLogLevelOverride in the v1beta1 API to permit negative log levels. This allows disabling V-leveled logs with a level of 0. My feedback includes a suggestion to apply the log level validation change to the v1alpha1 API version as well to maintain consistency.
|
/assign @cheftako |
|
@tomasaschan: GitHub didn't allow me to assign the following users: cheftako. Note that only GoogleContainerTools members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time. DetailsIn response to this:
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/test-infra repository. |
| // Lower severity messages are logged at higher verbosity. | ||
| // Allowed values are from 0 to 10. | ||
| // +kubebuilder:validation:Minimum=0 | ||
| // Allowed values are from -10 to 10. |
There was a problem hiding this comment.
This yields an update in doc of logLevel field https://docs.cloud.google.com/kubernetes-engine/config-sync/docs/reference/rootsync-reposync-fields. Worth noting that setting a logLevel to a high negative value (e.g., -10) may suppress almost all informational logs, making it difficult to monitor the container's health through standard output.
FYI run make generate to refresh the CRDs.
There was a problem hiding this comment.
Thanks! Did so (but with make configsync-crds); also, note that the way the Makefile sets up the installation of controller-gen it doesn't lock the version, and also gets confused if the user has set GOBIN (since it only sets GOPATH when installing), so it took me a few tries to make it run the version you had used previously.
There was a problem hiding this comment.
Good catch! We could resolve this together with the Makefile improvement, focusing on the GOBIN consistency and version pinning ,@Camila-B the driver.
For now we could update the contribution doc to remind contributors to unset the var before building.
|
/ok-to-test |
|
/assign @tiffanny29631 |
Need to run |
|
I'm flailing here. For some reason I can't get the local codegen to generate the same code as what this checks for; I assume there's some version of some tool that's assumed by the build system but not specified in the repo, and I get a different one than whatever the build machine is using. Could someone help me run the appropriate codegen for me and either push to this branch or just subsume this PR into one that builds cleanly? |
|
/retest |
|
/retest-required |
|
Seems like |
|
/retest-required |
|
/retest |
tiffanny29631
left a comment
There was a problem hiding this comment.
/lgtm
FYI this change will be included with Config Sync 1.24, target date 2026-05-07
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: tiffanny29631 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
137c8e3
into
GoogleContainerTools:main
|
Thanks both for the help to get this to a mergeable state! We're looking forward to 1.24! :) |
We were alerted to some log patterns that were costing literally thousands of dollars per month in our setup, and one of them was from this line1.
I tried using the
spec.override.logLevelsfeature to dial down the logging a bit, but it turns out CRD-level validation require the log level specified there to be in the range 0-10 inclusive, which makes it impossible to turn off log lines like the one linked above, for two reasons:It is not V-leveled; this PR addresses that for this specific logging statement, but it's likely that there is value in addressing this elswehere too in the project. Since we're not seeing enormous log volumes from other logging statements, though, I've considered that out of scope for this PR. To avoid changing the current behavior here, I've leveled this at 0, but I'm happy to bump that to turn it off by default for everyone.
The default log level is 0, which the CRD validation then does not allow turning off. This is addressed by relaxing the validation requirements and allow negative log level values.
klogitself doesn't have any issues with negative log levels (the log level is stored internally as anint32) so specifying-v=-1on the command line works just fine, but since theRootSyncCRD doesn't allow config like the following, we're stuck:To convince yourself that this is valid, you can run the following small program:
With this in
klog-repro.goat the root of this repository, you'll see this:Note: I get what looks like completely unrelated test errors from
make test, so I'm going to rely on CI to find if I need to amend anything else somewhere.