-
Notifications
You must be signed in to change notification settings - Fork 18
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
Feature: enable multi pool client connections #577
Feature: enable multi pool client connections #577
Conversation
04334b8
to
d35c2ab
Compare
LGTM 👍 |
f90c704
to
391ee7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your awesome contribution! 🙏 This paves the way for further development.
I have left a few comments.
016dac1
to
491cad3
Compare
This commit introduces significant updates to enhance the handling of proxies within the server configuration and adds support for load balancing strategies. Changes: - Updated API tests to reflect changes from a single `Proxy` to a list of `Proxies`. - Adjusted initialization and configuration of proxies in `run.go` to support multiple proxies and load balancer strategies. - Updated configuration files to include new fields for multiple proxies and load balancer strategies. - Enhanced global configuration validation for clients, pools, and proxies. - Added new `loadBalancer` section in `gatewayd.yaml` for rules and strategies. - Implemented load balancing strategy selection and Round Robin strategy. - Added tests for load balancer strategies. - Added new error type `ErrorCodeLoadBalancerStrategyNotFound`. - Improved proxy connection handling and added informative comments. Configuration Example: - Updated `gatewayd.yaml` to reflect new support for multiple proxies and load balancer strategies. - Ensure to update your configuration files accordingly. Testing: - Updated existing tests and added new tests for multi-proxy and load balancing functionality. - Verified configuration validation for proxies and load balancers. Impact: - Improved flexibility and scalability of server configuration. - Enabled robust proxy management and efficient load distribution. Update errors/errors.go Co-authored-by: Mostafa Moradian <[email protected]> Signed-off-by: sina <[email protected]> fixed review problems
491cad3
to
585ed7f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🤞
- Change pools, clients, and proxies to use map[string]map[string] instead of map[string] - Update related code for compatibility with new nested map structure
remvoed server 2 from gatewatd.yaml file
…iles Updated variable names in the API, test files, run command, and configuration files to improve code readability and maintainability. Key changes include: 1. **api.go**: - Renamed `configurationGroupPools` to `configGroupPools` for clarity. 2. **api_helpers_test.go, api_test.go**: - Updated to use `config.DefaultConfigurationBlock` instead of `config.DefaultPool` and `config.DefaultProxy` for better naming consistency. 3. **run.go**: - Changed iteration variables to `configGroup` and `configBlockName` for better descriptive naming. - Updated logging and error handling to use `configBlockName`. - Modified span attribute naming for tracing proxy creation. 4. **config.go**: - Updated `DefaultPool`, `DefaultClient`, and `DefaultProxy` to `DefaultConfigurationBlock` in the `LoadDefaults` function. - Enhanced configuration parsing logic to handle `DefaultConfigurationBlock` appropriately and ensure robust error handling. 5. **constants.go**: - Renamed `DefaultClient`, `DefaultPool`, and `DefaultProxy` to `DefaultConfigurationBlock`. - Retained other configuration constants for environment prefix, tracer name, and configuration filenames. These changes enhance the codebase by standardizing variable names, improving readability, and making the code easier to maintain.
- Enhanced the Client struct by adding YAML tags to all fields, ensuring compatibility with YAML parsers. - Added YAML tags to the Size field in the Pool struct. - Included YAML tags for the HealthCheckPeriod field in the Proxy struct. These changes address limitations of the YAML parser and ensure proper serialization and deserialization of configuration data.
recent changes I made to the structure configuration. We were having issues, especially when dealing with multiple servers. If a second server went down, no logs were being generated. This happened because the logger was expecting a second instance (default-2), and when it wasn’t there, the logger wouldn’t work, and we couldn’t see any logs. Adding a second logger instance made the errors visible. Also, the metrics system was looking for default-2 and throwing errors when it couldn’t find it. To fix this, I changed the structure to match what was originally suggested in issue #398. Now, each server, client, pool, and proxy can have its own logger and metrics configuration, which should make things more reliable and scalable. |
pools[name] = map[string]interface{}{ | ||
"cap": p.Cap(), | ||
"size": p.Size(), | ||
pools := make(map[string]any) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self: plugins should be updated as well, as they rely on this API.
backoff: 1s # duration | ||
backoffMultiplier: 2.0 # 0 means no backoff | ||
disableBackoffCaps: false | ||
activeWrites: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fact this node appears let me think (I might be wrong) this is a breaking changes.
Is it true? Ia everyone OK with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is backward incompatible by design. We can have backward compatibility, but it will increase maintenance overhead in the long run. I'll add a warning to the release notes for this.
backoff: 1s # duration | ||
backoffMultiplier: 2.0 # 0 means no backoff | ||
disableBackoffCaps: false | ||
standbyReads: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find no reference of this on the code, while I found activeWrites.
Based on the code, I would say the code will look for any node.
So, is there a need to enforce people to use activeWrites node?
Couldn't we work on a logic of weight or something like that?(maybe another PR) So when no weight each node are equivalent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The activeWrites
and standbyReads
can be any name. When we created the nested structure for Clients, Pools, and Proxies, we needed to set names for them. I didn’t want to use default
because we already have a default
for the configuration group, which would be confusing. Therefore, I used activeWrites (copied from the issue description). Now, the default name for the configuration block (nested name for Clients, Pools, Proxies) is activeWrites. That’s why you will find references to activeWrites. standbyReads was added to gateway.yaml to follow the issue structure, meaning that the gateway can support multiple Proxies(maybe its better to remove it).
Co-authored-by: Mostafa Moradian <[email protected]> Signed-off-by: sina <[email protected]>
The |
- Modified the GetServers endpoint to return the current load balancer configuration for each server. - Added a new field "loadBalancer" to the server details, including the load balancer strategy name. - Updated unit tests to validate the new "loadBalancer" field in the API response. - Adjusted test setup to include the default load balancer strategy configuration.
Renamed short variable names used in type assertions to longer, more descriptive names to resolve golint warnings about variable name length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 🎉
@sinadarbouy Thanks for all your efforts and contribution! 🙏
@ccoVeille Thanks for the reviews! 🙏
@likecodingloveproblems Thanks for the initial PR! 🙏
I'll merge this PR and more load balancing strategies and features can be added in future PRs. We may also need to create seprate PRs for those features (and fixes).
Ticket(s)
#398
Closes #512
Description
This pull request introduces significant updates to enhance the handling of proxies within the server configuration and adds support for load balancing strategies. Below are the key changes and features included in this pull request:
Changes
Configuration Changes:
Load Balancer Implementation:
Configuration Examples:
Related PRs
Development Checklist
make gen-docs
command.Legal Checklist