Skip to content

Conversation

@fabriziopandini
Copy link
Member

What this PR does / why we need it:
Documenting a few practices that we are adopting in latest review/PRs

/area documentation

@k8s-ci-robot k8s-ci-robot added area/documentation Issues or PRs related to documentation cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 19, 2025
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Nov 19, 2025
@stmcginnis
Copy link
Contributor

Looks good. There are some contextual logging efforts ongoing that might define more best practices, but this is good.

/lgtm

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

LGTM label has been added.

Git tree hash: b982c588715762f1f5df429ad9c997b0c09b1b82

Copy link
Contributor

@AndiDog AndiDog left a comment

Choose a reason for hiding this comment

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

LGTM, with comments/questions

Notably, over time in CAPI we are also standardizing usage of other key value pairs to improve consistency when reading
logs, e.g.
- key `reason` MUST be used when adding details about WHY a change happened.
- key `diff` MUST be used when documenting the diff in an object that either lead to a chance, or that is resulting from a change.
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be very helpful. Can we specify a suggested format? For example, subfields old/new, or string format (less helpful)?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's extremely hard to standardize as we have a lot of different cases where we have different data that we can use

(check the usages of the "diff" key today in CAPI)

Comment on lines +122 to +123
the message MUST contain the Kind of the controlled/referenced object and its name, for example `Created MachineSet foo-bar`
- If the controlled/referenced object is in another namespace, use namespace/name instead of name
Copy link
Contributor

Choose a reason for hiding this comment

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

Sure to repeat the object name, which should already be a structured field? I'm not against this repetition to make it more readable for humans – just asking if this was considered.

The namespace should be in the structured field automatically (via klog.KRef). If we want the human log message to only contain the namespace if it's outside the "default", then I guess this means a utility function which does that?

Copy link
Member

@sbueringer sbueringer Nov 20, 2025

Choose a reason for hiding this comment

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

Sure to repeat the object name, which should already be a structured field? I'm not against this repetition to make it more readable for humans – just asking if this was considered.

Yes, I think we should repeat it. My experience is that omitting it makes it unnecessarily hard to figure out what's going on, e.g.

Created Machine
k,v MachineSet namespace/name Machine namespace/name + a ton of other k/v pairs

Created Machine machine-1

With tools like Grafana/Kibana etc. it makes sense in my opinion to only show specific parts of the log, E.g. to only show controller-name + msg. If all the k/v pairs have to be shown for the log to make sense the view becomes extremely verbose

If we want the human log message to only contain the namespace if it's outside the "default", then I guess this means a utility function which does that?

I think we don't need a util for that. I'm not aware of a single case of this in core Cluster API. We just use %s and e.g. machine.Name. I think folks can just decide to either do that or use klog.KObj / klog.KRef as appropriate

Notably, over time in CAPI we are also standardizing usage of other key value pairs to improve consistency when reading
logs, e.g.
- key `reason` MUST be used when adding details about WHY a change happened.
- key `diff` MUST be used when documenting the diff in an object that either lead to a chance, or that is resulting from a change.
Copy link
Member

Choose a reason for hiding this comment

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

I think it's extremely hard to standardize as we have a lot of different cases where we have different data that we can use

(check the usages of the "diff" key today in CAPI)

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 20, 2025
@fabriziopandini fabriziopandini added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Nov 20, 2025
@sbueringer
Copy link
Member

/lgtm
/approve

/hold
In case someone wants to take another look

@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 Nov 20, 2025
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 20, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2936dfcd8f90673c0396a98cac2dd5f1cd94c58b

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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 Nov 20, 2025
@sbueringer
Copy link
Member

/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 Nov 21, 2025
@k8s-ci-robot k8s-ci-robot merged commit b2967c1 into kubernetes-sigs:main Nov 21, 2025
18 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.12 milestone Nov 21, 2025
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/documentation Issues or PRs related to documentation 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/S Denotes a PR that changes 10-29 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants