Skip to content

[ws-manager-mk2] Enable tracing, add debug logs #16643

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

Merged
merged 1 commit into from
Mar 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/ws-manager-mk2/controllers/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func updateWorkspaceStatus(ctx context.Context, workspace *workspacev1.Workspace
workspace.Status.Phase = workspacev1.WorkspacePhaseUnknown

default:
log.Info("cannot determine workspace phase")
log.Info("cannot determine workspace phase", "podStatus", pod.Status)
workspace.Status.Phase = workspacev1.WorkspacePhaseUnknown

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (r *WorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (

r.updateMetrics(ctx, &workspace)

log.V(1).Info("updated workspace status", "status", workspace.Status)
err = r.Status().Update(ctx, &workspace)
if err != nil {
// log.WithValues("status", workspace).Error(err, "unable to update workspace status")
Expand Down
15 changes: 15 additions & 0 deletions components/ws-manager-mk2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
_ "k8s.io/client-go/plugin/pkg/client/auth"

grpc_prometheus "github.com/grpc-ecosystem/go-grpc-prometheus"
"github.com/prometheus/client_golang/prometheus"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
Expand All @@ -32,6 +33,7 @@ import (
common_grpc "github.com/gitpod-io/gitpod/common-go/grpc"
"github.com/gitpod-io/gitpod/common-go/log"
"github.com/gitpod-io/gitpod/common-go/pprof"
"github.com/gitpod-io/gitpod/common-go/tracing"
imgbldr "github.com/gitpod-io/gitpod/image-builder/api"
regapi "github.com/gitpod-io/gitpod/registry-facade/api"
wsmanapi "github.com/gitpod-io/gitpod/ws-manager/api"
Expand Down Expand Up @@ -71,6 +73,19 @@ func main() {
flag.Parse()

ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
promrep := &tracing.PromReporter{
Operations: map[string]tracing.SpanMetricMapping{
"StartWorkspace": {
Name: "wsman_start_workspace",
Help: "time it takes to service a StartWorkspace request",
Buckets: prometheus.LinearBuckets(0, 500, 10), // 10 buckets, each 500ms wide
},
},
}
closer := tracing.Init("ws-manager-mk2", tracing.WithPrometheusReporter(promrep))
if closer != nil {
defer closer.Close()
}

cfg, err := getConfig(configFN)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion dev/loadgen/pkg/loadgen/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (w *WsmanExecutor) StopAll(ctx context.Context) error {

_, err := w.C.StopWorkspace(ctx, &stopReq)
if err != nil {
log.Warnf("failed to stop %s", id)
log.Warnf("failed to stop %s: %v", id, err)
}
}

Expand Down
12 changes: 11 additions & 1 deletion dev/loadgen/pkg/observer/success.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,26 @@ func (o *SuccessObserver) Wait(ctx context.Context, expected int) error {
case <-ticker.C:
o.m.Lock()
running := 0
stopped := 0
for _, ws := range o.workspaces {
if ws.Phase == api.WorkspacePhase_RUNNING {
switch ws.Phase {
case api.WorkspacePhase_RUNNING:
running += 1
case api.WorkspacePhase_STOPPED:
stopped += 1
}
}

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

// Quit early if too many workspaces have stopped already. They'll never become ready.
maxRunning := len(o.workspaces) - stopped
if float32(maxRunning) < float32(len(o.workspaces))*o.successRate {
return fmt.Errorf("too many workspaces in stopped state (%d), will never get enough ready workspaces", stopped)
}

o.m.Unlock()
case <-ctx.Done():
o.m.Lock()
Expand Down