Skip to content

🐛 fix: Ensure logger is initialized before logging errors #1777

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

Conversation

camilamacedo86
Copy link
Contributor

@camilamacedo86 camilamacedo86 commented Feb 14, 2025

Fix scenario where setupLogger is not logging because it was not initialized.

Closes: #1556

Description

Before this PR:

./bin/operator-controller --metrics-bind-address :8080
Error: metrics-bind-address requires tls-cert and tls-key flags to be set
 ( longer was not init yet)

After

$ $ ./bin/operator-controller --metrics-bind-address :8080
E0214 14:58:32.884029   55973 main.go:171] "metrics-bind-address requires tls-cert and tls-key flags to be set" err="invalid metrics configuration" logger="setup" metricsAddr=":8080" certFile="" keyFile=""
Error: metrics-bind-address requires tls-cert and tls-key flags to be set

Reviewer Checklist

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

@camilamacedo86 camilamacedo86 requested a review from a team as a code owner February 14, 2025 14:28
Copy link

netlify bot commented Feb 14, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit e240fb4
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/67af5a93d05950000838e61b
😎 Deploy Preview https://deploy-preview-1777--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.

@camilamacedo86
Copy link
Contributor Author

Hi @tmshort @joelanford
that is the real cause of the silence errors, not the "nil" just to let you know.

@@ -136,6 +136,8 @@ func main() {
os.Exit(0)
}

ctrl.SetLogger(textlogger.NewLogger(textlogger.NewConfig()))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just call before be used

Copy link

codecov bot commented Feb 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.26%. Comparing base (05415ef) to head (e240fb4).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1777      +/-   ##
==========================================
+ Coverage   68.24%   68.26%   +0.01%     
==========================================
  Files          63       63              
  Lines        5121     5123       +2     
==========================================
+ Hits         3495     3497       +2     
  Misses       1396     1396              
  Partials      230      230              
Flag Coverage Δ
e2e 51.62% <100.00%> (-0.06%) ⬇️
unit 55.84% <0.00%> (-0.03%) ⬇️

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.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 14, 2025
@tmshort tmshort disabled auto-merge February 14, 2025 18:22
@tmshort
Copy link
Contributor

tmshort commented Feb 14, 2025

/hold

Look at #1779, it does a bit more for logging initialization

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix issues with logging flag validations
3 participants