Skip to content

Commit c88486d

Browse files
tune polling on kubectl port forwarding to be a bit tighter
1 parent 81ae9f1 commit c88486d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

tui/DownloadSpinner.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ func doDownload(service conf.Service, profiling profilingOption, description str
135135
}
136136

137137
if service.Kube != nil {
138-
// kubectl port-forward services/service_name u.Port()
139138
serviceName := strings.TrimPrefix(service.Kube.Service, "services/")
140139
serviceName = strings.TrimPrefix(serviceName, "service/")
141140
cmd := exec.Command("kubectl", "port-forward", fmt.Sprintf("service/%s", serviceName), fmt.Sprintf("%s:%s", u.Port(), u.Port()))
@@ -157,14 +156,14 @@ func doDownload(service conf.Service, profiling profilingOption, description str
157156

158157
req, _ := http.NewRequest(http.MethodGet, fmt.Sprintf("http://127.0.0.1:%s", u.Port()), nil)
159158
for ctx.Err() == nil {
160-
ctx, cancel := context.WithTimeout(ctx, 1*time.Second)
159+
ctx, cancel := context.WithTimeout(ctx, 250*time.Millisecond)
161160
req.WithContext(ctx)
162161
res, err := http.DefaultClient.Do(req)
163162
cancel()
164163
if err == nil && res.StatusCode == 200 {
165164
break
166165
}
167-
time.Sleep(500 * time.Millisecond)
166+
time.Sleep(100 * time.Millisecond)
168167
}
169168
if ctx.Err() != nil {
170169
logrus.WithError(ctx.Err()).WithField("cmd", cmd.String()).Error("failed to start port-forward")

0 commit comments

Comments
 (0)