Skip to content

Conversation

@abhinavdahiya
Copy link
Contributor

controller runtime currently defaults to NullLogger 1 which doesn't log anything.
This is bad because any error returned from Reconcile function is therefore not logged anywhere
which is same as just eating the error. To make sure the controller runtime errors are also logged
we would need an adapter for logrus as this project uses that for logging.

Therefore, this implements a wrapper around lorgus that satisfies the logr.Logger interface and
confure the hive-controller and hive-operator managers with it.

The wrapper uses logrus.DebugLevel for all info messages and logrus.ErrorLevel for all error messages
from controller-runtime regardless of level (V) selected by caller in controller-runtime. This makes
sure all error messages from controller-runtime are always visible and the rest are only visible when in
debug mode.

/assign @dgoodwin
/cc @joelddiaz

controller runtime currently defaults to NullLogger [1] which doesn't log anything.
This is bad because any error returned from Reconcile function is therefore not logged anywhere
which is same as just eating the error. To make sure the controller runtime errors are also logged
we would need an adapter for logrus as this project uses that for logging.

Therefore, this implements a wrapper around lorgus that satisfies the logr.Logger interface and
confure the hive-controller and hive-operator managers with it.

The wrapper uses logrus.DebugLevel for all info messages and logrus.ErrorLevel for all error messages
from controller-runtime regardless of level (V) selected by caller in controller-runtime. This makes
sure all error messages from controller-runtime are always visible and the rest are only visible when in
debug mode.

[1]: https://github.com/kubernetes-sigs/controller-runtime/blob/9e78e653228851684b6b9cdabe5aae8559fe3722/pkg/log/null.go#L28
@abhinavdahiya abhinavdahiya force-pushed the controller_runtime_use_logrus branch from dea7271 to 611cbb8 Compare January 28, 2021 00:52
@dgoodwin
Copy link
Contributor

This is terrific, thanks!

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2021
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, dgoodwin

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

The pull request process is described here

Details 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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 28, 2021
@openshift-merge-robot openshift-merge-robot merged commit b8b3af3 into openshift:master Jan 28, 2021
@abhinavdahiya abhinavdahiya deleted the controller_runtime_use_logrus branch January 28, 2021 18:11
@abhinavdahiya
Copy link
Contributor Author

/cherry-pick ocm-2.2

@abhinavdahiya
Copy link
Contributor Author

/cherry-pick ocm-2.1

@openshift-cherrypick-robot

@abhinavdahiya: new pull request created: #1265

Details

In response to this:

/cherry-pick ocm-2.2

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.

@openshift-cherrypick-robot

@abhinavdahiya: new pull request created: #1266

Details

In response to this:

/cherry-pick ocm-2.1

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants