From d483e85dfe208e75151a5be79c2a714b55c0a1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Thu, 3 Oct 2024 14:50:49 +0000 Subject: [PATCH 1/5] Provide a nicer image build failed message --- components/server/src/workspace/workspace-starter.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/server/src/workspace/workspace-starter.ts b/components/server/src/workspace/workspace-starter.ts index 9ad55f1f4b0fb3..a44d8df7d29bbd 100644 --- a/components/server/src/workspace/workspace-starter.ts +++ b/components/server/src/workspace/workspace-starter.ts @@ -1344,7 +1344,10 @@ export class WorkspaceStarter { `workspace image build failed: ${message}`, { looksLikeUserError: true }, ); - err = new StartInstanceError("imageBuildFailedUser", err); + err = new StartInstanceError( + "imageBuildFailedUser", + `workspace image build failed: ${message}. For further logs, try executing \`gp validate\` inside of a workspace`, + ); // Don't report this as "failed" to our metrics as it would trigger an alert } else { log.error( From b0782fb118764ae365f21c3b72d257dcc56070b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Thu, 10 Oct 2024 07:07:10 +0000 Subject: [PATCH 2/5] an error message that actually shows up --- .../server/src/workspace/workspace-starter.ts | 2 +- components/supervisor/pkg/supervisor/config.go | 5 +++++ components/supervisor/pkg/supervisor/supervisor.go | 13 +++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/components/server/src/workspace/workspace-starter.ts b/components/server/src/workspace/workspace-starter.ts index a44d8df7d29bbd..5bcc7c40194d63 100644 --- a/components/server/src/workspace/workspace-starter.ts +++ b/components/server/src/workspace/workspace-starter.ts @@ -843,7 +843,7 @@ export class WorkspaceStarter { /** * failInstanceStart properly fails a workspace instance if something goes wrong before the instance ever reaches - * workspace manager. In this case we need to make sure we also fulfil the tasks of the bridge (e.g. for prebulds). + * workspace manager. In this case we need to make sure we also fulfil the tasks of the bridge (e.g. for prebuilds). */ private async failInstanceStart(ctx: TraceContext, err: any, workspace: Workspace, instance: WorkspaceInstance) { if (ctxIsAborted()) { diff --git a/components/supervisor/pkg/supervisor/config.go b/components/supervisor/pkg/supervisor/config.go index 86ec6476d027ac..902158e824d337 100644 --- a/components/supervisor/pkg/supervisor/config.go +++ b/components/supervisor/pkg/supervisor/config.go @@ -468,6 +468,11 @@ func (c WorkspaceConfig) isDebugWorkspace() bool { return c.DebugWorkspaceType != api.DebugWorkspaceType_noDebug } +// isImageBuild returns true if the workspace is an image build. +func (c WorkspaceConfig) isImageBuild() bool { + return os.Getenv("BOB_DOCKERFILE_PATH") != "" +} + var contentSources = map[api.ContentSource]csapi.WorkspaceInitSource{ api.ContentSource_from_other: csapi.WorkspaceInitFromOther, api.ContentSource_from_backup: csapi.WorkspaceInitFromBackup, diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index 77320943313f92..5ad48214e91f3e 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -465,7 +465,7 @@ func Run(options ...RunOption) { if cfg.isHeadless() { wg.Add(1) - go stopWhenTasksAreDone(ctx, &wg, shutdown, tasksSuccessChan) + go stopWhenTasksAreDone(&wg, cfg, shutdown, tasksSuccessChan) } else if !opts.RunGP { wg.Add(1) go portMgmt.Run(ctx, &wg) @@ -1593,15 +1593,20 @@ func tunnelOverSSH(ctx context.Context, tunneled *ports.TunneledPortsService, ne <-ctx.Done() } -func stopWhenTasksAreDone(ctx context.Context, wg *sync.WaitGroup, shutdown chan ShutdownReason, successChan <-chan taskSuccess) { +func stopWhenTasksAreDone(wg *sync.WaitGroup, cfg *Config, shutdown chan ShutdownReason, successChan <-chan taskSuccess) { defer wg.Done() defer close(shutdown) success := <-successChan if success.Failed() { + var msg []byte + if cfg.isImageBuild() { + msg = []byte("image build failed with " + string(success) + ". For further logs, try executing `gp validate` inside of a workspace") + } else { + msg = []byte("headless task failed: " + string(success) + ". I have no idea if this is an image build or not 🤷‍♂️") + } // we signal task failure via kubernetes termination log - msg := []byte("headless task failed: " + string(success)) - err := ioutil.WriteFile("/dev/termination-log", msg, 0o644) + err := os.WriteFile("/dev/termination-log", msg, 0o644) if err != nil { log.WithError(err).Error("err while writing termination log") } From 2ccabda8b43801c9ae4de2a5bb5a469bfa26bae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Thu, 10 Oct 2024 11:08:58 +0000 Subject: [PATCH 3/5] Tweak error message --- .../dashboard/src/prebuilds/detail/PrebuildDetailPage.tsx | 2 +- components/supervisor/pkg/supervisor/supervisor.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/components/dashboard/src/prebuilds/detail/PrebuildDetailPage.tsx b/components/dashboard/src/prebuilds/detail/PrebuildDetailPage.tsx index f1636ee2b96298..cbc4349abaebac 100644 --- a/components/dashboard/src/prebuilds/detail/PrebuildDetailPage.tsx +++ b/components/dashboard/src/prebuilds/detail/PrebuildDetailPage.tsx @@ -296,7 +296,7 @@ export const PrebuildDetailPage: FC = () => {
{prebuild?.status?.message && ( -
+
{prebuild?.status.message}
)} diff --git a/components/supervisor/pkg/supervisor/supervisor.go b/components/supervisor/pkg/supervisor/supervisor.go index 5ad48214e91f3e..569289c04fa9f7 100644 --- a/components/supervisor/pkg/supervisor/supervisor.go +++ b/components/supervisor/pkg/supervisor/supervisor.go @@ -1601,9 +1601,9 @@ func stopWhenTasksAreDone(wg *sync.WaitGroup, cfg *Config, shutdown chan Shutdow if success.Failed() { var msg []byte if cfg.isImageBuild() { - msg = []byte("image build failed with " + string(success) + ". For further logs, try executing `gp validate` inside of a workspace") + msg = []byte("image build failed (" + string(success) + "). This is likely due to a misconfiguration in your Dockerfile. Debug this using `gp validate` (visit https://www.gitpod.io/docs/configure/workspaces#validate-your-gitpod-configuration) to learn more") } else { - msg = []byte("headless task failed: " + string(success) + ". I have no idea if this is an image build or not 🤷‍♂️") + msg = []byte("headless task failed: " + string(success)) } // we signal task failure via kubernetes termination log err := os.WriteFile("/dev/termination-log", msg, 0o644) From e1b1d794305bd66e05a93b2b8c492a069ec68d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Tue, 15 Oct 2024 08:40:57 +0000 Subject: [PATCH 4/5] Make env retrieval consistent in supervisor config --- components/supervisor/pkg/supervisor/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/supervisor/pkg/supervisor/config.go b/components/supervisor/pkg/supervisor/config.go index 902158e824d337..ef31fd25799c2a 100644 --- a/components/supervisor/pkg/supervisor/config.go +++ b/components/supervisor/pkg/supervisor/config.go @@ -309,6 +309,9 @@ type WorkspaceConfig struct { // GitpodHeadless controls whether the workspace is running headless GitpodHeadless string `env:"GITPOD_HEADLESS"` + // BobDockerfilePath is the path to the Dockerfile image builder will attempt to build + BobDockerfilePath string `env:"BOB_DOCKERFILE_PATH"` + // DebugEnabled controls whether the supervisor debugging facilities (pprof, grpc tracing) should be enabled DebugEnable bool `env:"SUPERVISOR_DEBUG_ENABLE"` @@ -470,7 +473,7 @@ func (c WorkspaceConfig) isDebugWorkspace() bool { // isImageBuild returns true if the workspace is an image build. func (c WorkspaceConfig) isImageBuild() bool { - return os.Getenv("BOB_DOCKERFILE_PATH") != "" + return c.BobDockerfilePath != "" } var contentSources = map[api.ContentSource]csapi.WorkspaceInitSource{ From e904d7b980817cf0c0b15fa24cfb127f10e1b632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Tron=C3=AD=C4=8Dek?= Date: Tue, 15 Oct 2024 08:41:11 +0000 Subject: [PATCH 5/5] Fix broken docs link in dashboard --- components/dashboard/src/start/StartWorkspace.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/dashboard/src/start/StartWorkspace.tsx b/components/dashboard/src/start/StartWorkspace.tsx index 505216670f8f54..633f5bd694ce13 100644 --- a/components/dashboard/src/start/StartWorkspace.tsx +++ b/components/dashboard/src/start/StartWorkspace.tsx @@ -822,7 +822,7 @@ function ImageBuildView(props: ImageBuildViewProps) { 💡 You can use the gp validate command to validate the workspace configuration from the editor terminal.