Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨main.go: switch to klog-based logger #1317

Merged
merged 1 commit into from
Sep 27, 2024

Conversation

joelanford
Copy link
Member

Use standard klog now that klog works with controller-runtime's expectation of a logr.Logger interface.

We get a standard --v flag and we are more in line with k8s standards.

We also get client-go and other low-level logging from k8s libraries at the higher verbosity levels which could be immensely helpful for debugging.

See similar PR in catalogd: operator-framework/catalogd#419

Description

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@joelanford joelanford requested a review from a team as a code owner September 27, 2024 18:15
Copy link

netlify bot commented Sep 27, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit f03194f
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/66f6fe5a346ae500080f4dfb
😎 Deploy Preview https://deploy-preview-1317--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +93 to +98
image: gcr.io/kubebuilder/kube-rbac-proxy:v0.15.0
args:
- "--secure-listen-address=0.0.0.0:8443"
- "--upstream=http://127.0.0.1:8080/"
- "--logtostderr=true"
- "--v=0"
- --secure-listen-address=0.0.0.0:8443
- --http2-disable
- --upstream=http://127.0.0.1:8080/
- --logtostderr=true
Copy link
Member Author

Choose a reason for hiding this comment

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

Making arguments for krp look the same as catalogd (which also requires bumping krp version).

I'm doing this to ensure consistency in the contents and ordering of arguments between catalogd and operator controller so that vendors have an easier time manipulating flags for their specific use cases.

Comment on lines +104 to +105
l.Info("reconcile starting")
defer l.Info("reconcile ending")
Copy link
Member Author

Choose a reason for hiding this comment

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

With the original zap logger l.V(1).Info was being output by default.

With klogr, we need to put these log messages at a lower verbosity level to keep them coming by default.

@joelanford
Copy link
Member Author

As a test, I manually set --v=8 on the controller and verified that low-level client-go logs were being emitted. 🎉

Copy link

codecov bot commented Sep 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.02%. Comparing base (360f892) to head (f03194f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1317      +/-   ##
==========================================
- Coverage   76.09%   76.02%   -0.08%     
==========================================
  Files          40       40              
  Lines        2380     2377       -3     
==========================================
- Hits         1811     1807       -4     
- Misses        401      402       +1     
  Partials      168      168              
Flag Coverage Δ
e2e 58.43% <100.00%> (-0.06%) ⬇️
unit 51.99% <80.00%> (-0.11%) ⬇️

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.

Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
@joelanford joelanford added this pull request to the merge queue Sep 27, 2024
Merged via the queue into operator-framework:main with commit c5686d1 Sep 27, 2024
19 checks passed
@joelanford joelanford deleted the use-klog branch October 22, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants