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

Migrated pkg/proxy/ipvs to structured logging #104932

Conversation

shiva1333
Copy link
Contributor

What type of PR is this?

/kind cleanup

What this PR does / why we need it:

Migrate pkg/proxy/ipvs to structured logging

Which issue(s) this PR fixes:

Fixes #
Ref #104872

Special notes for your reviewer:

Does this PR introduce a user-facing change?

migrated pkg/proxy/ipvs 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/M Denotes a PR that changes 30-99 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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 11, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @shivanshu1333. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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-ci-robot k8s-ci-robot added area/ipvs sig/network Categorizes an issue or PR as relevant to SIG Network. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Sep 11, 2021
@shiva1333 shiva1333 changed the title Migrated pkg/proxy/ipvs to structured Migrated pkg/proxy/ipvs to structured logging Sep 11, 2021
@pacoxu
Copy link
Member

pacoxu commented Sep 13, 2021

Remember to close them if this is merged.

@shiva1333
Copy link
Contributor Author

Yes, sure

@shiva1333
Copy link
Contributor Author

@danwinship, @rramkumar1 kindly review

@serathius
Copy link
Contributor

/wg structured-logging
/area logging
/priority important-soon
/kind cleanup
/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. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Sep 13, 2021
@serathius serathius moved this from Inbox to Waiting on Reviewer in WG Structured Logging - 1.23 Migration Sep 13, 2021
@shiva1333
Copy link
Contributor Author

/auto-cc

m.rsList.add(ele)
return nil
}

func (m *GracefulTerminationManager) deleteRsFunc(rsToDelete *listItem) (bool, error) {
klog.V(5).Infof("Trying to delete rs: %s", rsToDelete.String())
klog.V(5).InfoS("Trying to delete real server", "realServer", rsToDelete)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

here I've removed .String() as it is a helper function to convert real server to string.
Structured logging does this by default, and I've made every logging statement consistent with having "key" - "value" pairs.

  • log output using klog.V(5).InfoS("Deleting real server", "realServers", rsToDelete.String()). *
    I0921 23:54:10.037778 58346 graceful_termination.go:173] "Deleting real server" realServer="1.1.1.1:80/tcp/10.0.0.1:80"

  • klog.V(5).InfoS("Deleting real server", "realServer", rsToDelete) *
    I0921 23:56:34.439093 58827 graceful_termination.go:173] "Deleting real server" realServer="1.1.1.1:80/tcp/10.0.0.1:80"

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for testing this and providing examples! Looks better!

@shiva1333
Copy link
Contributor Author

@serathius kindly re-review changes, thanks!

@shiva1333
Copy link
Contributor Author

/test pull-kubernetes-e2e-gci-gce-ipvs

@@ -167,10 +167,10 @@ func (m *GracefulTerminationManager) deleteRsFunc(rsToDelete *listItem) (bool, e
// (existing connections will be deleted on the next packet because sysctlExpireNoDestConn=1)
// For other protocols, don't delete until all connections have expired)
if utilipvs.IsRsGracefulTerminationNeeded(rsToDelete.VirtualServer.Protocol) && rs.ActiveConn+rs.InactiveConn != 0 {
klog.V(5).Infof("Not deleting, RS %v: %v ActiveConn, %v InactiveConn", rsToDelete.String(), rs.ActiveConn, rs.InactiveConn)
klog.V(5).InfoS("Not deleting real server, active connection, and inactive connection", "realServer", rsToDelete, "realServerActiveConnection", rs.ActiveConn, "realServerInactiveConnection", rs.InactiveConn)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
klog.V(5).InfoS("Not deleting real server, active connection, and inactive connection", "realServer", rsToDelete, "realServerActiveConnection", rs.ActiveConn, "realServerInactiveConnection", rs.InactiveConn)
klog.V(5).InfoS("Skip deleting real server till all connection have expired", "realServer", rsToDelete, "activeConnection", rs.ActiveConn, "inactiveConnection", rs.InactiveConn)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yes, this is better

@@ -191,13 +191,13 @@ func ensureIPSet(set *IPSet) error {
func checkMinVersion(vstring string) bool {
version, err := utilversion.ParseGeneric(vstring)
if err != nil {
klog.Errorf("vstring (%s) is not a valid version string: %v", vstring, err)
klog.ErrorS(err, "Vstring is not a valid version string", "versionString", vstring)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
klog.ErrorS(err, "Vstring is not a valid version string", "versionString", vstring)
klog.ErrorS(err, "Got invalid version string", "versionString", vstring)

mentioning name of variable in logs is not useful as simple rename will result in this log line not making sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, makes sense, thanks!

return false
}

minVersion, err := utilversion.ParseGeneric(MinIPSetCheckVersion)
if err != nil {
klog.Errorf("MinCheckVersion (%s) is not a valid version string: %v", MinIPSetCheckVersion, err)
klog.ErrorS(err, "MinCheckVersion is not a valid version string", "minCheckVersion", MinIPSetCheckVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
klog.ErrorS(err, "MinCheckVersion is not a valid version string", "minCheckVersion", MinIPSetCheckVersion)
klog.ErrorS(err, "Got invalid version string", "versionString", MinIPSetCheckVersion)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's similar to the previous suggestion, fixed it too, thank you very much for suggesting, slowly I'm getting better at this :)

@shiva1333
Copy link
Contributor Author

/retest

@shiva1333
Copy link
Contributor Author

@serathius kindly re-review, thanks!

@serathius
Copy link
Contributor

/lgtm
/assign @lbernail

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 29, 2021
@shiva1333
Copy link
Contributor Author

pinging @thockin for suggestions/approval
Thanks!

@shiva1333
Copy link
Contributor Author

/cc @aojea

@aojea
Copy link
Member

aojea commented Oct 14, 2021

/label tide/merge-method-squash
/approve
Thanks

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Oct 14, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: aojea, shivanshu1333

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 Oct 14, 2021
@k8s-ci-robot k8s-ci-robot merged commit 7d9a6d1 into kubernetes:master Oct 14, 2021
WG Structured Logging - 1.23 Migration automation moved this from Needs Approval to Done Oct 14, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.23 milestone Oct 14, 2021
tallclair pushed a commit to tallclair/kubernetes that referenced this pull request Oct 26, 2021
* migrated ipset.go

* migrated graceful_termination.go

* fixed vstring

* fixed ip set entry, made it consistent

* fixed rs logging

* resolving review comments for key graceful_termination.go

* refactoring ipset.go

* included review changes
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/ipvs 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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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/network Categorizes an issue or PR as relevant to SIG Network. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. 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

9 participants