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

refactor: addLoadBalancer #217

Merged
merged 2 commits into from
Dec 26, 2024

Conversation

ianchen0119
Copy link
Contributor

No description provided.

@CLAassistant
Copy link

CLAassistant commented Dec 26, 2024

CLA assistant check
All committers have signed the CLA.

@ianchen0119
Copy link
Contributor Author

This pull request includes multiple changes to the loadbalancer package in the pkg/agent/manager/loadbalancer/loadbalancer.go file and introduces new constants in the pkg/api/lb.go file. These changes primarily focus on error handling improvements, annotation checks, and code simplification.

Error Handling Improvements:

  • Replaced standard fmt.Errorf with github.com/pkg/errors for better error wrapping and stack trace support. (pkg/agent/manager/loadbalancer/loadbalancer.go) [1] [2] [3] [4] [5] [6] [7]
  • Added error wrapping to provide more context in error messages. (pkg/agent/manager/loadbalancer/loadbalancer.go) [1] [2] [3] [4] [5]

Annotation Checks:

  • Simplified and corrected the logic for checking lbAddressAnnotation values. (pkg/agent/manager/loadbalancer/loadbalancer.go)
  • Refactored endPointSelAnnotation checks to use a switch statement for better readability and maintainability. (pkg/agent/manager/loadbalancer/loadbalancer.go)

Code Simplification:

  • Removed redundant klog.Errorf calls before returning errors. (pkg/agent/manager/loadbalancer/loadbalancer.go) [1] [2]
  • Replaced hardcoded values with new constants defined in pkg/api/lb.go, improving code readability and maintainability. (pkg/agent/manager/loadbalancer/loadbalancer.go) [1] [2]

New Constants:

  • Added new constants for load balancer modes in pkg/api/lb.go to replace magic numbers and string literals. (pkg/api/lb.go)

Import Adjustments:

  • Added github.com/pkg/errors to the import list and removed the unused errors package. (pkg/agent/manager/loadbalancer/loadbalancer.go) [1] [2]

@ianchen0119
Copy link
Contributor Author

Hi @TrekkieCoder

I refactored a part of the implementation for better readability.
Please help to review it when you feel free.

Tks!

@TrekkieCoder TrekkieCoder merged commit 8449947 into loxilb-io:main Dec 26, 2024
2 checks passed
@ianchen0119 ianchen0119 deleted the refactor/addLbFunc branch December 26, 2024 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants