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

Migrate assume_cache.go to structured logging #105904

Merged

Conversation

mengjiao-liu
Copy link
Member

@mengjiao-liu mengjiao-liu commented Oct 26, 2021

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Migrate assume_cache.go to structured logging

Which issue(s) this PR fixes:

Ref #105841

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Migrated `pkg/scheduler/framework/plugins/volumebinding/assume_cache.go` to structured logging.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Oct 26, 2021
@shiva1333
Copy link
Contributor

/wg structured-logging
/area logging
/priority important-soon
/kind cleanup
/triage accepted
/sig instrumentation
/cc @kubernetes/wg-structured-logging-reviews

@k8s-ci-robot k8s-ci-robot added wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging. area/logging priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. triage/accepted Indicates an issue or PR is ready to be actively worked on. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Oct 26, 2021
@k8s-ci-robot
Copy link
Contributor

@shivanshu1333: you can only set the release note label to release-note-none if the release-note block in the PR body text is empty or "none".

In response to this:

/release-note-none

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.

@mengjiao-liu
Copy link
Member Author

/test pull-kubernetes-integration

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 28, 2021
@shiva1333 shiva1333 moved this from Waiting on Reviewer to Needs Approval in WG Structured Logging - 1.23 Migration Oct 28, 2021
@mengjiao-liu
Copy link
Member Author

ping @serathius

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

@serathius serathius left a comment

Choose a reason for hiding this comment

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

When deciding on value key, context of how value is used (e.g. warning) is secondary to what value represents (e.g. error). Please don't pass Go Error types into other keys than "err".

Names of variables should not matter when deciding on logging keys. File assume_cache.go is example of bad naming. It's inconsistent and not even representing correct meaning of calue. Take for example "name", "objName" there are two different names for same thing used in different functions. We should definetly not repeat same pattern in logging. When users read logs they don't have easy access to code which would explain that those two keys have same values.

Another problem here that "name" is really bad variable name. You might think that this is object name but it's not. It's key to cache, you can confirm that by reading how this variable is generated "name, err := cache.MetaNamespaceKeyFunc(obj)" this is clearly a key for this cache and not an object name. I don't want to waste to much time but a proper fix would:

  • Rename all variables "name" and "objName" to "key"
  • Use "cacheKey" as a key in logging.

@serathius
Copy link
Contributor

We could also consider renaming variables to avoid confusion, but this PR should be ok from migration side.
/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 1, 2021
@pohly
Copy link
Contributor

pohly commented Nov 5, 2021

/assign @xing-yang

For approval.

@serathius
Copy link
Contributor

/assign @gnufied

@serathius
Copy link
Contributor

This PR is needed to finish scheduler structured logging migration planned for 1.23
/milestone v1.23

@shiva1333
Copy link
Contributor

/assign @xing-yang for approval

@k8s-ci-robot
Copy link
Contributor

@shivanshu1333: GitHub didn't allow me to assign the following users: for, approval.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @xing-yang for approval

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.

@shiva1333
Copy link
Contributor

shiva1333 commented Nov 8, 2021

required for 1.23
ping @gnufied, @xing-yang for approval

@k8s-ci-robot
Copy link
Contributor

@shivanshu1333: GitHub didn't allow me to assign the following users: approval, for.

Note that only kubernetes members, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

required for 1.23
/assign @gnufied for approval

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.

return
}
}

objInfo := &objInfo{name: name, latestObj: obj, apiObj: obj}
if err = c.store.Update(objInfo); err != nil {
klog.Warningf("got error when updating stored object : %v", err)
klog.InfoS("Error occurred while updating stored object", "err", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does structured logging use Info to replace Warning msgs?

Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned in the stuctured-logging-migration-guide, the concept behind using info is explained in logr, quoting verbatim for quick reference

Info logs are things you want to tell the user which are not errors. Error logs are, well, errors. If your code receives an error from a subordinate function call and is logging that error and not returning it, use error logs.

Verbosity-levels on info logs. This gives developers a chance to indicate arbitrary grades of importance for info logs, without assigning names with semantic meaning such as "warning", "trace", and "debug." Superficially this may feel very similar, but the primary difference is the lack of semantics. Because verbosity is a numerical value, it's safe to assume that an app running with higher verbosity means more (and less important) logs will be generated.

Hope, this helps :)

@xing-yang
Copy link
Contributor

Just one question. Looks good other than that.

@xing-yang
Copy link
Contributor

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mengjiao-liu, xing-yang

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 9, 2021
@k8s-ci-robot k8s-ci-robot merged commit a41d166 into kubernetes:master Nov 9, 2021
WG Structured Logging - 1.23 Migration automation moved this from Needs Approval to Done Nov 9, 2021
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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on. wg/structured-logging Categorizes an issue or PR as relevant to WG Structured Logging.
Development

Successfully merging this pull request may close these issues.

None yet

8 participants