Skip to content

Commit b1b2214

Browse files
Provide a nicer image build failed message (#20281)
* Provide a nicer image build failed message * an error message that actually shows up * Tweak error message * Make env retrieval consistent in supervisor config * Fix broken docs link in dashboard
1 parent 30b3c27 commit b1b2214

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

components/dashboard/src/prebuilds/detail/PrebuildDetailPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ export const PrebuildDetailPage: FC = () => {
296296
<div className="py-4 px-6 flex flex-col gap-1">
297297
<PrebuildStatus prebuild={prebuild} />
298298
{prebuild?.status?.message && (
299-
<div className="text-pk-content-secondary truncate">
299+
<div className="text-pk-content-secondary line-clamp-2">
300300
{prebuild?.status.message}
301301
</div>
302302
)}

components/dashboard/src/start/StartWorkspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ function ImageBuildView(props: ImageBuildViewProps) {
822822
💡 You can use the <code>gp validate</code> command to validate the workspace configuration
823823
from the editor terminal. &nbsp;
824824
<a
825-
href="https://www.gitpod.io/docs/configure/workspaces/workspace-image#trying-out-changes-to-your-dockerfile"
825+
href="https://www.gitpod.io/docs/configure/workspaces#validate-your-gitpod-configuration"
826826
target="_blank"
827827
rel="noopener noreferrer"
828828
className="gp-link"

components/server/src/workspace/workspace-starter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ export class WorkspaceStarter {
843843

844844
/**
845845
* failInstanceStart properly fails a workspace instance if something goes wrong before the instance ever reaches
846-
* workspace manager. In this case we need to make sure we also fulfil the tasks of the bridge (e.g. for prebulds).
846+
* workspace manager. In this case we need to make sure we also fulfil the tasks of the bridge (e.g. for prebuilds).
847847
*/
848848
private async failInstanceStart(ctx: TraceContext, err: any, workspace: Workspace, instance: WorkspaceInstance) {
849849
if (ctxIsAborted()) {
@@ -1344,7 +1344,10 @@ export class WorkspaceStarter {
13441344
`workspace image build failed: ${message}`,
13451345
{ looksLikeUserError: true },
13461346
);
1347-
err = new StartInstanceError("imageBuildFailedUser", err);
1347+
err = new StartInstanceError(
1348+
"imageBuildFailedUser",
1349+
`workspace image build failed: ${message}. For further logs, try executing \`gp validate\` inside of a workspace`,
1350+
);
13481351
// Don't report this as "failed" to our metrics as it would trigger an alert
13491352
} else {
13501353
log.error(

components/supervisor/pkg/supervisor/config.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ type WorkspaceConfig struct {
309309
// GitpodHeadless controls whether the workspace is running headless
310310
GitpodHeadless string `env:"GITPOD_HEADLESS"`
311311

312+
// BobDockerfilePath is the path to the Dockerfile image builder will attempt to build
313+
BobDockerfilePath string `env:"BOB_DOCKERFILE_PATH"`
314+
312315
// DebugEnabled controls whether the supervisor debugging facilities (pprof, grpc tracing) should be enabled
313316
DebugEnable bool `env:"SUPERVISOR_DEBUG_ENABLE"`
314317

@@ -468,6 +471,11 @@ func (c WorkspaceConfig) isDebugWorkspace() bool {
468471
return c.DebugWorkspaceType != api.DebugWorkspaceType_noDebug
469472
}
470473

474+
// isImageBuild returns true if the workspace is an image build.
475+
func (c WorkspaceConfig) isImageBuild() bool {
476+
return c.BobDockerfilePath != ""
477+
}
478+
471479
var contentSources = map[api.ContentSource]csapi.WorkspaceInitSource{
472480
api.ContentSource_from_other: csapi.WorkspaceInitFromOther,
473481
api.ContentSource_from_backup: csapi.WorkspaceInitFromBackup,

components/supervisor/pkg/supervisor/supervisor.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ func Run(options ...RunOption) {
465465

466466
if cfg.isHeadless() {
467467
wg.Add(1)
468-
go stopWhenTasksAreDone(ctx, &wg, shutdown, tasksSuccessChan)
468+
go stopWhenTasksAreDone(&wg, cfg, shutdown, tasksSuccessChan)
469469
} else if !opts.RunGP {
470470
wg.Add(1)
471471
go portMgmt.Run(ctx, &wg)
@@ -1593,15 +1593,20 @@ func tunnelOverSSH(ctx context.Context, tunneled *ports.TunneledPortsService, ne
15931593
<-ctx.Done()
15941594
}
15951595

1596-
func stopWhenTasksAreDone(ctx context.Context, wg *sync.WaitGroup, shutdown chan ShutdownReason, successChan <-chan taskSuccess) {
1596+
func stopWhenTasksAreDone(wg *sync.WaitGroup, cfg *Config, shutdown chan ShutdownReason, successChan <-chan taskSuccess) {
15971597
defer wg.Done()
15981598
defer close(shutdown)
15991599

16001600
success := <-successChan
16011601
if success.Failed() {
1602+
var msg []byte
1603+
if cfg.isImageBuild() {
1604+
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")
1605+
} else {
1606+
msg = []byte("headless task failed: " + string(success))
1607+
}
16021608
// we signal task failure via kubernetes termination log
1603-
msg := []byte("headless task failed: " + string(success))
1604-
err := ioutil.WriteFile("/dev/termination-log", msg, 0o644)
1609+
err := os.WriteFile("/dev/termination-log", msg, 0o644)
16051610
if err != nil {
16061611
log.WithError(err).Error("err while writing termination log")
16071612
}

0 commit comments

Comments
 (0)