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

🌱 Fix log keys, use upper case for logs #10613

Merged
merged 1 commit into from
May 16, 2024

Conversation

sbueringer
Copy link
Member

@sbueringer sbueringer commented May 14, 2024

Signed-off-by: Stefan Büringer [email protected]

What this PR does / why we need it:
Maybe wouldn't have done it if I had realized earlier that we have >1k usages of WithValues / Info / Error, but here we go.

Went over all of those and made sure we follow log conventions

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

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 14, 2024
@k8s-ci-robot k8s-ci-robot requested a review from elmiko May 14, 2024 16:42
@k8s-ci-robot k8s-ci-robot added the do-not-merge/needs-area PR is missing an area label label May 14, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label May 14, 2024
@sbueringer
Copy link
Member Author

/assign @fabriziopandini @chrischdi

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@sbueringer
Copy link
Member Author

/retest

@chrischdi
Copy link
Member

/lgtm

one optional question/idea: shouldn't we be always able now to use obj.GetKind() instead of manually writing the name (for the (klog.Obj` case)?

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

LGTM label has been added.

Git tree hash: 10293cc098cd28332c7937564a5f724df467ed6a

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.

nice! just two nits from my side

@sbueringer
Copy link
Member Author

sbueringer commented May 15, 2024

one optional question/idea: shouldn't we be always able now to use obj.GetKind() instead of manually writing the name (for the (klog.Obj` case)?

There is no guarantee that the Kind is set in typed objects (only for Unstructured & PartialObjectMeta)

IIRC it depends on if a live client or the cache is used to retrieve the object. But we just shouldn't depend on it (only for Unstructured & PartialObjectMeta)

Bonus info: The reason why kind must be set for Unstructured & PartialObjectMeta is because otherwise there would be no way to tell what kind they have. This doesn't apply for typed objects.

@sbueringer
Copy link
Member Author

^^ @chrischdi I hope I didn't use it incorrectly in this PR :)

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 15, 2024
@sbueringer
Copy link
Member Author

sbueringer commented May 15, 2024

Added one small fix to be sure that we have a GVK during cluster deletion. I checked the logs earlier and the GVK is actually filled out, but we just shouldn't rely on GVK being set for typed objects

For client.Object's this also usually looks like this o.GetObjectKind().GroupVersionKind().Kind, I prefer hard-coding the kind instead whenever possible, it's just easier to read.

@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-cluster-api-apidiff-main 85d2880 link false /test pull-cluster-api-apidiff-main

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

@@ -488,7 +488,7 @@ func (r *MachinePoolReconciler) infraMachineToMachinePoolMapper(ctx context.Cont
if labels.IsMachinePoolOwned(o) {
machinePool, err := utilexp.GetMachinePoolByLabels(ctx, r.Client, o.GetNamespace(), o.GetLabels())
if err != nil {
log.Error(err, "failed to get MachinePool for InfraMachine", "infraMachine", klog.KObj(o), "labels", o.GetLabels())
log.Error(err, "Failed to get MachinePool for InfraMachine", o.GetObjectKind().GroupVersionKind().Kind, klog.KObj(o), "labels", o.GetLabels())
Copy link
Member Author

Choose a reason for hiding this comment

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

Btw this is only safe because this func is used with an unstructured informer. So we can infer that kind must be set

@sbueringer
Copy link
Member Author

/test pull-cluster-api-e2e-main

@chrischdi
Copy link
Member

/lgtm

@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
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 1a399804ffc3109bccd6a1701936bb0fedf3dc6b

@fabriziopandini
Copy link
Member

/lgtm
/approve

@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 May 16, 2024
@sbueringer sbueringer added the area/logging Issues or PRs related to logging label May 16, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/needs-area PR is missing an area label label May 16, 2024
@k8s-ci-robot k8s-ci-robot merged commit 9dc9c8f into kubernetes-sigs:main May 16, 2024
22 of 23 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.8 milestone May 16, 2024
@sbueringer sbueringer deleted the pr-fixup-logs branch May 16, 2024 15: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/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.

4 participants