Skip to content

Commit 13cf10a

Browse files
committed
Better builder bob errors from supervisor
1 parent bee3be2 commit 13cf10a

File tree

4 files changed

+29
-7
lines changed

4 files changed

+29
-7
lines changed

components/image-builder-bob/cmd/build.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
package cmd
66

77
import (
8+
"errors"
89
"os"
10+
"strings"
911
"time"
1012

1113
"github.com/spf13/cobra"
@@ -32,6 +34,14 @@ var buildCmd = &cobra.Command{
3234

3335
cfg, err := builder.GetConfigFromEnv()
3436
if err != nil {
37+
if errors.Is(err, builder.DockerfilePathNotExists) {
38+
dockerfilePath := strings.TrimPrefix(os.Getenv("BOB_DOCKERFILE_PATH"), "/workspace/")
39+
err = os.WriteFile("/workspace/.gitpod/bob.log", []byte("could not find Dockerfile at \""+dockerfilePath+"\". Please double-check the value specified in image.file in .gitpod.yml"), 0644)
40+
if err != nil {
41+
log.WithError(err).Error("cannot write init message to /workspace/.gitpod/bob.log")
42+
}
43+
}
44+
3545
log.WithError(err).Fatal("cannot get config")
3646
return
3747
}
@@ -43,6 +53,11 @@ var buildCmd = &cobra.Command{
4353
if err != nil {
4454
log.WithError(err).Error("build failed")
4555

56+
err := os.WriteFile("/workspace/.gitpod/bob.log", []byte(err.Error()), 0644)
57+
if err != nil {
58+
log.WithError(err).Error("cannot write error to /workspace/.gitpod/bob.log")
59+
}
60+
4661
// make sure we're running long enough to have our logs read
4762
if dt := time.Since(t0); dt < 5*time.Second {
4863
time.Sleep(10 * time.Second)

components/image-builder-bob/pkg/builder/config.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ type Config struct {
2929
localCacheImport string
3030
}
3131

32+
var DockerfilePathNotExists = xerrors.Errorf("BOB_DOCKERFILE_PATH does not exist or isn't a file")
33+
3234
// GetConfigFromEnv extracts configuration from environment variables
3335
func GetConfigFromEnv() (*Config, error) {
3436
cfg := &Config{
@@ -63,7 +65,7 @@ func GetConfigFromEnv() (*Config, error) {
6365
return nil, xerrors.Errorf("BOB_DOCKERFILE_PATH must begin with /workspace")
6466
}
6567
if stat, err := os.Stat(cfg.Dockerfile); err != nil || stat.IsDir() {
66-
return nil, xerrors.Errorf("BOB_DOCKERFILE_PATH does not exist or isn't a file")
68+
return nil, DockerfilePathNotExists
6769
}
6870
}
6971

components/server/src/github/file-provider.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ export class GithubFileProvider implements FileProvider {
3232
const notFoundError = new Error(
3333
`File ${path} does not exist in repository ${repository.owner}/${repository.name}`,
3434
);
35-
const fileExists =
36-
(await this.getFileContent({ repository, revision: revisionOrBranch }, user, path)) !== undefined;
37-
if (!fileExists) {
38-
throw notFoundError;
39-
}
35+
// const fileExists =
36+
// (await this.getFileContent({ repository, revision: revisionOrBranch }, user, path)) !== undefined;
37+
// if (!fileExists) {
38+
// throw notFoundError;
39+
// }
4040

4141
const commits = (
4242
await this.githubApi.run(user, (gh) =>

components/supervisor/pkg/supervisor/supervisor.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1601,7 +1601,12 @@ func stopWhenTasksAreDone(wg *sync.WaitGroup, cfg *Config, shutdown chan Shutdow
16011601
if success.Failed() {
16021602
var msg []byte
16031603
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")
1604+
logFromFile, err := os.ReadFile("/workspace/.gitpod/bob.log")
1605+
if err != nil {
1606+
msg = []byte("err while reading bob.log" + err.Error())
1607+
} else {
1608+
msg = []byte("image build failed: " + string(logFromFile) + ". Debug this using `gp validate` (visit https://www.gitpod.io/docs/configure/workspaces#validate-your-gitpod-configuration) to learn more")
1609+
}
16051610
} else {
16061611
msg = []byte("headless task failed: " + string(success))
16071612
}

0 commit comments

Comments
 (0)