node-driver-registrar icon indicating copy to clipboard operation
node-driver-registrar copied to clipboard

Support structured logging

Open rlia opened this issue 1 year ago • 9 comments

What type of PR is this?

/kind feature

What this PR does / why we need it:

In this PR I have added JSON logging. With this change, it is now possible to output the logs of the node-driver-register in JSON format. Running the container with the --logging-format=json option will output the logs in JSON format.

In addition, I've modified the log messages based on the following guideline: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md#remove-string-formatting-from-log-message

I’ve update the klog functions in use according to the guidelines provided below, and I've confirmed that they pass the logcheck tests: https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/migration-to-structured-logging.md#change-log-functions

$ logcheck ./cmd/csi-node-driver-registrar/

Which issue(s) this PR fixes:

Fixes #228

Special notes for your reviewer:

$ ./bin/csi-node-driver-registrar --logging-format json
{"ts":1695281742857.0557,"caller":"csi-node-driver-registrar/main.go:196","msg":"kubelet-registration-path is a required parameter"}
$ ./bin/csi-node-driver-registrar --logging-format text
E0921 16:35:45.474034   13268 main.go:196] "kubelet-registration-path is a required parameter"
$ ./bin/csi-node-driver-registrar 
E0921 16:35:50.030637   13337 main.go:196] "kubelet-registration-path is a required parameter"
$ ./bin/csi-node-driver-registrar --logging-format unknown
E1218 13:27:19.510846    4896 main.go:129] "LoggingConfiguration is invalid" err="format: Invalid value: \"unknown\": Unsupported log format"

Does this PR introduce a user-facing change?:

Added support for structured logging (the log messages have been changed due to the activation of structured logging)

rlia avatar Nov 02 '23 07:11 rlia

Hi @rlia. Thanks for your PR.

I'm waiting for a kubernetes-csi member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

k8s-ci-robot avatar Nov 02 '23 07:11 k8s-ci-robot

/ok-to-test

bells17 avatar Nov 02 '23 09:11 bells17

/lgtm /approve

jsafrane avatar Nov 06 '23 16:11 jsafrane

Thanks a lot !

jsafrane avatar Nov 06 '23 16:11 jsafrane

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, rlia

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

The pull request process is described 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

k8s-ci-robot avatar Nov 06 '23 16:11 k8s-ci-robot

I am sorry, @rlia can you please rebase?

jsafrane avatar Dec 11 '23 13:12 jsafrane

New changes are detected. LGTM label has been removed.

k8s-ci-robot avatar Dec 18 '23 04:12 k8s-ci-robot

@rlia: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-csi-node-driver-registrar-unit abc918a60d7966269732492e73b79c7edf3ffc2f link true /test pull-kubernetes-csi-node-driver-registrar-unit

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

k8s-ci-robot avatar Feb 12 '24 12:02 k8s-ci-robot

PR needs rebase.

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.

k8s-ci-robot avatar Feb 23 '24 00:02 k8s-ci-robot

@rlia another release, can you please rebase again? I promise I will merge it this time :-)

jsafrane avatar May 14 '24 08:05 jsafrane

In addition, can you please add logcheck to make test? A simple line in Makefile is needed, see e.g. liveness probe example: https://github.com/kubernetes-csi/livenessprobe/pull/259/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52R20

jsafrane avatar May 14 '24 11:05 jsafrane

[IMHO] This PR addresses structured logging, but contextual logging is not yet supported. Therefore, if we want to pass the make test-logcheck tests in this PR, we will need to make additional changes similar to those in the following PR: https://github.com/kubernetes-csi/livenessprobe/pull/259

Alternatively, it might be a good idea to keep this PR focused on addressing structured logging only, and create a separate PR to handle contextual logging.

bells17 avatar May 14 '24 11:05 bells17

ack, feel free to focus at structured logging

jsafrane avatar May 14 '24 13:05 jsafrane

/lgtm /approve

jsafrane avatar May 16 '24 13:05 jsafrane

Thanks for your patience!

jsafrane avatar May 16 '24 13:05 jsafrane

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, rlia

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

The pull request process is described 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

k8s-ci-robot avatar May 16 '24 13:05 k8s-ci-robot