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

fix: set formatter for klog logger #3493

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

chetan-rns
Copy link
Member

We set the logger for klog and the client-go library uses it. This fix sets the formatter for the logger so that the logs from klog stay consistent with the log format set by the user.

Before:

Logs from client-go don't follow the right format

cbanavik@cbanavik-mac argo-rollouts % go run cmd/rollouts-controller/main.go --logformat="json"

{"level":"info","msg":"Argo Rollouts starting","time":"2024-04-02T13:16:31+05:30","version":
{"level":"info","msg":"Leaderelection get id cbanavik-mac_11377322-2859-434d-8f46-121b1438e6b2","time":"2024-04-02T13:16:31+05:30"}
{"level":"info","msg":"Starting Metric Server at 0.0.0.0:8090","time":"2024-04-02T13:16:31+05:30"}
INFO[0000] attempting to acquire leader lease argo-rollouts/argo-rollouts-controller-lock... 
{"level":"info","msg":"New leader elected: cbanavik-mac_0b485ea3-1a2b-4418-8be8-6b572a7c168f","time":"2024-04-02T13:16:31+05:30"}
{"level":"info","msg":"New leader elected: cbanavik-mac_11377322-2859-434d-8f46-121b1438e6b2","time":"2024-04-02T13:16:49+05:30"}
INFO[0017] successfully acquired lease argo-rollouts/argo-rollouts-controller-lock 

After:

cbanavik@cbanavik-mac argo-rollouts % go run cmd/rollouts-controller/main.go --logformat="json"

{"level":"info","msg":"Argo Rollouts starting","time":"2024-04-02T13:09:20+05:30","version":
{"level":"info","msg":"Leaderelection get id cbanavik-mac_0b485ea3-1a2b-4418-8be8-6b572a7c168f","time":"2024-04-02T13:09:20+05:30"}
{"level":"info","msg":"attempting to acquire leader lease argo-rollouts/argo-rollouts-controller-lock...\n","time":"2024-04-02T13:09:20+05:30"}
{"level":"info","msg":"Starting Metric Server at 0.0.0.0:8090","time":"2024-04-02T13:09:20+05:30"}
{"level":"info","msg":"New leader elected: cbanavik-mac_24066bb3-0dcf-4115-bfbc-af7c6ee68fa5","time":"2024-04-02T13:09:20+05:30"}
{"level":"info","msg":"New leader elected: cbanavik-mac_0b485ea3-1a2b-4418-8be8-6b572a7c168f","time":"2024-04-02T13:09:37+05:30"}
{"level":"info","msg":"successfully acquired lease argo-rollouts/argo-rollouts-controller-lock\n","time":"2024-04-02T13:09:37+05:30"}

Fixes: #3041
Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional with a list of types and scopes found here, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed my commits with DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

Signed-off-by: Chetan Banavikalmutt <[email protected]>
Copy link

sonarcloud bot commented Apr 2, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
6.9% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

github-actions bot commented Apr 2, 2024

Go Published Test Results

2 160 tests   2 160 ✅  2m 53s ⏱️
  119 suites      0 💤
    1 files        0 ❌

Results for commit cbac5ee.

Copy link

codecov bot commented Apr 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.87%. Comparing base (8405f2e) to head (cbac5ee).
Report is 71 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3493      +/-   ##
==========================================
+ Coverage   81.83%   82.87%   +1.03%     
==========================================
  Files         135      135              
  Lines       20688    17142    -3546     
==========================================
- Hits        16931    14206    -2725     
+ Misses       2883     2043     -840     
- Partials      874      893      +19     

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

Copy link
Contributor

github-actions bot commented Apr 2, 2024

E2E Tests Published Test Results

  4 files    4 suites   3h 48m 7s ⏱️
110 tests 100 ✅  6 💤  4 ❌
456 runs  414 ✅ 24 💤 18 ❌

For more details on these failures, see this check.

Results for commit cbac5ee.

@zachaller zachaller merged commit 55bac14 into argoproj:master Apr 2, 2024
23 checks passed
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.

Wrong log format
2 participants