Skip to content

Commit

Permalink
fix: cli port-forward fails with high network latency (#4632)
Browse files Browse the repository at this point in the history
  • Loading branch information
emosbaugh authored May 21, 2024
1 parent 5d825ed commit d0ba962
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions pkg/k8sutil/portforward.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,15 @@ func PortForward(localPort int, remotePort int, namespace string, getPodName fun
if err == nil && response.StatusCode == http.StatusOK {
break
}
if time.Now().Sub(start) > time.Duration(time.Second*10) {
if time.Since(start) > time.Duration(time.Second*10) {
if err == nil {
err = errors.Errorf("service responded with status %s", response.Status)
}
return 0, nil, errors.Wrap(err, "failed to query healthz")
}

time.Sleep(time.Millisecond * 100)
if quickClient.Timeout < time.Second {
quickClient.Timeout = quickClient.Timeout + time.Millisecond*100
}
quickClient.Timeout *= 2 // 200ms, 400ms, 800ms, 1.6s, 3.2s, 6.4s
}

if pollForAdditionalPorts {
Expand Down

0 comments on commit d0ba962

Please sign in to comment.