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

Always include one non-local target during discovery #583

Open
wants to merge 1 commit into
base: vtgateproxy-15
Choose a base branch
from

Conversation

henryr
Copy link

@henryr henryr commented Jan 16, 2025

In case an entire AZ, or other affinity group, fails at once it's useful to have one backup target in another AZ. So let's grab one every time we set the targets for a given pool. The target should be shuffle-sorted to the end of the target list, so in the normal state it should never get used.

@henryr henryr requested a review from a team as a code owner January 16, 2025 12:05
targets[poolType] = targets[poolType][:b.numConnections]
// Always grab one non-local target to protect against a complete local failure.
nonLocal := targets[poolType][len(targets[poolType])-1]
targets[poolType] = append(targets[poolType][:b.numConnections], nonLocal)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Pedantically you should probably only slice to [:b.numConnections-1] so that the total conns are still the number that we set, it's just only N-1 of them are AZ-affine?

@@ -323,7 +323,9 @@ func (b *JSONGateResolverBuilder) parse() (bool, error) {
for poolType := range targets {
b.sorter.shuffleSort(targets[poolType], b.affinityField, b.affinityValue)
if len(targets[poolType]) > *numConnections {

Choose a reason for hiding this comment

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

nit: preexisting code and no change in behavior, but this should be if len(targets[poolType]) > b.numConnections {

Copy link

This PR is being marked as stale because it has been open for 30 days with no activity. To rectify, you may do any of the following:

  • Push additional commits to the associated branch.
  • Remove the stale label.
  • Add a comment indicating why it is not stale.

If no action is taken within 7 days, this PR will be closed.

@github-actions github-actions bot added the Stale label Feb 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants