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

🐛 Improve log k/v pairs and a improve/drop a few log lines #9813

Merged
merged 1 commit into from
Dec 14, 2023

Conversation

sbueringer
Copy link
Member

What this PR does / why we need it:

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 5, 2023
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

@sbueringer sbueringer changed the title [WIP] 🌱 Improve log k/v pairs & consistent event recorder names [WIP] 🐛 Fix log k/v pairs & consistent event recorder names Dec 6, 2023
@sbueringer
Copy link
Member Author

/cherry-pick release-1.6

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.6 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.6

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.

@sbueringer
Copy link
Member Author

/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.5

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.

@sbueringer sbueringer force-pushed the pr-finalize-logging branch 4 times, most recently from 0e329f6 to fa4d1fe Compare December 7, 2023 14:09
if configOwner.GetKind() == "Machine" {
// AddOwners adds the owners of Machine as k/v pairs to the logger.
// Specifically, it will add KubeadmControlPlane, MachineSet and MachineDeployment.
ctx, log, err = clog.AddOwners(ctx, r.Client, configOwner)
Copy link
Member Author

Choose a reason for hiding this comment

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

We have to call clog.AddOwner with the Machine and not with the KubeadmConfig. Only the Machine has the KCP, MS, MD owner hierarchy

@@ -294,7 +294,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {

// Set up a ClusterCacheTracker and ClusterCacheReconciler to provide to controllers
// requiring a connection to a remote cluster
log := ctrl.Log.WithName("remote").WithName("ClusterCacheTracker")
log := ctrl.Log.WithValues("component", "remote/clustercachetracker")
Copy link
Member Author

Choose a reason for hiding this comment

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

WithName just adds a prefix to all messages. We stopped using that in all other places.

This adds something similar to the controller or webhook k/v pair. I called it component because the CCT is not a controller

Copy link
Member

Choose a reason for hiding this comment

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

What about adding this k/v pair to log inside NewClusterCacheTracker vs doing this before every call to this method?

Copy link
Member Author

@sbueringer sbueringer Dec 13, 2023

Choose a reason for hiding this comment

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

Good idea. Done

controlplane/kubeadm/internal/controllers/controller.go Outdated Show resolved Hide resolved
@@ -890,7 +890,7 @@ func (r *Reconciler) updateStatus(ctx context.Context, cluster *clusterv1.Cluste
availableReplicasCount++
}
} else if machine.GetDeletionTimestamp().IsZero() {
log.Info("Waiting for the Kubernetes node on the machine to report ready state")
log.V(4).Info("Waiting for the Kubernetes node on the machine to report ready state")
Copy link
Member Author

Choose a reason for hiding this comment

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

This is way to verbose on log level 0 and seems totally out-of-place (it's confusing if the MS controller is logging on log level 0 that it's waiting for a node to become ready. It is only doing that for status calculation but otherwise doesn't influence MS reconciliation). Similar logs around here use log level 4

Copy link
Contributor

Choose a reason for hiding this comment

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

Ever so slight nit to break this out into its own PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

I moved the event recorder stuff to a separate PR and changed the scope of this PR to "fix k/v paris and improve/drop a few log lines". I think that should be okay

@sbueringer sbueringer changed the title [WIP] 🐛 Fix log k/v pairs & consistent event recorder names 🐛 Fix log k/v pairs & consistent event recorder names Dec 7, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 7, 2023
@sbueringer
Copy link
Member Author

/cherry-pick release-1.6

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.6 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.6

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.

@sbueringer
Copy link
Member Author

/cherry-pick release-1.5

@k8s-infra-cherrypick-robot

@sbueringer: once the present PR merges, I will cherry-pick it on top of release-1.5 in a new PR and assign it to you.

In response to this:

/cherry-pick release-1.5

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.

@sbueringer sbueringer added the area/logging Issues or PRs related to logging label Dec 7, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label Dec 7, 2023
@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-full-main

@sbueringer
Copy link
Member Author

/assign @fabriziopandini @chrischdi

Copy link
Member

@chrischdi chrischdi left a comment

Choose a reason for hiding this comment

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

One question, as of that

/lgtm

controlplane/kubeadm/internal/controllers/controller.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 12, 2023
@sbueringer sbueringer changed the title 🐛 Fix log k/v pairs & consistent event recorder names 🐛 Improve log k/v pairs and a improve/drop a few log lines Dec 12, 2023
@sbueringer
Copy link
Member Author

sbueringer commented Dec 12, 2023

/hold cancel

Moved the event recorder change in its own PR and changed the scope of this PR

/assign @fabriziopandini @chrischdi

@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 Dec 12, 2023
@jackfrancis
Copy link
Contributor

/lgtm

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

LGTM label has been added.

Git tree hash: 14394659cbe9fad6e34e3f8734c240121b4756d6

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

one nit, otherwise lgtm

@@ -294,7 +294,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {

// Set up a ClusterCacheTracker and ClusterCacheReconciler to provide to controllers
// requiring a connection to a remote cluster
log := ctrl.Log.WithName("remote").WithName("ClusterCacheTracker")
log := ctrl.Log.WithValues("component", "remote/clustercachetracker")
Copy link
Member

Choose a reason for hiding this comment

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

What about adding this k/v pair to log inside NewClusterCacheTracker vs doing this before every call to this method?

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 13, 2023
Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

/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 Dec 14, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: a142ee1bb2bafca69175b5f0e29519aa3afcf520

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini

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 k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 14, 2023
@k8s-ci-robot k8s-ci-robot merged commit 23f09dd into kubernetes-sigs:main Dec 14, 2023
21 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.7 milestone Dec 14, 2023
@k8s-infra-cherrypick-robot

@sbueringer: new pull request created: #9880

In response to this:

/cherry-pick release-1.6

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-infra-cherrypick-robot

@sbueringer: #9813 failed to apply on top of branch "release-1.5":

Applying: Improve log k/v pairs and a improve/drop a few log lines
Using index info to reconstruct a base tree...
M	bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go
M	bootstrap/kubeadm/main.go
M	controlplane/kubeadm/main.go
M	docs/book/src/tasks/experimental-features/runtime-sdk/implement-extensions.md
M	internal/controllers/cluster/suite_test.go
M	internal/controllers/machine/suite_test.go
M	internal/controllers/machinedeployment/machinedeployment_controller.go
M	internal/controllers/machinedeployment/suite_test.go
M	internal/controllers/machinehealthcheck/suite_test.go
M	internal/controllers/machineset/machineset_controller.go
M	internal/controllers/machineset/suite_test.go
M	internal/controllers/topology/cluster/suite_test.go
M	main.go
M	test/infrastructure/docker/main.go
Falling back to patching base and 3-way merge...
Auto-merging test/infrastructure/docker/main.go
Auto-merging main.go
Auto-merging internal/controllers/topology/cluster/suite_test.go
CONFLICT (content): Merge conflict in internal/controllers/topology/cluster/suite_test.go
Auto-merging internal/controllers/machineset/suite_test.go
Auto-merging internal/controllers/machineset/machineset_controller.go
Auto-merging internal/controllers/machinehealthcheck/suite_test.go
Auto-merging internal/controllers/machinedeployment/suite_test.go
Auto-merging internal/controllers/machinedeployment/machinedeployment_controller.go
Auto-merging internal/controllers/machine/suite_test.go
Auto-merging internal/controllers/cluster/suite_test.go
Auto-merging docs/book/src/tasks/experimental-features/runtime-sdk/implement-extensions.md
Auto-merging controlplane/kubeadm/main.go
Auto-merging bootstrap/kubeadm/main.go
Auto-merging bootstrap/kubeadm/internal/controllers/kubeadmconfig_controller.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Improve log k/v pairs and a improve/drop a few log lines
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.5

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.

@sbueringer sbueringer deleted the pr-finalize-logging branch December 14, 2023 16:04
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. area/logging Issues or PRs related to logging 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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants