node-driver-registrar
node-driver-registrar copied to clipboard
Support structured logging
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)
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.
/ok-to-test
/lgtm /approve
Thanks a lot !
[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
- ~~OWNERS~~ [jsafrane]
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment
I am sorry, @rlia can you please rebase?
New changes are detected. LGTM label has been removed.
@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.
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.
@rlia another release, can you please rebase again? I promise I will merge it this time :-)
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
[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.
ack, feel free to focus at structured logging
/lgtm /approve
Thanks for your patience!
[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
- ~~OWNERS~~ [jsafrane]
Approvers can indicate their approval by writing /approve
in a comment
Approvers can cancel approval by writing /approve cancel
in a comment