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

xdsclient: always backoff between new streams even after successful stream #5280

Merged
merged 3 commits into from Apr 1, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 8 additions & 18 deletions xds/internal/xdsclient/controller/transport.go
Expand Up @@ -59,24 +59,18 @@ func (t *Controller) run(ctx context.Context) {
// report error (and log) when stats is transient failure.

retries := 0
first := true
for {
select {
case <-ctx.Done():
return
default:
}

if retries != 0 {
if !first {
timer := time.NewTimer(t.backoff(retries))
select {
case <-timer.C:
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
}
timer.Stop()
return
}
}
first = false

retries++
stream, err := t.vClient.NewStream(ctx, t.cc)
Expand Down Expand Up @@ -370,22 +364,18 @@ func (t *Controller) processAckInfo(ack *ackAction, stream grpc.ClientStream) (t
// It blocks until the context is cancelled.
func (t *Controller) reportLoad(ctx context.Context, cc *grpc.ClientConn, opts controllerversion.LoadReportingOptions) {
retries := 0
first := true
for {
if ctx.Err() != nil {
return
}

if retries != 0 {
if !first {
timer := time.NewTimer(t.backoff(retries))
select {
case <-timer.C:
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
}
timer.Stop()
return
}
}
first = false

retries++
stream, err := t.vClient.NewLoadStatsStream(ctx, cc)
Expand Down