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

Support structured logging #349

Merged
merged 5 commits into from
May 16, 2024

Conversation

rlia
Copy link
Contributor

@rlia rlia commented Nov 2, 2023

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)

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 2, 2023
@k8s-ci-robot
Copy link
Contributor

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 k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 2, 2023
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 2, 2023
@bells17
Copy link
Contributor

bells17 commented Nov 2, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Nov 2, 2023
@jsafrane
Copy link
Contributor

jsafrane commented Nov 6, 2023

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 6, 2023
@jsafrane
Copy link
Contributor

jsafrane commented Nov 6, 2023

Thanks a lot !

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 6, 2023
@jsafrane
Copy link
Contributor

I am sorry, @rlia can you please rebase?

@rlia rlia force-pushed the structured-logging2 branch from 538c666 to dc23d0e Compare December 18, 2023 04:33
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 18, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 12, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 23, 2024
@jsafrane
Copy link
Contributor

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

@jsafrane
Copy link
Contributor

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

@bells17
Copy link
Contributor

bells17 commented May 14, 2024

[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:
kubernetes-csi/livenessprobe#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.

@jsafrane
Copy link
Contributor

ack, feel free to focus at structured logging

@rlia rlia force-pushed the structured-logging2 branch from b32900e to 5c16a09 Compare May 15, 2024 06:23
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 15, 2024
Makefile Outdated
@@ -18,3 +18,5 @@ CMDS=csi-node-driver-registrar
all: build

include release-tools/build.make

test: test-logcheck
Copy link
Contributor

Choose a reason for hiding this comment

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

This will need more changes in the PR. As @bells17 pointed out, we should focus on the structured logging and not add test-logcheck here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was mistaken. . I deleted the line.

@jsafrane
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 16, 2024
@jsafrane
Copy link
Contributor

Thanks for your patience!

@k8s-ci-robot
Copy link
Contributor

[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

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support structured logging
4 participants