Skip to content

Provide a nicer image build failed message #20281

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 5 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ export const PrebuildDetailPage: FC = () => {
<div className="py-4 px-6 flex flex-col gap-1">
<PrebuildStatus prebuild={prebuild} />
{prebuild?.status?.message && (
<div className="text-pk-content-secondary truncate">
<div className="text-pk-content-secondary line-clamp-2">
{prebuild?.status.message}
</div>
)}
Expand Down
7 changes: 5 additions & 2 deletions components/server/src/workspace/workspace-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down Expand Up @@ -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(
Expand Down
5 changes: 5 additions & 0 deletions components/supervisor/pkg/supervisor/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") != ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Other config will read env when init, we should do it the same for isImageBuild to align with others

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out, fixed in e1b1d79 (#20281).

}

var contentSources = map[api.ContentSource]csapi.WorkspaceInitSource{
api.ContentSource_from_other: csapi.WorkspaceInitFromOther,
api.ContentSource_from_backup: csapi.WorkspaceInitFromBackup,
Expand Down
13 changes: 9 additions & 4 deletions components/supervisor/pkg/supervisor/supervisor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 (" + 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))
}
// 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")
}
Expand Down
Loading