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

logger: make consistent flexible levels and contextual logging #1268

Open
wants to merge 7 commits into
base: incubation
Choose a base branch
from

Conversation

ykaliuta
Copy link
Contributor

@ykaliuta ykaliuta commented Sep 30, 2024

Jira: https://issues.redhat.com/browse/RHOAIENG-13892

The patchset's intention is to address following issues:

  • changing logmode does not change controller-runtime's log level (for prod it shows info)
  • overwriting logmode with DSCI works only for components

Deprecate logmode and use logLevel instead to tweak zap log level. Use standard zap command line switches to tune it from command line.

The patchset takes in use k8s contextual logger and it also propagates it down the chain to components and utility functions.

See the individual patches' messages.

Parts of this work:
#1253
#1271
#1272
#1280
#1289
#1295

Description

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link

openshift-ci bot commented Sep 30, 2024

[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 ask for approval from ykaliuta. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

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

@ykaliuta
Copy link
Contributor Author

/hold

@ykaliuta
Copy link
Contributor Author

/cc @bartoszmajsak @zdtsw @lburgazzoli

@ykaliuta
Copy link
Contributor Author

ykaliuta commented Oct 1, 2024

/retest-required

@ykaliuta ykaliuta force-pushed the slogger branch 2 times, most recently from 089d0e0 to e83817e Compare October 2, 2024 11:28
@ykaliuta
Copy link
Contributor Author

ykaliuta commented Oct 2, 2024

/cc @aslakknutsen

@ykaliuta ykaliuta force-pushed the slogger branch 5 times, most recently from a1d88b7 to 2af9fab Compare October 8, 2024 01:55
@ykaliuta ykaliuta changed the title RFC: logger: globally enable levels logger: make consistent flexible levels and contextual logging Oct 8, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 9, 2024

Codecov Report

Attention: Patch coverage is 19.56522% with 37 lines in your changes missing coverage. Please review.

Please upload report for BASE (incubation@a5388ad). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...atasciencecluster/datasciencecluster_controller.go 0.00% 14 Missing ⚠️
.../dscinitialization/dscinitialization_controller.go 25.00% 8 Missing and 1 partial ⚠️
controllers/dscinitialization/monitoring.go 0.00% 6 Missing ⚠️
...lers/secretgenerator/secretgenerator_controller.go 0.00% 4 Missing ⚠️
pkg/cluster/resources.go 0.00% 4 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             incubation    #1268   +/-   ##
=============================================
  Coverage              ?   18.22%           
=============================================
  Files                 ?       30           
  Lines                 ?     2688           
  Branches              ?        0           
=============================================
  Hits                  ?      490           
  Misses                ?     2135           
  Partials              ?       63           

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

Switch ReconcileComponent from passing logger explicitly to wrapping
it into context[1][2]

Makes one parameter less to pass and will allow called utilities to
report component context where they are called from.

No user or logging format impact until utilities takes contextual
logging in use.

[1] https://www.kubernetes.dev/blog/2022/05/25/contextual-logging/
[2] https://github.com/kubernetes/enhancements/blob/master/keps/sig-instrumentation/3077-contextual-logging/README.md

Credits-To: Bartosz Majsak [email protected]
Signed-off-by: Yauheni Kaliuta <[email protected]>
Remove increasing logging level for controllers (it was also passed
to components if not overridden from DSCI) since:

- it made logging inconsistent. The base contoller runtime logger is
set up with INFO level for all log modes, so when controllers are
configured for Error level, user sees INFO messages from both
controller-runtime and other parts of operator which use
controller-runtime's logger directly;

- since the base logger is configured for INFO, there is no
difference in levels between "default" and "devel". Having levels 1
and 2 there is misleading.

Update documentation.

This patch changes default logging, former filtered Info messages
are displayed now.

There is no _big_ difference in practice since currently the log is
anyway full of info messages from parts which do not use
reconciler's logger, like:

{"level":"info","ts":"2024-10-09T13:23:11Z","msg":"waiting for 1 deployment to be ready for dashboard"}

Signed-off-by: Yauheni Kaliuta <[email protected]>
To avoid patch polluting with the next changes where uber's zap is
imported as `zap`.

Signed-off-by: Yauheni Kaliuta <[email protected]>
Allow to override global zap log level from DSCI devFlags. Accepts
the same values as to `--zap-log-level` command line switch.

Signed-off-by: Yauheni Kaliuta <[email protected]>
Since the log level is overridable with its own field of devFlags,
do not use logmode anymore. It was used to create own logger with
own zap backend in case if devFlags exist.

Just add name and value to the existing logger instead.

Signed-off-by: Yauheni Kaliuta <[email protected]>
Remove own logger from controllers' reconcilers and switch to k8s
contextual logger instead [1].

Use contextual logger for SecretGeneratorReconciler and
CertConfigmapGeneratorReconciler setups as well.

[1] https://www.kubernetes.dev/blog/2022/05/25/contextual-logging/

Signed-off-by: Yauheni Kaliuta <[email protected]>
All the users should have proper context. Webhook is a separate
server so makes own logger based on the controller-runtime's one.

The log level changes will affect it as well.

Signed-off-by: Yauheni Kaliuta <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants