Skip to content

Commit

Permalink
watchtower/wtclient: only reset iterator once we've exhausted all can…
Browse files Browse the repository at this point in the history
…didates

Doing so allows us to load balance sessions better amongst all of the
tower candidates.
  • Loading branch information
wpaulino committed Jul 30, 2019
1 parent 0431701 commit 0690c8f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions watchtower/wtclient/session_negotiator.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,6 @@ retryWithBackoff:
}
}

// Before attempting a bout of session negotiation, reset the candidate
// iterator to ensure the results are fresh.
n.cfg.Candidates.Reset()
for {
select {
case <-n.quit:
Expand All @@ -267,6 +264,13 @@ retryWithBackoff:
log.Debugf("Unable to get new tower candidate, "+
"retrying after %v -- reason: %v", backoff, err)

// Only reset the iterator once we've exhausted all
// candidates. Doing so allows us to load balance
// sessions better amongst all of the tower candidates.
if err == ErrTowerCandidatesExhausted {
n.cfg.Candidates.Reset()
}

goto retryWithBackoff
}

Expand Down

0 comments on commit 0690c8f

Please sign in to comment.