Skip to content

Commit db756b3

Browse files
authored
[loadgen] Resubscribe and log ids (#17080)
1 parent c828d41 commit db756b3

File tree

3 files changed

+47
-26
lines changed

3 files changed

+47
-26
lines changed

dev/loadgen/configs/prod-benchmark.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,29 @@ repos:
7878
score: 20
7979
workspaceImage: registry.hub.docker.com/gitpod/workspace-full:latest
8080
workspaceClass: "g1-large"
81+
environment:
82+
- name: "GITPOD_TASKS"
83+
value: "[{\"name\":\"Open port 1\",\"command\":\"gp ports visibility 6879:private\"},{\"name\":\"Open port 2\",\"command\":\"gp ports visibility 7869:private\"}]"
8184
- cloneURL: https://github.com/gitpod-io/template-typescript-react
8285
cloneTarget: main
8386
score: 20
8487
workspaceImage: registry.hub.docker.com/gitpod/workspace-full:latest
8588
workspaceClass: "default"
89+
environment:
90+
- name: "GITPOD_TASKS"
91+
value: "[{\"name\":\"Open port 1\",\"command\":\"gp ports visibility 6879:private\"},{\"name\":\"Open port 2\",\"command\":\"gp ports visibility 7869:private\"}]"
8692
- cloneURL: https://github.com/gitpod-io/template-python-django
8793
cloneTarget: main
8894
score: 20
8995
workspaceImage: registry.hub.docker.com/gitpod/workspace-full:latest
9096
workspaceClass: "gitpodio-internal-xl"
97+
environment:
98+
- name: "GITPOD_TASKS"
99+
value: "[{\"name\":\"Open port 1\",\"command\":\"gp ports visibility 6879:private\"},{\"name\":\"Open port 2\",\"command\":\"gp ports visibility 7869:private\"}]"
91100
- cloneURL: https://github.com/gitpod-io/non-gitpodified-repo
92101
score: 20
93102
cloneTarget: main
94103
workspaceImage: registry.hub.docker.com/gitpod/workspace-full:latest
104+
environment:
105+
- name: "GITPOD_TASKS"
106+
value: "[{\"name\":\"Open port 1\",\"command\":\"gp ports visibility 6879:private\"},{\"name\":\"Open port 2\",\"command\":\"gp ports visibility 7869:private\"}]"

dev/loadgen/pkg/loadgen/executor.go

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"context"
99
"encoding/json"
1010
"fmt"
11-
"io"
1211
"math/rand"
1312
"os"
1413
"sync"
@@ -158,36 +157,45 @@ func (w *WsmanExecutor) Observe() (<-chan WorkspaceUpdate, error) {
158157
ctx, cancel := context.WithCancel(context.Background())
159158
w.Sub = append(w.Sub, cancel)
160159

161-
sub, err := w.C.Subscribe(ctx, &api.SubscribeRequest{
162-
MustMatch: w.loadgenSessionFilter(),
163-
})
164-
if err != nil {
165-
return nil, err
166-
}
167160
go func() {
168161
defer close(res)
169162
for {
170-
resp, err := sub.Recv()
163+
sub, err := w.C.Subscribe(ctx, &api.SubscribeRequest{
164+
MustMatch: w.loadgenSessionFilter(),
165+
})
171166
if err != nil {
172-
if err != io.EOF && status.Code(err) != codes.Canceled {
173-
log.WithError(err).Warn("subscription failure")
174-
}
175-
return
176-
}
177-
status := resp.GetStatus()
178-
if status == nil {
167+
log.WithError(err).Warn("failed to subscribe to ws-manager, retrying...")
168+
time.Sleep(5 * time.Second)
179169
continue
180170
}
181171

182-
res <- WorkspaceUpdate{
183-
InstanceID: status.Id,
184-
WorkspaceID: status.Metadata.MetaId,
185-
OwnerID: status.Metadata.Owner,
186-
Failed: status.Conditions.Failed != "",
187-
Phase: status.Phase,
172+
for {
173+
resp, err := sub.Recv()
174+
if err != nil {
175+
if status.Code(err) != codes.Canceled {
176+
log.WithError(err).Warn("lost connection to ws-manager, retrying...")
177+
time.Sleep(5 * time.Second)
178+
// Break and resubscribe.
179+
break
180+
}
181+
return
182+
}
183+
status := resp.GetStatus()
184+
if status == nil {
185+
continue
186+
}
187+
188+
res <- WorkspaceUpdate{
189+
InstanceID: status.Id,
190+
WorkspaceID: status.Metadata.MetaId,
191+
OwnerID: status.Metadata.Owner,
192+
Failed: status.Conditions.Failed != "",
193+
Phase: status.Phase,
194+
}
188195
}
189196
}
190197
}()
198+
191199
return res, nil
192200
}
193201

dev/loadgen/pkg/observer/success.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package observer
77
import (
88
"context"
99
"fmt"
10+
"strings"
1011
"sync"
1112
"time"
1213

@@ -73,13 +74,13 @@ func (o *SuccessObserver) Wait(ctx context.Context, expected int) error {
7374
case <-ticker.C:
7475
o.m.Lock()
7576
running := 0
76-
stopped := 0
77-
for _, ws := range o.workspaces {
77+
var stopped []string
78+
for id, ws := range o.workspaces {
7879
switch ws.Phase {
7980
case api.WorkspacePhase_RUNNING:
8081
running += 1
8182
case api.WorkspacePhase_STOPPED:
82-
stopped += 1
83+
stopped = append(stopped, id)
8384
}
8485
}
8586

@@ -88,9 +89,9 @@ func (o *SuccessObserver) Wait(ctx context.Context, expected int) error {
8889
}
8990

9091
// Quit early if too many workspaces have stopped already. They'll never become ready.
91-
maxRunning := len(o.workspaces) - stopped
92+
maxRunning := len(o.workspaces) - len(stopped)
9293
if float32(maxRunning) < float32(len(o.workspaces))*o.successRate {
93-
return fmt.Errorf("too many workspaces in stopped state (%d), will never get enough ready workspaces", stopped)
94+
return fmt.Errorf("too many workspaces in stopped state (%d), will never get enough ready workspaces. Stopped workspaces: %v", len(stopped), strings.Join(stopped, ", "))
9495
}
9596

9697
o.m.Unlock()

0 commit comments

Comments
 (0)