write-tee: fix preferred backend selection#14427
Open
Conversation
Signed-off-by: Marco Pracucci <marco@pracucci.com>
Signed-off-by: Marco Pracucci <marco@pracucci.com>
|
Bugbot Autofix prepared fixes for 1 of the 1 bugs found in the latest run.
Or push these changes by commenting: Preview (b042879f33)diff --git a/tools/writetee/proxy.go b/tools/writetee/proxy.go
--- a/tools/writetee/proxy.go
+++ b/tools/writetee/proxy.go
@@ -141,8 +141,8 @@
// Parse mirrored backend endpoints (comma separated).
if cfg.BackendMirroredEndpoints != "" {
parts := strings.Split(cfg.BackendMirroredEndpoints, ",")
- for idx, part := range parts {
- backend, err := p.parseBackendEndpoint(part, idx, BackendTypeMirrored)
+ for _, part := range parts {
+ backend, err := p.parseBackendEndpoint(part, BackendTypeMirrored)
if err != nil {
return nil, err
}
@@ -155,9 +155,8 @@
// Parse amplified backend endpoints (comma separated).
if cfg.BackendAmplifiedEndpoints != "" {
parts := strings.Split(cfg.BackendAmplifiedEndpoints, ",")
- baseIdx := len(p.backends) // offset for numeric preferred backend matching
- for idx, part := range parts {
- backend, err := p.parseBackendEndpoint(part, baseIdx+idx, BackendTypeAmplified)
+ for _, part := range parts {
+ backend, err := p.parseBackendEndpoint(part, BackendTypeAmplified)
if err != nil {
return nil, err
}
@@ -213,7 +212,7 @@
return p, nil
}
-func (p *Proxy) parseBackendEndpoint(endpoint string, idx int, backendType BackendType) (ProxyBackend, error) {
+func (p *Proxy) parseBackendEndpoint(endpoint string, backendType BackendType) (ProxyBackend, error) {
// Skip empty ones.
endpoint = strings.TrimSpace(endpoint)
if endpoint == "" { |
Signed-off-by: Marco Pracucci <marco@pracucci.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What this PR does
In the test cluster we're using, we're currently configuring the mirrored backend == amplified backend == preferred backend. This means that both the mirrored and amplified backend are both marked as preferred, which means that when amplifying the traffic, the amplification is skipped because we have a check to ensure we never amplify to the preferred backend (because that's the sync one).
In this PR I'm changing the preferred backend logic. After rolling out this change, the traffic doubled in our test cluster (we configure it with amplification factor == 1):

Which issue(s) this PR fixes or relates to
Fixes #
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]. If changelog entry is not needed, please add thechangelog-not-neededlabel to the PR.about-versioning.mdupdated with experimental features.