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

⚠ logging: align to Kubernetes structured logging, add reconcileID #1827

Merged
merged 1 commit into from Mar 17, 2022

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented Mar 4, 2022

Signed-off-by: Stefan Büringer buringerst@vmware.com

For more details, please see: #1826

This PR introduces the LogConstructor controller option which replaces the previous Log option.
LogConstructor creates a Logger on-demand either within the context of a reconciliation based on a *reconcile.Request or outside of it (then nil is passed in).

Through this PR the logs change as follows:

When the controller is created with the builder:

-  "msg": "controller/cluster: Waiting for DockerCluster",
+  "msg": "Waiting for DockerCluster",
+  "cluster": {
+     "name": "capi-quickstart",
+     "namespace": "default"
+   },
-  "reconciler group": "cluster.x-k8s.io",
-  "reconciler kind": "Cluster",
+  "controllerGroup": "cluster.x-k8s.io",
+  "controllerKind": "Cluster",
+  "reconcileID": "56e044eb38fb76741ffe41cd83e7bed5",

When the controller is created with controller.New or controller.NewUnmanaged:

-  "msg": "controller/cluster: Waiting for DockerCluster",
+  "msg": "Waiting for DockerCluster",
+  "object": {
+     "name": "capi-quickstart",
+     "namespace": "default"
+   },
+  "reconcileID": "56e044eb38fb76741ffe41cd83e7bed5",

The output of the text format changed similarly. Although the objects are just formatted as <namespace>/<name> in this case (when using klog).

Please note by providing a LogConstructor via controller options everything except the reconcileID can be overwritten.

Fixes #1826

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 4, 2022
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 4, 2022
@sbueringer
Copy link
Member Author

sbueringer commented Mar 4, 2022

/test pull-controller-runtime-test-master
Not sure if it's related, but let's see.

I'm seeing similar failed tests on the periodic job: https://prow.k8s.io/job-history/gs/kubernetes-jenkins/logs/periodic-controller-runtime-test-master

pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/internal/controller/controller.go Outdated Show resolved Hide resolved
pkg/builder/controller.go Outdated Show resolved Hide resolved
pkg/builder/controller.go Show resolved Hide resolved
pkg/controller/controller.go Outdated Show resolved Hide resolved
pkg/internal/controller/controller.go Show resolved Hide resolved
pkg/internal/controller/controller.go Show resolved Hide resolved
pkg/internal/controller/controller.go Show resolved Hide resolved
pkg/internal/controller/controller.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 11, 2022
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 11, 2022
@sbueringer
Copy link
Member Author

@alvaroaleman Findings should be addressed or answered, PTAL. Thank you very much!

Signed-off-by: Stefan Büringer buringerst@vmware.com
@k8s-ci-robot
Copy link
Contributor

@sbueringer: 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-controller-runtime-apidiff-master 598978c link false /test pull-controller-runtime-apidiff-master

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.

Copy link
Member

@alvaroaleman alvaroaleman left a comment

Choose a reason for hiding this comment

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

looks good to me, thanks for the work!
/hold
@joelanford @vincepri any concerns or objections?

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 15, 2022
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 15, 2022
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@vincepri
Copy link
Member

+1 from me to merge

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alvaroaleman, sbueringer, vincepri

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:
  • OWNERS [alvaroaleman,vincepri]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@FillZpp
Copy link
Contributor

FillZpp commented Mar 17, 2022

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 17, 2022
@k8s-ci-robot k8s-ci-robot merged commit e42a8c1 into kubernetes-sigs:master Mar 17, 2022
@k8s-ci-robot k8s-ci-robot added this to the v0.10.x milestone Mar 17, 2022
@sbueringer sbueringer deleted the pr-align-logging branch March 17, 2022 07:49
@sbueringer
Copy link
Member Author

Thanks everyone for the quick feedback and good discussions! :)

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve logging
5 participants