From d0fc9e550375647862b62c11b8a3ecc5b02374b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Tue, 7 Nov 2023 18:49:32 +0000 Subject: [PATCH] Fix `ws start` status logging --- components/local-app/pkg/helper/workspace.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/local-app/pkg/helper/workspace.go b/components/local-app/pkg/helper/workspace.go index 983816a08c85c3..f75e84c3747562 100644 --- a/components/local-app/pkg/helper/workspace.go +++ b/components/local-app/pkg/helper/workspace.go @@ -164,9 +164,11 @@ func ObserveWorkspaceUntilStarted(ctx context.Context, clnt *client.Gitpod, work return ws.Status, nil } + var wsStatus string slog.Info("waiting for workspace to start...", "workspaceID", workspaceID) if HasInstanceStatus(wsInfo.Msg.Result) { - slog.Info("workspace " + prettyprint.FormatWorkspacePhase(wsInfo.Msg.Result.Status.Instance.Status.Phase)) + slog.Info("workspace status: " + prettyprint.FormatWorkspacePhase(wsInfo.Msg.Result.Status.Instance.Status.Phase)) + wsStatus = prettyprint.FormatWorkspacePhase(wsInfo.Msg.Result.Status.Instance.Status.Phase) } var ( @@ -186,7 +188,6 @@ func ObserveWorkspaceUntilStarted(ctx context.Context, clnt *client.Gitpod, work continue } - previousStatus := "" for stream.Receive() { msg := stream.Msg() if msg == nil { @@ -200,13 +201,13 @@ func ObserveWorkspaceUntilStarted(ctx context.Context, clnt *client.Gitpod, work return ws, nil } - var currentStatus string if HasInstanceStatus(wsInfo.Msg.Result) { - currentStatus = prettyprint.FormatWorkspacePhase(wsInfo.Msg.Result.Status.Instance.Status.Phase) - } - if currentStatus != previousStatus { - slog.Info("workspace " + currentStatus) - previousStatus = currentStatus + newWsStatus := prettyprint.FormatWorkspacePhase(ws.Instance.Status.Phase) + // De-duplicate status messages + if wsStatus != newWsStatus { + slog.Info("workspace status: " + newWsStatus) + wsStatus = newWsStatus + } } } if err := stream.Err(); err != nil {