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

Add more logs to L4 NetLB #1845

Merged
merged 4 commits into from
Oct 25, 2022
Merged

Conversation

panslava
Copy link
Contributor

This should not introduce any change in logic, but involves some refactoring

I've tried to split it by multiple commits

- Remove unused "version" argument
- Remove no-op type conversions
Add more logging in deletion with measuring time taken
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 24, 2022
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 24, 2022
@panslava panslava force-pushed the debug-logs branch 2 times, most recently from 91636e2 to 4bf99f8 Compare October 24, 2022 13:25
@panslava
Copy link
Contributor Author

/assign cezarygerard
/cc code-elinka

@k8s-ci-robot
Copy link
Contributor

@panslava: GitHub didn't allow me to request PR reviews from the following users: code-elinka.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/assign cezarygerard
/cc code-elinka

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.

@@ -216,26 +204,52 @@ func (l4hc *l4HealthChecks) ensureHealthCheck(hcName string, svcName types.Names
//
// L4 ILB and L4 NetLB Services with ExternalTrafficPolicy=Cluster use the same firewall
// rule at global scope.
func (l4hc *l4HealthChecks) ensureIPv4Firewall(svc *corev1.Service, hcFwName string, hcPort int32, sharedHC bool, nodeNames []string) error {
func (l4hc *l4HealthChecks) ensureIPv4Firewall(svc *corev1.Service, namer namer.L4ResourcesNamer, hcPort int32, isSharedHC bool, nodeNames []string, hcResult *EnsureHealthCheckResult) {
Copy link
Contributor

@code-elinka code-elinka Oct 24, 2022

Choose a reason for hiding this comment

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

I like the old way of returning the error more than not returning it.
Pros of the old approach:

  • easier to test
  • you can customize log messages based on error

Cons:

  • you need to check for an error everywhere, where you use this function

Copy link
Contributor Author

@panslava panslava Oct 24, 2022

Choose a reason for hiding this comment

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

I agree, I also like returning errors...
I find the main problem is -- we use single EnsureHealthCheckResult for storing too much stuff. We should not store error there. Even if we want more context about errors (like now we use GceResourceInError), we should just create custom error type
But changing this will require changing too much logic...
hcResult also stores HCFirewallRuleName, that's why I passed it here, cause I don't want to create firewallName on the level above...

Copy link
Contributor

@code-elinka code-elinka Oct 24, 2022

Choose a reason for hiding this comment

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

I see. Yes, I tried to find a nice way to handle it and I would rather keep the error logic inside of the function. Thank you for the reasoning 👍

@code-elinka
Copy link
Contributor

LGTM. Thank you for this PR. I really like the last 2 commits. For first 2 refactoring commits: I think we could have much cleaner code with more linters :D

@panslava
Copy link
Contributor Author

/cc aojea

@k8s-ci-robot k8s-ci-robot requested a review from aojea October 24, 2022 21:52
pkg/backends/backends.go Outdated Show resolved Hide resolved
start := time.Now()
klog.V(2).Infof("EnsureL4BackendService(%v, %v, %v): started", name, scheme, protocol)
defer klog.V(2).Infof("EnsureL4BackendService(%v, %v, %v): finished, time taken: %v", name, scheme, protocol, time.Since(start))

klog.V(2).Infof("EnsureL4BackendService(%v, %v, %v): checking existing backend service", name, scheme, protocol)
Copy link
Contributor

Choose a reason for hiding this comment

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

this log is now redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really, we can remove, but it gives info about what step is happening (checking existing backend service)

pkg/healthchecksl4/healthchecksl4.go Outdated Show resolved Hide resolved
pkg/backends/backends.go Show resolved Hide resolved
pkg/healthchecksl4/healthchecksl4.go Outdated Show resolved Hide resolved
pkg/loadbalancers/l4netlb.go Outdated Show resolved Hide resolved
pkg/loadbalancers/l4netlb.go Outdated Show resolved Hide resolved
pkg/loadbalancers/forwarding_rules.go Outdated Show resolved Hide resolved
pkg/loadbalancers/forwarding_rules.go Outdated Show resolved Hide resolved
pkg/l4lb/l4netlbcontroller.go Outdated Show resolved Hide resolved
@panslava
Copy link
Contributor Author

@cezarygerard thanks for review, I fixed everything

@cezarygerard
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 Oct 25, 2022
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cezarygerard, panslava

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:
  • OWNERS [cezarygerard,panslava]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

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. 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