Skip to content

Commit b0782fb

Browse files
committed
an error message that actually shows up
1 parent d483e85 commit b0782fb

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
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()) {

components/supervisor/pkg/supervisor/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,11 @@ func (c WorkspaceConfig) isDebugWorkspace() bool {
468468
return c.DebugWorkspaceType != api.DebugWorkspaceType_noDebug
469469
}
470470

471+
// isImageBuild returns true if the workspace is an image build.
472+
func (c WorkspaceConfig) isImageBuild() bool {
473+
return os.Getenv("BOB_DOCKERFILE_PATH") != ""
474+
}
475+
471476
var contentSources = map[api.ContentSource]csapi.WorkspaceInitSource{
472477
api.ContentSource_from_other: csapi.WorkspaceInitFromOther,
473478
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 with " + string(success) + ". For further logs, try executing `gp validate` inside of a workspace")
1605+
} else {
1606+
msg = []byte("headless task failed: " + string(success) + ". I have no idea if this is an image build or not 🤷‍♂️")
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)