Skip to content

Commit 3b5181e

Browse files
committed
[ws-manager-mk2] Enable tracing, add debug logs
1 parent 1631a4a commit 3b5181e

File tree

5 files changed

+29
-3
lines changed

5 files changed

+29
-3
lines changed

components/ws-manager-mk2/controllers/status.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func updateWorkspaceStatus(ctx context.Context, workspace *workspacev1.Workspace
179179
workspace.Status.Phase = workspacev1.WorkspacePhaseUnknown
180180

181181
default:
182-
log.Info("cannot determine workspace phase")
182+
log.Info("cannot determine workspace phase", "podStatus", pod.Status)
183183
workspace.Status.Phase = workspacev1.WorkspacePhaseUnknown
184184

185185
}

components/ws-manager-mk2/controllers/workspace_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
109109

110110
r.updateMetrics(ctx, &workspace)
111111

112+
log.V(1).Info("updated workspace status", "status", workspace.Status)
112113
err = r.Status().Update(ctx, &workspace)
113114
if err != nil {
114115
// log.WithValues("status", workspace).Error(err, "unable to update workspace status")

components/ws-manager-mk2/main.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
_ "k8s.io/client-go/plugin/pkg/client/auth"
2121

2222
grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
23+
"github.com/prometheus/client_golang/prometheus"
2324
"k8s.io/apimachinery/pkg/runtime"
2425
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2526
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
@@ -32,6 +33,7 @@ import (
3233
common_grpc "github.com/gitpod-io/gitpod/common-go/grpc"
3334
"github.com/gitpod-io/gitpod/common-go/log"
3435
"github.com/gitpod-io/gitpod/common-go/pprof"
36+
"github.com/gitpod-io/gitpod/common-go/tracing"
3537
imgbldr "github.com/gitpod-io/gitpod/image-builder/api"
3638
regapi "github.com/gitpod-io/gitpod/registry-facade/api"
3739
wsmanapi "github.com/gitpod-io/gitpod/ws-manager/api"
@@ -71,6 +73,19 @@ func main() {
7173
flag.Parse()
7274

7375
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
76+
promrep := &tracing.PromReporter{
77+
Operations: map[string]tracing.SpanMetricMapping{
78+
"StartWorkspace": {
79+
Name: "wsman_start_workspace",
80+
Help: "time it takes to service a StartWorkspace request",
81+
Buckets: prometheus.LinearBuckets(0, 500, 10), // 10 buckets, each 500ms wide
82+
},
83+
},
84+
}
85+
closer := tracing.Init("ws-manager-mk2", tracing.WithPrometheusReporter(promrep))
86+
if closer != nil {
87+
defer closer.Close()
88+
}
7489

7590
cfg, err := getConfig(configFN)
7691
if err != nil {

dev/loadgen/pkg/loadgen/executor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ func (w *WsmanExecutor) StopAll(ctx context.Context) error {
211211

212212
_, err := w.C.StopWorkspace(ctx, &stopReq)
213213
if err != nil {
214-
log.Warnf("failed to stop %s", id)
214+
log.Warnf("failed to stop %s: %v", id, err)
215215
}
216216
}
217217

dev/loadgen/pkg/observer/success.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,26 @@ func (o *SuccessObserver) Wait(ctx context.Context, expected int) error {
7373
case <-ticker.C:
7474
o.m.Lock()
7575
running := 0
76+
stopped := 0
7677
for _, ws := range o.workspaces {
77-
if ws.Phase == api.WorkspacePhase_RUNNING {
78+
switch ws.Phase {
79+
case api.WorkspacePhase_RUNNING:
7880
running += 1
81+
case api.WorkspacePhase_STOPPED:
82+
stopped += 1
7983
}
8084
}
8185

8286
if float32(running) >= float32(len(o.workspaces))*o.successRate {
8387
return nil
8488
}
8589

90+
// Quit early if too many workspaces have stopped already. They'll never become ready.
91+
maxRunning := len(o.workspaces) - stopped
92+
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+
}
95+
8696
o.m.Unlock()
8797
case <-ctx.Done():
8898
o.m.Lock()

0 commit comments

Comments
 (0)