status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
βŒ€
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
dagger/dagger
https://github.com/dagger/dagger
4,051
Fix lint errors on nodejs engine bump
The automatic engine bump PR seems to generate code that the nodejs linter disagrees with, requiring manual updates to the PR whenever it's opened, e.g. https://github.com/dagger/dagger/actions/runs/3586757292/jobs/6036336215
https://github.com/dagger/dagger/issues/4051
https://github.com/dagger/dagger/pull/4072
ec51da155e85ecda92ba6c14812d567f37269f8a
bec73f147a6901d77aca780b5386434b27863cdf
2022-11-30T20:20:05Z
go
2022-12-01T23:00:13Z
internal/mage/sdk/nodejs.go
} func (t Nodejs) Test(ctx context.Context) error { c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { return err } defer c.Close() _, err = nodeJsBase(c). WithMountedDirectory("/root/.docker", util.HostDockerDir(c)). WithExec([]string{"yarn", "test"}, dagger.ContainerWithExecOpts{ ExperimentalPrivilegedNesting: true, }). ExitCode(ctx) return err } func (t Nodejs) Generate(ctx context.Context) error { c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { return err } defer c.Close() generated, err := nodeJsBase(c). WithMountedFile("/usr/local/bin/client-gen", util.ClientGenBinary(c)). WithExec([]string{"client-gen", "--lang", "nodejs", "-o", nodejsGeneratedAPIPath}, dagger.ContainerWithExecOpts{ ExperimentalPrivilegedNesting: true, }). WithExec([]string{ "yarn", "fmt", nodejsGeneratedAPIPath,
closed
dagger/dagger
https://github.com/dagger/dagger
4,051
Fix lint errors on nodejs engine bump
The automatic engine bump PR seems to generate code that the nodejs linter disagrees with, requiring manual updates to the PR whenever it's opened, e.g. https://github.com/dagger/dagger/actions/runs/3586757292/jobs/6036336215
https://github.com/dagger/dagger/issues/4051
https://github.com/dagger/dagger/pull/4072
ec51da155e85ecda92ba6c14812d567f37269f8a
bec73f147a6901d77aca780b5386434b27863cdf
2022-11-30T20:20:05Z
go
2022-12-01T23:00:13Z
internal/mage/sdk/nodejs.go
}). File(nodejsGeneratedAPIPath). Contents(ctx) if err != nil { return err } return os.WriteFile(nodejsGeneratedAPIPath, []byte(generated), 0o600) } func (t Nodejs) Publish(ctx context.Context, tag string) error { c, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr)) if err != nil { return err } defer c.Close() var ( version = strings.TrimPrefix(tag, "sdk/nodejs/v") token, _ = util.WithSetHostVar(ctx, c.Host(), "NPM_TOKEN").Secret().Plaintext(ctx) ) build := nodeJsBase(c).WithExec([]string{"npm", "run", "build"}) npmrc := fmt.Sprintf(`//registry.npmjs.org/:_authToken=%s registry=https://registry.npmjs.org/ always-auth=true`, token) if err = os.WriteFile("sdk/nodejs/.npmrc", []byte(npmrc), 0o600); err != nil { return err } _, err = build. WithExec([]string{"npm", "version", version}). WithExec([]string{"npm", "publish", "--access", "public"}).
closed
dagger/dagger
https://github.com/dagger/dagger
4,051
Fix lint errors on nodejs engine bump
The automatic engine bump PR seems to generate code that the nodejs linter disagrees with, requiring manual updates to the PR whenever it's opened, e.g. https://github.com/dagger/dagger/actions/runs/3586757292/jobs/6036336215
https://github.com/dagger/dagger/issues/4051
https://github.com/dagger/dagger/pull/4072
ec51da155e85ecda92ba6c14812d567f37269f8a
bec73f147a6901d77aca780b5386434b27863cdf
2022-11-30T20:20:05Z
go
2022-12-01T23:00:13Z
internal/mage/sdk/nodejs.go
ExitCode(ctx) return err } func (t Nodejs) Bump(ctx context.Context, version string) error { engineReference := fmt.Sprintf("// Code generated by dagger. DO NOT EDIT.\n"+ "const DEFAULT_IMAGE_REF = %q;\n\n"+ "export const DEFAULT_HOST = `docker-image://${DEFAULT_IMAGE_REF}`\n", version) return os.WriteFile("sdk/nodejs/provisioning/default.ts", []byte(engineReference), 0o600) } func nodeJsBase(c *dagger.Client) *dagger.Container { workdir := c.Directory().WithDirectory("/", util.Repository(c).Directory("sdk/nodejs")) base := c.Container(). // ⚠️ Keep this in sync with the engine version defined in package.json From("node:16-alpine"). WithWorkdir("/workdir") deps := base.WithRootfs( base. Rootfs(). WithFile("/workdir/package.json", workdir.File("package.json")). WithFile("/workdir/yarn.lock", workdir.File("yarn.lock")), ). WithExec([]string{"yarn", "install"}) src := deps.WithRootfs( deps. Rootfs(). WithDirectory("/workdir", workdir), ) return src }
closed
dagger/dagger
https://github.com/dagger/dagger
4,020
cli: `dagger do` with warning message
## Problem The new `dagger` CLI (0.3) works very differently from the old one (0.2). This can confuse some users who upgrade, run the typical `dagger do` command from 0.2, and get a "command not found". ## Solution Implement a hidden `dagger do` command in 0.3, which does nothing but prints a message explaining the change and where to go to navigate it.
https://github.com/dagger/dagger/issues/4020
https://github.com/dagger/dagger/pull/4071
f378cabc6254b69fc1f4765d3c83e57e12057841
c8e90811f74d0ea13508e4bfaede11046b3fa522
2022-11-29T18:01:17Z
go
2022-12-02T05:38:57Z
cmd/dagger/main.go
package main import ( "fmt" "os" "github.com/dagger/dagger/engine" "github.com/dagger/dagger/tracing" "github.com/spf13/cobra" ) var ( configPath string workdir string debugLogs bool ) func init() {
closed
dagger/dagger
https://github.com/dagger/dagger
4,020
cli: `dagger do` with warning message
## Problem The new `dagger` CLI (0.3) works very differently from the old one (0.2). This can confuse some users who upgrade, run the typical `dagger do` command from 0.2, and get a "command not found". ## Solution Implement a hidden `dagger do` command in 0.3, which does nothing but prints a message explaining the change and where to go to navigate it.
https://github.com/dagger/dagger/issues/4020
https://github.com/dagger/dagger/pull/4071
f378cabc6254b69fc1f4765d3c83e57e12057841
c8e90811f74d0ea13508e4bfaede11046b3fa522
2022-11-29T18:01:17Z
go
2022-12-02T05:38:57Z
cmd/dagger/main.go
rootCmd.PersistentFlags().StringVar(&workdir, "workdir", ".", "The host workdir loaded into dagger") rootCmd.PersistentFlags().BoolVar(&debugLogs, "debug", false, "show buildkit debug logs") rootCmd.AddCommand( listenCmd, versionCmd, queryCmd, runCmd, ) } var rootCmd = &cobra.Command{ Use: "dagger", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { var err error workdir, configPath, err = engine.NormalizePaths(workdir, configPath) return err }, } func main() { closer := tracing.Init() if err := rootCmd.Execute(); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) closer.Close() os.Exit(1) } closer.Close() }
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/client-gen/main.go
package main import ( "context" "fmt" "go/parser" "go/token" "os" "path" "path/filepath" "strings" "github.com/spf13/cobra" "dagger.io/dagger" "github.com/dagger/dagger/codegen/generator" gogenerator "github.com/dagger/dagger/codegen/generator/go" nodegenerator "github.com/dagger/dagger/codegen/generator/nodejs" "github.com/dagger/dagger/codegen/introspection" "github.com/dagger/dagger/tracing" ) var ( configPath string workdir string ) var rootCmd = &cobra.Command{ Use: "client-gen", RunE: ClientGen, } func init() {
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/client-gen/main.go
rootCmd.PersistentFlags().StringVar(&workdir, "workdir", "", "The host workdir loaded into dagger") rootCmd.PersistentFlags().StringVarP(&configPath, "project", "p", "", "project config file") rootCmd.Flags().StringP("output", "o", "", "output file") rootCmd.Flags().String("package", "", "package name") rootCmd.Flags().String("lang", "", "language to generate in") } func ClientGen(cmd *cobra.Command, args []string) error {
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/client-gen/main.go
ctx := context.Background() c, err := dagger.Connect(ctx, dagger.WithWorkdir(workdir), dagger.WithConfigPath(configPath), dagger.WithNoExtensions(), ) if err != nil { return err } defer c.Close() lang, err := getLang(cmd) if err != nil { panic(err) } pkg, err := getPackage(cmd) if err != nil { panic(err) } schema, err := generator.Introspect(ctx, c) if err != nil { panic(err) } generated, err := generate(ctx, schema, generator.Config{ Package: pkg, Lang: generator.SDKLang(lang), }) if err != nil { return err } output, err := cmd.Flags().GetString("output")
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/client-gen/main.go
if err != nil { panic(err) } if output == "" || output == "-" { fmt.Fprint(os.Stdout, string(generated)) } else { if err := os.MkdirAll(filepath.Dir(output), 0o700); err != nil { return err } if err := os.WriteFile(output, generated, 0o600); err != nil { return err } gitAttributes := fmt.Sprintf("/%s linguist-generated=true", filepath.Base(output)) if err := os.WriteFile(path.Join(filepath.Dir(output), ".gitattributes"), []byte(gitAttributes), 0o600); err != nil { return err } } return nil } func getLang(cmd *cobra.Command) (string, error) { lang, err := cmd.Flags().GetString("lang") if err != nil { return "", err } return lang, nil } func getPackage(cmd *cobra.Command) (string, error) { pkg, err := cmd.Flags().GetString("package") if err != nil { return "", err
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/client-gen/main.go
} if pkg != "" { return pkg, nil } output, err := cmd.Flags().GetString("output") if err != nil { return "", err } if output == "" || output == "-" { return "main", nil } directory, err := filepath.Abs(filepath.Dir(output)) if err != nil { return "", err } fset := token.NewFileSet() pkgs, err := parser.ParseDir(fset, directory, nil, parser.PackageClauseOnly) if err == nil && len(pkgs) > 0 { for _, p := range pkgs { return p.Name, nil } } return strings.ToLower(filepath.Base(directory)), nil } func generate(ctx context.Context, schema *introspection.Schema, cfg generator.Config) ([]byte, error) {
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/client-gen/main.go
generator.SetSchemaParents(schema) var gen generator.Generator switch cfg.Lang { case generator.SDKLangGo: gen = &gogenerator.GoGenerator{ Config: cfg, } case generator.SDKLangNodeJS: gen = &nodegenerator.NodeGenerator{} default: sdks := []string{ string(generator.SDKLangGo), string(generator.SDKLangNodeJS), } return []byte{}, fmt.Errorf("use target SDK language: %s: %w", sdks, generator.ErrUnknownSDKLang) } return gen.Generate(ctx, schema) } func main() { closer := tracing.Init() if err := rootCmd.Execute(); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) closer.Close() os.Exit(1) } closer.Close() }
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/dagger/engine.go
package main import ( "context" "os" "github.com/dagger/dagger/engine" "github.com/dagger/dagger/router" ) func withEngine(
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/dagger/engine.go
ctx context.Context, sessionToken string, cb engine.StartCallback, ) error { var runnerHost string if v, ok := os.LookupEnv("_EXPERIMENTAL_DAGGER_RUNNER_HOST"); ok { runnerHost = v } else { runnerHost = "docker-image://" + engineImageRef() } engineConf := &engine.Config{ Workdir: workdir, ConfigPath: configPath, SessionToken: sessionToken, RunnerHost: runnerHost, } if debugLogs { engineConf.LogOutput = os.Stderr } return engine.Start(ctx, engineConf, func(ctx context.Context, r *router.Router) error { return cb(ctx, r) }) }
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/dagger/version.go
package main import ( "fmt" "runtime" "runtime/debug" "github.com/spf13/cobra" ) const ( developmentVersion = "devel" engineImageRepo = "ghcr.io/dagger/engine" ) var versionCmd = &cobra.Command{ Use: "version", Short: "Print dagger version", PersistentPreRun: func(*cobra.Command, []string) {}, PersistentPostRun: func(*cobra.Command, []string) {}, Args: cobra.NoArgs, Run: func(cmd *cobra.Command, args []string) { fmt.Println(long()) }, } var version = developmentVersion func revision() string {
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/dagger/version.go
bi, ok := debug.ReadBuildInfo() if !ok { return "" } for _, s := range bi.Settings { if s.Key == "vcs.revision" { return s.Value[:9] } } return "" } func short() string { return fmt.Sprintf("dagger %s (%s)", version, revision()) } func long() string { return fmt.Sprintf("%s %s/%s", short(), runtime.GOOS, runtime.GOARCH) } func engineImageRef() string { if version != developmentVersion { return fmt.Sprintf("%s:v%s", engineImageRepo, version) } return fmt.Sprintf("%s:main", engineImageRepo) }
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/engine-session/main.go
package main import ( "context" "errors" "fmt" "io" "net" "net/http" "os" "os/signal" "syscall" "time" "github.com/dagger/dagger/engine" "github.com/dagger/dagger/router" "github.com/dagger/dagger/tracing" "github.com/spf13/cobra" ) var ( configPath string workdir string ) func init() {
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/engine-session/main.go
rootCmd.PersistentFlags().StringVar(&workdir, "workdir", "", "") rootCmd.PersistentFlags().StringVarP(&configPath, "project", "p", "", "") } var rootCmd = &cobra.Command{ Use: "WARNING: this is an internal-only command used by Dagger SDKs to communicate with the Dagger engine. It is not intended to be used by humans directly.", PersistentPreRunE: func(cmd *cobra.Command, args []string) error { var err error workdir, configPath, err = engine.NormalizePaths(workdir, configPath) return err }, Run: EngineSession, } func EngineSession(cmd *cobra.Command, args []string) {
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/engine-session/main.go
startOpts := &engine.Config{ Workdir: workdir, ConfigPath: configPath, LogOutput: os.Stderr, RunnerHost: os.Getenv("_EXPERIMENTAL_DAGGER_RUNNER_HOST"), } signalCh := make(chan os.Signal, 1) signal.Notify(signalCh, syscall.SIGINT, syscall.SIGTERM) l, err := net.Listen("tcp", "localhost:0") if err != nil { panic(err) } go func() { <-signalCh l.Close() }() go func() { io.Copy(io.Discard, os.Stdin) l.Close() }() port := l.Addr().(*net.TCPAddr).Port err = engine.Start(context.Background(), startOpts, func(ctx context.Context, r *router.Router) error { srv := http.Server{ Handler: r,
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
cmd/engine-session/main.go
ReadHeaderTimeout: 30 * time.Second, } go func() { if _, err := os.Stdout.Write([]byte(fmt.Sprintf("%d\n", port))); err != nil { panic(err) } }() err := srv.Serve(l) if err != nil && !errors.Is(err, net.ErrClosed) { return err } return nil }) if err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } } func main() { closer := tracing.Init() if err := rootCmd.Execute(); err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) closer.Close() os.Exit(1) } closer.Close() }
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
codegen/generator/generator.go
package generator import ( "context" "errors" "fmt" "dagger.io/dagger" "github.com/dagger/dagger/codegen/introspection" ) var ErrUnknownSDKLang = errors.New("unknown sdk language") type SDKLang string const ( SDKLangGo SDKLang = "go" SDKLangNodeJS SDKLang = "nodejs" SDKLangPython SDKLang = "python" ) type Config struct { Lang SDKLang Package string } type Generator interface { Generate(ctx context.Context, schema *introspection.Schema) ([]byte, error) } func SetSchemaParents(schema *introspection.Schema) {
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
codegen/generator/generator.go
for _, t := range schema.Types { for _, f := range t.Fields { f.ParentObject = t } } } func Introspect(ctx context.Context, c *dagger.Client) (*introspection.Schema, error) { var response introspection.Response err := c.Do(ctx, &dagger.Request{ Query: introspection.Query, }, &dagger.Response{Data: &response}, ) if err != nil { return nil, fmt.Errorf("error querying the API: %w", err) } return response.Schema, nil } func IntrospectAndGenerate(ctx context.Context, c *dagger.Client, generator Generator) ([]byte, error) { schema, err := Introspect(ctx, c) if err != nil { return nil, err } return generator.Generate(ctx, schema) }
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
codegen/generator/nodejs/templates/functions_test.go
package templates import ( "context" "testing" "dagger.io/dagger" "github.com/dagger/dagger/codegen/generator" "github.com/dagger/dagger/codegen/introspection" "github.com/stretchr/testify/require" ) var currentSchema *introspection.Schema func init() { ctx := context.Background() client, err := dagger.Connect(ctx) if err != nil { panic(err) } defer client.Close() currentSchema, err = generator.Introspect(ctx, client) if err != nil { panic(err) } generator.SetSchemaParents(currentSchema) } func getField(t *introspection.Type, name string) *introspection.Field {
closed
dagger/dagger
https://github.com/dagger/dagger
4,131
🐞 ./cmd/client-gen doesn't work out of the box
### What is the issue? I wanted to regenerate locally some SDK code. It failed inside the engine of a `./hack/make sdk:nodejs:generate` and I couldn't get more details. I wanted to see on my host FS what was failing, so I decided to do a: ``` $ go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Log output ``` Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. Usage: client-gen [flags] Flags: -h, --help help for client-gen --lang string language to generate in -o, --output string output file --package string package name -p, --project string project config file --workdir string The host workdir loaded into dagger Error: failed to start engine session bin: EOF: Error: unknown engine provider: Please visit https://dagger.io/help#go for troubleshooting guidance. exit status 1 ``` ### Steps to reproduce get the latest main (5219a37e) and run ``` go run ./cmd/client-gen/ --lang nodejs -o sdk/nodejs/api/client.gen.ts ``` ### Dagger version 5219a37e ### OS version Ubuntu 20.04
https://github.com/dagger/dagger/issues/4131
https://github.com/dagger/dagger/pull/4143
1d14ca04b9aa13589649c7a441a587d1e2b18e30
2844748a9db7c4851e5f7acc87c01651f07bb598
2022-12-08T09:21:34Z
go
2022-12-09T21:36:44Z
codegen/generator/nodejs/templates/functions_test.go
for _, v := range t.Fields { if v.Name == name { return v } } return nil } func TestSplitRequiredOptionalArgs(t *testing.T) { t.Run("container exec", func(t *testing.T) { container := currentSchema.Types.Get("Container") require.NotNil(t, container) execField := getField(container, "exec") t.Log(container) required, optional := splitRequiredOptionalArgs(execField.Args) require.Equal(t, execField.Args[:0], required) require.Equal(t, execField.Args, optional) }) t.Run("container export", func(t *testing.T) { container := currentSchema.Types.Get("Container") require.NotNil(t, container) execField := getField(container, "export") t.Log(container) required, optional := splitRequiredOptionalArgs(execField.Args) require.Equal(t, execField.Args[:1], required) require.Equal(t, execField.Args[1:], optional) }) }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
package main import ( "context" "encoding/json" "fmt" "io" "net" "net/http" "os" "os/exec"
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
"os/signal" "path/filepath" "strings" "syscall" "github.com/dagger/dagger/engine" "github.com/dagger/dagger/router" "github.com/google/uuid" "github.com/opencontainers/runtime-spec/specs-go" "golang.org/x/sys/unix" ) const ( metaMountPath = "/.dagger_meta_mount" stdinPath = metaMountPath + "/stdin" exitCodePath = metaMountPath + "/exitCode" runcPath = "/usr/bin/buildkit-runc" shimPath = "/_shim" ) var ( stdoutPath = metaMountPath + "/stdout" stderrPath = metaMountPath + "/stderr" ) /* There are two "subcommands" of this binary: 1. The setupBundle command, which is invoked by buildkitd as the oci executor. It updates the spec provided by buildkitd's executor to wrap the command in our shim (described below). It then exec's to runc which will do the actual container setup+execution. 2. The shim, which is included in each Container.Exec and enables us to capture/redirect stdio, capture the exit code, etc. */ func main() {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
if os.Args[0] == shimPath { os.Exit(shim()) } else { os.Exit(setupBundle()) } } func shim() int { if len(os.Args) < 2 { fmt.Fprintf(os.Stderr, "usage: %s <path> [<args>]\n", os.Args[0]) return 1 } name := os.Args[1] args := []string{} if len(os.Args) > 2 { args = os.Args[2:] } cmd := exec.Command(name, args...) cmd.Env = os.Environ() if stdinFile, err := os.Open(stdinPath); err == nil { defer stdinFile.Close() cmd.Stdin = stdinFile } else { cmd.Stdin = nil } stdoutRedirect, found := internalEnv("_DAGGER_REDIRECT_STDOUT") if found { stdoutPath = stdoutRedirect
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
} stdoutFile, err := os.Create(stdoutPath) if err != nil { panic(err) } defer stdoutFile.Close() cmd.Stdout = io.MultiWriter(stdoutFile, os.Stdout) stderrRedirect, found := internalEnv("_DAGGER_REDIRECT_STDERR") if found { stderrPath = stderrRedirect } stderrFile, err := os.Create(stderrPath) if err != nil { panic(err) } defer stderrFile.Close() cmd.Stderr = io.MultiWriter(stderrFile, os.Stderr) exitCode := 0 if err := cmd.Run(); err != nil { exitCode = 1 if exiterr, ok := err.(*exec.ExitError); ok { exitCode = exiterr.ExitCode() } } if err := os.WriteFile(exitCodePath, []byte(fmt.Sprintf("%d", exitCode)), 0600); err != nil { panic(err) } return exitCode } func setupBundle() int {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
ctx, cancel := context.WithCancel(context.Background()) defer cancel() var bundleDir string var isRun bool for i, arg := range os.Args { if arg == "--bundle" && i+1 < len(os.Args) { bundleDir = os.Args[i+1] } if arg == "run" { isRun = true } } if bundleDir == "" || !isRun { return execRunc() }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
configPath := filepath.Join(bundleDir, "config.json") configBytes, err := os.ReadFile(configPath) if err != nil { fmt.Printf("Error reading config.json: %v\n", err) return 1 } var spec specs.Spec if err := json.Unmarshal(configBytes, &spec); err != nil { fmt.Printf("Error parsing config.json: %v\n", err) return 1 } var isDaggerExec bool for _, mnt := range spec.Mounts { if mnt.Destination == metaMountPath { isDaggerExec = true break } } if isDaggerExec { selfPath, err := os.Executable() if err != nil { fmt.Printf("Error getting self path: %v\n", err) return 1 } selfPath, err = filepath.EvalSymlinks(selfPath)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
if err != nil { fmt.Printf("Error getting self path: %v\n", err) return 1 } spec.Mounts = append(spec.Mounts, specs.Mount{ Destination: shimPath, Type: "bind", Source: selfPath, Options: []string{"rbind", "ro"}, }) spec.Process.Args = append([]string{shimPath}, spec.Process.Args...) } spec, err = toggleNesting(ctx, spec) if err != nil { fmt.Printf("Error toggling nesting: %v\n", err) return 1 } configBytes, err = json.Marshal(spec) if err != nil { fmt.Printf("Error marshaling config.json: %v\n", err) return 1 } if err := os.WriteFile(configPath, configBytes, 0600); err != nil { fmt.Printf("Error writing config.json: %v\n", err) return 1 }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
cmd := exec.Command(runcPath, os.Args[1:]...) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.SysProcAttr = &syscall.SysProcAttr{ Pdeathsig: syscall.SIGKILL, } sigCh := make(chan os.Signal, 32) signal.Notify(sigCh) if err := cmd.Start(); err != nil { fmt.Printf("Error starting runc: %v", err) return 1 } go func() { for sig := range sigCh { cmd.Process.Signal(sig) } }() if err := cmd.Wait(); err != nil { if exiterr, ok := err.(*exec.ExitError); ok { if exitcode, ok := exiterr.Sys().(syscall.WaitStatus); ok { return exitcode.ExitStatus() } } fmt.Printf("Error waiting for runc: %v", err) return 1 } return 0 } func execRunc() int {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
args := []string{runcPath} args = append(args, os.Args[1:]...) if err := unix.Exec(runcPath, args, os.Environ()); err != nil { fmt.Printf("Error execing runc: %v\n", err) return 1 } panic("congratulations: you've reached unreachable code, please report a bug!") } func internalEnv(name string) (string, bool) { val, found := os.LookupEnv(name) if !found { return "", false } os.Unsetenv(name) return val, true } func toggleNesting(ctx context.Context, spec specs.Spec) (specs.Spec, error) { checkenv: for i, env := range spec.Process.Env { switch { case strings.HasPrefix(env, "_DAGGER_ENABLE_NESTING="): spec.Process.Env = append(spec.Process.Env[:i], spec.Process.Env[i+1:]...)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
cmd/shim/main.go
sessionToken, err := uuid.NewRandom() if err != nil { return specs.Spec{}, fmt.Errorf("error generating session token: %w", err) } l, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { return specs.Spec{}, fmt.Errorf("error listening on session socket: %w", err) } engineConf := &engine.Config{ SessionToken: sessionToken.String(), RunnerHost: "unix:///run/buildkit/buildkitd.sock", LogOutput: os.Stderr, } go func() { err := engine.Start(ctx, engineConf, func(ctx context.Context, r *router.Router) error { return http.Serve(l, r) }) if err != nil { fmt.Printf("Error starting engine: %v\n", err) } }() spec.Process.Env = append(spec.Process.Env, fmt.Sprintf("DAGGER_SESSION_URL=http://127.0.0.1:%d", l.Addr().(*net.TCPAddr).Port)) spec.Process.Env = append(spec.Process.Env, fmt.Sprintf("DAGGER_SESSION_TOKEN=%s", sessionToken.String())) break checkenv } } return spec, nil }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
package core import ( "context" "encoding/json" "fmt" "io" "os" "path" "path/filepath" "strconv" "strings" "github.com/containerd/containerd/platforms" "github.com/docker/distribution/reference" bkclient "github.com/moby/buildkit/client" "github.com/moby/buildkit/client/llb" "github.com/moby/buildkit/exporter/containerimage/exptypes" dockerfilebuilder "github.com/moby/buildkit/frontend/dockerfile/builder" bkgw "github.com/moby/buildkit/frontend/gateway/client" "github.com/moby/buildkit/solver/pb" "github.com/opencontainers/go-digest" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" ) type Container struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
ID ContainerID `json:"id"` } func NewContainer(id ContainerID, platform specs.Platform) (*Container, error) { if id == "" { id, err := (&containerIDPayload{Platform: platform}).Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } return &Container{ID: id}, nil } type ContainerID string func (id ContainerID) decode() (*containerIDPayload, error) { if id == "" { return &containerIDPayload{}, nil } var payload containerIDPayload if err := decodeID(&payload, id); err != nil { return nil, err } return &payload, nil } type containerIDPayload struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
FS *pb.Definition `json:"fs"` Config specs.ImageConfig `json:"cfg"` Mounts ContainerMounts `json:"mounts,omitempty"` Meta *pb.Definition `json:"meta,omitempty"` Platform specs.Platform `json:"platform,omitempty"` Secrets []ContainerSecret `json:"secret_env,omitempty"` Sockets []ContainerSocket `json:"sockets,omitempty"` } type ContainerSecret struct { Secret SecretID `json:"secret"` EnvName string `json:"env,omitempty"` MountPath string `json:"path,omitempty"` } type ContainerSocket struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
Socket SocketID `json:"socket"` UnixPath string `json:"unix_path,omitempty"` } func (payload *containerIDPayload) Encode() (ContainerID, error) { id, err := encodeID(payload) if err != nil { return "", err } return ContainerID(id), nil } func (payload *containerIDPayload) FSState() (llb.State, error) { if payload.FS == nil { return llb.Scratch(), nil } return defToState(payload.FS) } const metaMount = "/.dagger_meta_mount" const metaSourcePath = "meta" func (payload *containerIDPayload) MetaState() (*llb.State, error) { if payload.Meta == nil { return nil, nil } metaSt, err := defToState(payload.Meta) if err != nil { return nil, err } return &metaSt, nil } type ContainerMount struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
Source *pb.Definition `json:"source,omitempty"` SourcePath string `json:"source_path,omitempty"` Target string `json:"target"` CacheID string `json:"cache_id,omitempty"` CacheSharingMode string `json:"cache_sharing,omitempty"` Tmpfs bool `json:"tmpfs,omitempty"` } func (mnt ContainerMount) SourceState() (llb.State, error) { if mnt.Source == nil { return llb.Scratch(), nil } return defToState(mnt.Source) } type ContainerMounts []ContainerMount func (mnts ContainerMounts) With(newMnt ContainerMount) ContainerMounts { mntsCp := make(ContainerMounts, 0, len(mnts)) parent := newMnt.Target + "/" for _, mnt := range mnts { if mnt.Target == newMnt.Target || strings.HasPrefix(mnt.Target, parent) { continue }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
mntsCp = append(mntsCp, mnt) } mntsCp = append(mntsCp, newMnt) return mntsCp } func (container *Container) From(ctx context.Context, gw bkgw.Client, addr string) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } platform := payload.Platform refName, err := reference.ParseNormalizedNamed(addr) if err != nil { return nil, err } ref := reference.TagNameOnly(refName).String() _, cfgBytes, err := gw.ResolveImageConfig(ctx, ref, llb.ResolveImageConfigOpt{ Platform: &platform, ResolveMode: llb.ResolveModeDefault.String(), }) if err != nil { return nil, err } var imgSpec specs.Image if err := json.Unmarshal(cfgBytes, &imgSpec); err != nil { return nil, err } dir, err := NewDirectory(ctx, llb.Image(addr), "/", platform) if err != nil { return nil, err
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
} ctr, err := container.WithRootFS(ctx, dir) if err != nil { return nil, err } return ctr.UpdateImageConfig(ctx, func(specs.ImageConfig) specs.ImageConfig { return imgSpec.Config }) } const defaultDockerfileName = "Dockerfile" func (container *Container) Build(ctx context.Context, gw bkgw.Client, context *Directory, dockerfile string) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } ctxPayload, err := context.ID.Decode() if err != nil { return nil, err } platform := payload.Platform opts := map[string]string{ "platform": platforms.Format(platform), "contextsubdir": ctxPayload.Dir, } if dockerfile != "" { opts["filename"] = path.Join(ctxPayload.Dir, dockerfile) } else { opts["filename"] = path.Join(ctxPayload.Dir, defaultDockerfileName) } inputs := map[string]*pb.Definition{
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
dockerfilebuilder.DefaultLocalNameContext: ctxPayload.LLB, dockerfilebuilder.DefaultLocalNameDockerfile: ctxPayload.LLB, } res, err := gw.Solve(ctx, bkgw.SolveRequest{ Frontend: "dockerfile.v0", FrontendOpt: opts, FrontendInputs: inputs, }) if err != nil { return nil, err } bkref, err := res.SingleRef() if err != nil { return nil, err } var st llb.State if bkref == nil { st = llb.Scratch() } else { st, err = bkref.ToState() if err != nil { return nil, err } } def, err := st.Marshal(ctx, llb.Platform(platform)) if err != nil { return nil, err } payload.FS = def.ToPB() cfgBytes, found := res.Metadata[exptypes.ExporterImageConfigKey]
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
if found { var imgSpec specs.Image if err := json.Unmarshal(cfgBytes, &imgSpec); err != nil { return nil, err } payload.Config = imgSpec.Config } id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) RootFS(ctx context.Context) (*Directory, error) { payload, err := container.ID.decode() if err != nil { return nil, err } return (&directoryIDPayload{ LLB: payload.FS, Platform: payload.Platform, }).ToDirectory() } func (container *Container) WithRootFS(ctx context.Context, dir *Directory) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } dirPayload, err := dir.ID.Decode() if err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
return nil, err } payload.FS = dirPayload.LLB id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) WithDirectory(ctx context.Context, gw bkgw.Client, subdir string, src *Directory, filter CopyFilter) (*Container, error) { return container.updateRootFS(ctx, gw, subdir, func(dir *Directory) (*Directory, error) { return dir.WithDirectory(ctx, ".", src, filter) }) } func (container *Container) WithFile(ctx context.Context, gw bkgw.Client, subdir string, src *File) (*Container, error) { return container.updateRootFS(ctx, gw, subdir, func(dir *Directory) (*Directory, error) { return dir.WithFile(ctx, ".", src) }) } func (container *Container) WithNewFile(ctx context.Context, gw bkgw.Client, dest string, content []byte) (*Container, error) { dir, file := filepath.Split(dest) return container.updateRootFS(ctx, gw, dir, func(dir *Directory) (*Directory, error) { return dir.WithNewFile(ctx, gw, file, content) }) } func (container *Container) WithMountedDirectory(ctx context.Context, target string, source *Directory) (*Container, error) { payload, err := source.ID.Decode() if err != nil { return nil, err }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
return container.withMounted(target, payload.LLB, payload.Dir) } func (container *Container) WithMountedFile(ctx context.Context, target string, source *File) (*Container, error) { payload, err := source.ID.decode() if err != nil { return nil, err } return container.withMounted(target, payload.LLB, payload.File) } func (container *Container) WithMountedCache(ctx context.Context, target string, cache CacheID, source *Directory) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } cachePayload, err := cache.decode() if err != nil { return nil, err } target = absPath(payload.Config.WorkingDir, target) mount := ContainerMount{ Target: target, CacheID: cachePayload.Sum(), CacheSharingMode: "shared", } if source != nil { srcPayload, err := source.ID.Decode() if err != nil { return nil, err } mount.Source = srcPayload.LLB
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
mount.SourcePath = srcPayload.Dir } payload.Mounts = payload.Mounts.With(mount) id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) WithMountedTemp(ctx context.Context, target string) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } target = absPath(payload.Config.WorkingDir, target) payload.Mounts = payload.Mounts.With(ContainerMount{ Target: target, Tmpfs: true, }) id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) WithMountedSecret(ctx context.Context, target string, source *Secret) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
target = absPath(payload.Config.WorkingDir, target) payload.Secrets = append(payload.Secrets, ContainerSecret{ Secret: source.ID, MountPath: target, }) id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) WithoutMount(ctx context.Context, target string) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } target = absPath(payload.Config.WorkingDir, target) var found bool var foundIdx int for i := len(payload.Mounts) - 1; i >= 0; i-- { if payload.Mounts[i].Target == target { found = true foundIdx = i break } } if found { payload.Mounts = append(payload.Mounts[:foundIdx], payload.Mounts[foundIdx+1:]...) } id, err := payload.Encode()
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) Mounts(ctx context.Context) ([]string, error) { payload, err := container.ID.decode() if err != nil { return nil, err } mounts := []string{} for _, mnt := range payload.Mounts { mounts = append(mounts, mnt.Target) } return mounts, nil } func (container *Container) WithUnixSocket(ctx context.Context, target string, source *Socket) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } target = absPath(payload.Config.WorkingDir, target) newSocket := ContainerSocket{ Socket: source.ID, UnixPath: target, } var replaced bool for i, sock := range payload.Sockets { if sock.UnixPath == target { payload.Sockets[i] = newSocket
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
replaced = true break } } if !replaced { payload.Sockets = append(payload.Sockets, newSocket) } id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) WithoutUnixSocket(ctx context.Context, target string) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } target = absPath(payload.Config.WorkingDir, target) for i, sock := range payload.Sockets { if sock.UnixPath == target { payload.Sockets = append(payload.Sockets[:i], payload.Sockets[i+1:]...) break } } id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
} func (container *Container) WithSecretVariable(ctx context.Context, name string, secret *Secret) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } payload.Secrets = append(payload.Secrets, ContainerSecret{ Secret: secret.ID, EnvName: name, }) id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) Directory(ctx context.Context, gw bkgw.Client, dirPath string) (*Directory, error) { dir, _, err := locatePath(ctx, container, dirPath, gw, NewDirectory) if err != nil { return nil, err } info, err := dir.Stat(ctx, gw, ".") if err != nil { return nil, err } if !info.IsDir() { return nil, fmt.Errorf("path %s is a file, not a directory", dirPath) }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
return dir, nil } func (container *Container) File(ctx context.Context, gw bkgw.Client, filePath string) (*File, error) { file, _, err := locatePath(ctx, container, filePath, gw, NewFile) if err != nil { return nil, err } info, err := file.Stat(ctx, gw) if err != nil { return nil, err } if info.IsDir() { return nil, fmt.Errorf("path %s is a directory, not a file", filePath) } return file, nil } func locatePath[T *File | *Directory]( ctx context.Context, container *Container, containerPath string, gw bkgw.Client, init func(context.Context, llb.State, string, specs.Platform) (T, error), ) (T, *ContainerMount, error) { payload, err := container.ID.decode() if err != nil { return nil, nil, err } containerPath = absPath(payload.Config.WorkingDir, containerPath)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
var found T for i := len(payload.Mounts) - 1; i >= 0; i-- { mnt := payload.Mounts[i] if containerPath == mnt.Target || strings.HasPrefix(containerPath, mnt.Target+"/") { if mnt.Tmpfs { return nil, nil, fmt.Errorf("%s: cannot retrieve path from tmpfs", containerPath) } if mnt.CacheID != "" { return nil, nil, fmt.Errorf("%s: cannot retrieve path from cache", containerPath) } st, err := mnt.SourceState() if err != nil { return nil, nil, err } sub := mnt.SourcePath if containerPath != mnt.Target { dirSub := strings.TrimPrefix(containerPath, mnt.Target+"/") if dirSub != "" { sub = path.Join(sub, dirSub) } } found, err := init(ctx, st, sub, payload.Platform) if err != nil { return nil, nil, err } return found, &mnt, nil } }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
st, err := payload.FSState() if err != nil { return nil, nil, err } found, err = init(ctx, st, containerPath, payload.Platform) if err != nil { return nil, nil, err } return found, nil, nil } func (container *Container) withMounted(target string, srcDef *pb.Definition, srcPath string) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } target = absPath(payload.Config.WorkingDir, target) payload.Mounts = payload.Mounts.With(ContainerMount{ Source: srcDef, SourcePath: srcPath, Target: target, }) id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) updateRootFS(ctx context.Context, gw bkgw.Client, subdir string, fn func(dir *Directory) (*Directory, error)) (*Container, error) { dir, mount, err := locatePath(ctx, container, subdir, gw, NewDirectory)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
if err != nil { return nil, err } dir, err = fn(dir) if err != nil { return nil, err } if mount == nil { return container.WithRootFS(ctx, dir) } dirPayload, err := dir.ID.Decode() if err != nil { return nil, err } return container.withMounted(mount.Target, dirPayload.LLB, mount.SourcePath) } func (container *Container) ImageConfig(ctx context.Context) (specs.ImageConfig, error) { payload, err := container.ID.decode() if err != nil { return specs.ImageConfig{}, err } return payload.Config, nil } func (container *Container) UpdateImageConfig(ctx context.Context, updateFn func(specs.ImageConfig) specs.ImageConfig) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, err } payload.Config = updateFn(payload.Config)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
id, err := payload.Encode() if err != nil { return nil, err } return &Container{ID: id}, nil } func (container *Container) Exec(ctx context.Context, gw bkgw.Client, defaultPlatform specs.Platform, opts ContainerExecOpts) (*Container, error) { payload, err := container.ID.decode() if err != nil { return nil, fmt.Errorf("decode id: %w", err) } cfg := payload.Config mounts := payload.Mounts platform := payload.Platform if platform.OS == "" { platform = defaultPlatform } args := opts.Args if len(args) == 0 { args = cfg.Cmd } if len(cfg.Entrypoint) > 0 { args = append(cfg.Entrypoint, args...) } runOpts := []llb.RunOption{ llb.Args(args), } if opts.ExperimentalPrivilegedNesting {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
runOpts = append(runOpts, llb.AddEnv("_DAGGER_ENABLE_NESTING", ""), ) } meta := llb.Mkdir(metaSourcePath, 0o777) if opts.Stdin != "" { meta = meta.Mkfile(path.Join(metaSourcePath, "stdin"), 0o600, []byte(opts.Stdin)) } runOpts = append(runOpts, llb.AddMount(metaMount, llb.Scratch().File(meta), llb.SourcePath(metaSourcePath))) if opts.RedirectStdout != "" { runOpts = append(runOpts, llb.AddEnv("_DAGGER_REDIRECT_STDOUT", opts.RedirectStdout)) } if opts.RedirectStderr != "" { runOpts = append(runOpts, llb.AddEnv("_DAGGER_REDIRECT_STDERR", opts.RedirectStderr)) } if cfg.User != "" { runOpts = append(runOpts, llb.User(cfg.User)) } if cfg.WorkingDir != "" { runOpts = append(runOpts, llb.Dir(cfg.WorkingDir)) } for _, env := range cfg.Env {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
name, val, ok := strings.Cut(env, "=") if !ok { _ = ok } if name == "_DAGGER_ENABLE_NESTING" && !opts.ExperimentalPrivilegedNesting { continue } runOpts = append(runOpts, llb.AddEnv(name, val)) } for i, secret := range payload.Secrets { secretOpts := []llb.SecretOption{llb.SecretID(secret.Secret.String())} var secretDest string switch { case secret.EnvName != "": secretDest = secret.EnvName secretOpts = append(secretOpts, llb.SecretAsEnv(true)) case secret.MountPath != "": secretDest = secret.MountPath default: return nil, fmt.Errorf("malformed secret config at index %d", i) } runOpts = append(runOpts, llb.AddSecret(secretDest, secretOpts...)) } for _, socket := range payload.Sockets { if socket.UnixPath == "" { return nil, fmt.Errorf("unsupported socket: only unix paths are implemented") }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
runOpts = append(runOpts, llb.AddSSHSocket( llb.SSHID(socket.Socket.LLBID()), llb.SSHSocketTarget(socket.UnixPath), )) } fsSt, err := payload.FSState() if err != nil { return nil, fmt.Errorf("fs state: %w", err) } for _, mnt := range mounts { srcSt, err := mnt.SourceState() if err != nil { return nil, fmt.Errorf("mount %s: %w", mnt.Target, err) } mountOpts := []llb.MountOption{} if mnt.SourcePath != "" { mountOpts = append(mountOpts, llb.SourcePath(mnt.SourcePath)) } if mnt.CacheSharingMode != "" { var sharingMode llb.CacheMountSharingMode switch mnt.CacheSharingMode { case "shared": sharingMode = llb.CacheMountShared case "private": sharingMode = llb.CacheMountPrivate case "locked": sharingMode = llb.CacheMountLocked default: return nil, errors.Errorf("invalid cache mount sharing mode %q", mnt.CacheSharingMode)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
} mountOpts = append(mountOpts, llb.AsPersistentCacheDir(mnt.CacheID, sharingMode)) } if mnt.Tmpfs { mountOpts = append(mountOpts, llb.Tmpfs()) } runOpts = append(runOpts, llb.AddMount(mnt.Target, srcSt, mountOpts...)) } execSt := fsSt.Run(runOpts...) execDef, err := execSt.Root().Marshal(ctx, llb.Platform(platform)) if err != nil { return nil, fmt.Errorf("marshal root: %w", err) } payload.FS = execDef.ToPB() metaDef, err := execSt.GetMount(metaMount).Marshal(ctx, llb.Platform(platform)) if err != nil { return nil, fmt.Errorf("get meta mount: %w", err) } payload.Meta = metaDef.ToPB() for i, mnt := range mounts { if mnt.Tmpfs || mnt.CacheID != "" { continue } mountSt := execSt.GetMount(mnt.Target) execMountDef, err := mountSt.Marshal(ctx, llb.Platform(platform)) if err != nil { return nil, fmt.Errorf("propagate %s: %w", mnt.Target, err) } mounts[i].Source = execMountDef.ToPB()
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
} payload.Mounts = mounts id, err := payload.Encode() if err != nil { return nil, fmt.Errorf("encode: %w", err) } return &Container{ID: id}, nil } func (container *Container) ExitCode(ctx context.Context, gw bkgw.Client) (*int, error) { content, err := container.MetaFileContents(ctx, gw, "exitCode") if err != nil { return nil, err } if content == nil { return nil, nil } exitCode, err := strconv.Atoi(*content) if err != nil { return nil, err } return &exitCode, nil } func (container *Container) MetaFileContents(ctx context.Context, gw bkgw.Client, filePath string) (*string, error) { file, err := container.MetaFile(ctx, gw, filePath) if err != nil { return nil, err } if file == nil { return nil, nil }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
content, err := file.Contents(ctx, gw) if err != nil { return nil, err } strContent := string(content) if err != nil { return nil, err } return &strContent, nil } func (container *Container) MetaFile(ctx context.Context, gw bkgw.Client, filePath string) (*File, error) { payload, err := container.ID.decode() if err != nil { return nil, err } meta, err := payload.MetaState() if err != nil { return nil, err } if meta == nil { return nil, nil } return NewFile(ctx, *meta, path.Join(metaSourcePath, filePath), payload.Platform) } func (container *Container) Publish( ctx context.Context, ref string, platformVariants []ContainerID, bkClient *bkclient.Client, solveOpts bkclient.SolveOpt,
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
solveCh chan<- *bkclient.SolveStatus, ) (string, error) { solveOpts.Exports = []bkclient.ExportEntry{ { Type: bkclient.ExporterImage, Attrs: map[string]string{ "name": ref, "push": "true", }, }, } ch, wg := mirrorCh(solveCh) defer wg.Wait() res, err := bkClient.Build(ctx, solveOpts, "", func(ctx context.Context, gw bkgw.Client) (*bkgw.Result, error) { return container.export(ctx, gw, platformVariants) }, ch) if err != nil { return "", err } refName, err := reference.ParseNormalizedNamed(ref) if err != nil { return "", err } imageDigest, found := res.ExporterResponse[exptypes.ExporterImageDigestKey] if found { dig, err := digest.Parse(imageDigest) if err != nil { return "", fmt.Errorf("parse digest: %w", err) }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
withDig, err := reference.WithDigest(refName, dig) if err != nil { return "", fmt.Errorf("with digest: %w", err) } return withDig.String(), nil } return ref, nil } func (container *Container) Platform() (specs.Platform, error) { payload, err := container.ID.decode() if err != nil { return specs.Platform{}, err } return payload.Platform, nil } func (container *Container) Export( ctx context.Context, host *Host, dest string, platformVariants []ContainerID, bkClient *bkclient.Client, solveOpts bkclient.SolveOpt, solveCh chan<- *bkclient.SolveStatus, ) error { dest, err := host.NormalizeDest(dest) if err != nil { return err } out, err := os.Create(dest) if err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
return err } defer out.Close() return host.Export(ctx, bkclient.ExportEntry{ Type: bkclient.ExporterOCI, Output: func(map[string]string) (io.WriteCloser, error) { return out, nil }, }, dest, bkClient, solveOpts, solveCh, func(ctx context.Context, gw bkgw.Client) (*bkgw.Result, error) { return container.export(ctx, gw, platformVariants) }) } func (container *Container) export( ctx context.Context, gw bkgw.Client, platformVariants []ContainerID, ) (*bkgw.Result, error) { var payloads []*containerIDPayload if container.ID != "" { payload, err := container.ID.decode() if err != nil { return nil, err } if payload.FS != nil { payloads = append(payloads, payload) } } for _, id := range platformVariants { payload, err := id.decode() if err != nil {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
return nil, err } if payload.FS != nil { payloads = append(payloads, payload) } } if len(payloads) == 0 { return nil, errors.New("no containers to export") } if len(payloads) == 1 { payload := payloads[0] st, err := payload.FSState() if err != nil { return nil, err } stDef, err := st.Marshal(ctx, llb.Platform(payload.Platform)) if err != nil { return nil, err } res, err := gw.Solve(ctx, bkgw.SolveRequest{ Evaluate: true, Definition: stDef.ToPB(), }) if err != nil { return nil, err } cfgBytes, err := json.Marshal(specs.Image{ Architecture: payload.Platform.Architecture, OS: payload.Platform.OS,
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
OSVersion: payload.Platform.OSVersion, OSFeatures: payload.Platform.OSFeatures, Config: payload.Config, }) if err != nil { return nil, err } res.AddMeta(exptypes.ExporterImageConfigKey, cfgBytes) return res, nil } res := bkgw.NewResult() expPlatforms := &exptypes.Platforms{ Platforms: make([]exptypes.Platform, len(payloads)), } for i, payload := range payloads { st, err := payload.FSState() if err != nil { return nil, err } stDef, err := st.Marshal(ctx, llb.Platform(payload.Platform)) if err != nil { return nil, err } r, err := gw.Solve(ctx, bkgw.SolveRequest{ Evaluate: true, Definition: stDef.ToPB(), }) if err != nil { return nil, err }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
ref, err := r.SingleRef() if err != nil { return nil, err } platformKey := platforms.Format(payload.Platform) res.AddRef(platformKey, ref) expPlatforms.Platforms[i] = exptypes.Platform{ ID: platformKey, Platform: payload.Platform, } cfgBytes, err := json.Marshal(specs.Image{ Architecture: payload.Platform.Architecture, OS: payload.Platform.OS, OSVersion: payload.Platform.OSVersion, OSFeatures: payload.Platform.OSFeatures, Config: payload.Config, }) if err != nil { return nil, err } res.AddMeta(fmt.Sprintf("%s/%s", exptypes.ExporterImageConfigKey, platformKey), cfgBytes) } platformBytes, err := json.Marshal(expPlatforms) if err != nil { return nil, err } res.AddMeta(exptypes.ExporterPlatformsKey, platformBytes) return res, nil } type ContainerExecOpts struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/container.go
Args []string Stdin string RedirectStdout string RedirectStderr string ExperimentalPrivilegedNesting bool }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
package core import ( "context" _ "embed" "errors" "io" "net" "os" "path/filepath" "strings" "testing" "dagger.io/dagger" "github.com/dagger/dagger/core" "github.com/dagger/dagger/core/schema" "github.com/dagger/dagger/internal/testutil" "github.com/moby/buildkit/identity" "github.com/stretchr/testify/require" ) func TestContainerScratch(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { ID string Fs struct { Entries []string } } }{} err := testutil.Query( `{ container { id fs { entries } } }`, &res, nil) require.NoError(t, err) require.Empty(t, res.Container.Fs.Entries) } func TestContainerFrom(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { From struct { Fs struct { File struct { Contents string } } } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { fs { file(path: "/etc/alpine-release") { contents } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.Fs.File.Contents, "3.16.2\n") } func TestContainerBuild(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
ctx := context.Background() c, err := dagger.Connect(ctx) require.NoError(t, err) defer c.Close() contextDir := c.Directory(). WithNewFile("main.go", `package main import "fmt" import "os" func main() { for _, env := range os.Environ() { fmt.Println(env) } }`) t.Run("default Dockerfile location", func(t *testing.T) { src := contextDir. WithNewFile("Dockerfile", `FROM golang:1.18.2-alpine WORKDIR /src COPY main.go . RUN go mod init hello RUN go build -o /usr/bin/goenv main.go ENV FOO=bar CMD goenv `) env, err := c.Container().Build(src).WithExec([]string{}).Stdout(ctx)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
require.NoError(t, err) require.Contains(t, env, "FOO=bar\n") }) t.Run("custom Dockerfile location", func(t *testing.T) { src := contextDir. WithNewFile("subdir/Dockerfile.whee", `FROM golang:1.18.2-alpine WORKDIR /src COPY main.go . RUN go mod init hello RUN go build -o /usr/bin/goenv main.go ENV FOO=bar CMD goenv `) env, err := c.Container().Build(src, dagger.ContainerBuildOpts{ Dockerfile: "subdir/Dockerfile.whee", }).WithExec([]string{}).Stdout(ctx) require.NoError(t, err) require.Contains(t, env, "FOO=bar\n") }) t.Run("subdirectory with default Dockerfile location", func(t *testing.T) { src := contextDir. WithNewFile("Dockerfile", `FROM golang:1.18.2-alpine WORKDIR /src COPY main.go . RUN go mod init hello RUN go build -o /usr/bin/goenv main.go ENV FOO=bar CMD goenv
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
`) sub := c.Directory().WithDirectory("subcontext", src).Directory("subcontext") env, err := c.Container().Build(sub).WithExec([]string{}).Stdout(ctx) require.NoError(t, err) require.Contains(t, env, "FOO=bar\n") }) t.Run("subdirectory with custom Dockerfile location", func(t *testing.T) { src := contextDir. WithNewFile("subdir/Dockerfile.whee", `FROM golang:1.18.2-alpine WORKDIR /src COPY main.go . RUN go mod init hello RUN go build -o /usr/bin/goenv main.go ENV FOO=bar CMD goenv `) sub := c.Directory().WithDirectory("subcontext", src).Directory("subcontext") env, err := c.Container().Build(sub, dagger.ContainerBuildOpts{ Dockerfile: "subdir/Dockerfile.whee", }).WithExec([]string{}).Stdout(ctx) require.NoError(t, err) require.Contains(t, env, "FOO=bar\n") }) } func TestContainerWithRootFS(t *testing.T) { t.Parallel() ctx := context.Background() c, err := dagger.Connect(ctx) require.NoError(t, err)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
defer c.Close() alpine316 := c.Container().From("alpine:3.16.2") alpine316ReleaseStr, err := alpine316.File("/etc/alpine-release").Contents(ctx) require.NoError(t, err) alpine316ReleaseStr = strings.TrimSpace(alpine316ReleaseStr) dir := alpine316.Rootfs() exitCode, err := c.Container().WithEnvVariable("ALPINE_RELEASE", alpine316ReleaseStr).WithRootfs(dir).WithExec([]string{ "/bin/sh", "-c", "test -f /etc/alpine-release && test \"$(head -n 1 /etc/alpine-release)\" = \"$ALPINE_RELEASE\"", }).ExitCode(ctx) require.NoError(t, err) require.Equal(t, exitCode, 0) alpine315 := c.Container().From("alpine:3.15.6") varVal := "testing123" alpine315WithVar := alpine315.WithEnvVariable("DAGGER_TEST", varVal) varValResp, err := alpine315WithVar.EnvVariable(ctx, "DAGGER_TEST") require.NoError(t, err) require.Equal(t, varVal, varValResp) alpine315ReplacedFS := alpine315WithVar.WithRootfs(dir) varValResp, err = alpine315ReplacedFS.EnvVariable(ctx, "DAGGER_TEST") require.NoError(t, err) require.Equal(t, varVal, varValResp) releaseStr, err := alpine315ReplacedFS.File("/etc/alpine-release").Contents(ctx) require.NoError(t, err) require.Equal(t, "3.16.2\n", releaseStr) } func TestContainerExecExitCode(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { From struct { WithExec struct { ExitCode *int } } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { withExec(args: ["true"]) { exitCode } } } }`, &res, nil)
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
require.NoError(t, err) require.NotNil(t, res.Container.From.WithExec.ExitCode) require.Equal(t, 0, *res.Container.From.WithExec.ExitCode) /* It's not currently possible to get a nonzero exit code back because Buildkit raises an error. We could perhaps have the shim mask the exit status and always exit 0, but we would have to be careful not to let that happen in a big chained LLB since it would prevent short-circuiting. We could only do it when the user requests the exitCode, but then we would actually need to run the command _again_ since we'd need some way to tell the shim what to do. Hmm... err = testutil.Query( `{ container { from(address: "alpine:3.16.2") { withExec(args: ["false"]) { exitCode } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.WithExec.ExitCode, 1) */ } func TestContainerExecStdoutStderr(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { From struct { WithExec struct { Stdout string Stderr string } } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { withExec(args: ["sh", "-c", "echo hello; echo goodbye >/dev/stderr"]) { stdout stderr } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.WithExec.Stdout, "hello\n") require.Equal(t, res.Container.From.WithExec.Stderr, "goodbye\n") } func TestContainerExecStdin(t *testing.T) { t.Parallel() res := struct { Container struct { From struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
WithExec struct { Stdout string } } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { withExec(args: ["cat"], stdin: "hello") { stdout } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.WithExec.Stdout, "hello") } func TestContainerExecRedirectStdoutStderr(t *testing.T) { t.Parallel() res := struct { Container struct { From struct { WithExec struct { Out, Err struct { Contents string } } }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
} }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { withExec( args: ["sh", "-c", "echo hello; echo goodbye >/dev/stderr"], redirectStdout: "out", redirectStderr: "err" ) { out: file(path: "out") { contents } err: file(path: "err") { contents } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.WithExec.Out.Contents, "hello\n") require.Equal(t, res.Container.From.WithExec.Err.Contents, "goodbye\n") c, ctx := connect(t) defer c.Close() execWithMount := c.Container().From("alpine:3.16.2"). WithMountedDirectory("/mnt", c.Directory()). WithExec([]string{"sh", "-c", "echo hello; echo goodbye >/dev/stderr"}, dagger.ContainerWithExecOpts{ RedirectStdout: "/mnt/out",
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
RedirectStderr: "/mnt/err", }) stdout, err := execWithMount.File("/mnt/out").Contents(ctx) require.NoError(t, err) require.Equal(t, "hello\n", stdout) stderr, err := execWithMount.File("/mnt/err").Contents(ctx) require.NoError(t, err) require.Equal(t, "goodbye\n", stderr) err = testutil.Query( `{ container { from(address: "alpine:3.16.2") { exec( args: ["sh", "-c", "echo hello; echo goodbye >/dev/stderr"], redirectStdout: "out", redirectStderr: "err" ) { stdout stderr } } } }`, &res, nil) require.Error(t, err) require.Contains(t, err.Error(), "stdout: no such file or directory") require.Contains(t, err.Error(), "stderr: no such file or directory") } func TestContainerNullStdoutStderr(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { From struct { Stdout *string Stderr *string } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { stdout stderr } } }`, &res, nil) require.NoError(t, err) require.Nil(t, res.Container.From.Stdout) require.Nil(t, res.Container.From.Stderr) } func TestContainerExecWithWorkdir(t *testing.T) { t.Parallel() res := struct { Container struct { From struct { WithWorkdir struct { WithExec struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Stdout string } } } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { withWorkdir(path: "/usr") { withExec(args: ["pwd"]) { stdout } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.WithWorkdir.WithExec.Stdout, "/usr\n") } func TestContainerExecWithUser(t *testing.T) { t.Parallel() res := struct { Container struct { From struct { User string WithUser struct { User string WithExec struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Stdout string } } } } }{} t.Run("user name", func(t *testing.T) { err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { user withUser(name: "daemon") { user withExec(args: ["whoami"]) { stdout } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, "", res.Container.From.User) require.Equal(t, "daemon", res.Container.From.WithUser.User) require.Equal(t, "daemon\n", res.Container.From.WithUser.WithExec.Stdout) }) t.Run("user and group name", func(t *testing.T) { err := testutil.Query( `{ container {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
from(address: "alpine:3.16.2") { user withUser(name: "daemon:floppy") { user withExec(args: ["sh", "-c", "whoami; groups"]) { stdout } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, "", res.Container.From.User) require.Equal(t, "daemon:floppy", res.Container.From.WithUser.User) require.Equal(t, "daemon\nfloppy\n", res.Container.From.WithUser.WithExec.Stdout) }) t.Run("user ID", func(t *testing.T) { err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { user withUser(name: "2") { user withExec(args: ["whoami"]) { stdout } } } }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
}`, &res, nil) require.NoError(t, err) require.Equal(t, "", res.Container.From.User) require.Equal(t, "2", res.Container.From.WithUser.User) require.Equal(t, "daemon\n", res.Container.From.WithUser.WithExec.Stdout) }) t.Run("user and group ID", func(t *testing.T) { err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { user withUser(name: "2:11") { user withExec(args: ["sh", "-c", "whoami; groups"]) { stdout } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, "", res.Container.From.User) require.Equal(t, "2:11", res.Container.From.WithUser.User) require.Equal(t, "daemon\nfloppy\n", res.Container.From.WithUser.WithExec.Stdout) }) } func TestContainerExecWithEntrypoint(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { From struct { Entrypoint []string WithEntrypoint struct { Entrypoint []string WithExec struct { Stdout string } WithEntrypoint struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Entrypoint []string } } } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { entrypoint withEntrypoint(args: ["sh", "-c"]) { entrypoint withExec(args: ["echo $HOME"]) { stdout } withEntrypoint(args: []) { entrypoint } } } } }`, &res, nil) require.NoError(t, err) require.Empty(t, res.Container.From.Entrypoint) require.Equal(t, []string{"sh", "-c"}, res.Container.From.WithEntrypoint.Entrypoint) require.Equal(t, "/root\n", res.Container.From.WithEntrypoint.WithExec.Stdout) require.Empty(t, res.Container.From.WithEntrypoint.WithEntrypoint.Entrypoint) } func TestContainerWithDefaultArgs(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
t.Parallel() res := struct { Container struct { From struct { Entrypoint []string DefaultArgs []string WithExec struct { Stdout string } WithDefaultArgs struct { Entrypoint []string DefaultArgs []string } WithEntrypoint struct { Entrypoint []string DefaultArgs []string WithExec struct { Stdout string } WithDefaultArgs struct { Entrypoint []string DefaultArgs []string WithExec struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Stdout string } } } } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { entrypoint defaultArgs withDefaultArgs { entrypoint defaultArgs } withEntrypoint(args: ["sh", "-c"]) { entrypoint defaultArgs withExec(args: ["echo $HOME"]) { stdout } withDefaultArgs(args: ["id"]) { entrypoint defaultArgs withExec(args: []) { stdout }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
} } } } }`, &res, nil) t.Run("default alpine (no entrypoint)", func(t *testing.T) { require.NoError(t, err) require.Empty(t, res.Container.From.Entrypoint) require.Equal(t, []string{"/bin/sh"}, res.Container.From.DefaultArgs) }) t.Run("with nil default args", func(t *testing.T) { require.Empty(t, res.Container.From.WithDefaultArgs.Entrypoint) require.Empty(t, res.Container.From.WithDefaultArgs.DefaultArgs) }) t.Run("with entrypoint set", func(t *testing.T) { require.Equal(t, []string{"sh", "-c"}, res.Container.From.WithEntrypoint.Entrypoint) require.Equal(t, []string{"/bin/sh"}, res.Container.From.WithEntrypoint.DefaultArgs) }) t.Run("with exec args", func(t *testing.T) { require.Equal(t, "/root\n", res.Container.From.WithEntrypoint.WithExec.Stdout) }) t.Run("with default args set", func(t *testing.T) { require.Equal(t, []string{"sh", "-c"}, res.Container.From.WithEntrypoint.WithDefaultArgs.Entrypoint) require.Equal(t, []string{"id"}, res.Container.From.WithEntrypoint.WithDefaultArgs.DefaultArgs) require.Equal(t, "uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel),11(floppy),20(dialout),26(tape),27(video)\n", res.Container.From.WithEntrypoint.WithDefaultArgs.WithExec.Stdout) }) } func TestContainerExecWithEnvVariable(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { From struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
WithEnvVariable struct { WithExec struct { Stdout string } } } } }{} err := testutil.Query( `{ container { from(address: "alpine:3.16.2") { withEnvVariable(name: "FOO", value: "bar") { withExec(args: ["env"]) { stdout } } } } }`, &res, nil) require.NoError(t, err) require.Contains(t, res.Container.From.WithEnvVariable.WithExec.Stdout, "FOO=bar\n") } func TestContainerVariables(t *testing.T) { t.Parallel() res := struct { Container struct { From struct { EnvVariables []schema.EnvVariable WithExec struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Stdout string } } } }{} err := testutil.Query( `{ container { from(address: "golang:1.18.2-alpine") { envVariables { name value } withExec(args: ["env"]) { stdout } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, []schema.EnvVariable{ {Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, {Name: "GOLANG_VERSION", Value: "1.18.2"}, {Name: "GOPATH", Value: "/go"}, }, res.Container.From.EnvVariables) require.Contains(t, res.Container.From.WithExec.Stdout, "GOPATH=/go\n") } func TestContainerVariable(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { From struct { EnvVariable *string } } }{} err := testutil.Query( `{ container { from(address: "golang:1.18.2-alpine") { envVariable(name: "GOLANG_VERSION") } } }`, &res, nil) require.NoError(t, err) require.NotNil(t, res.Container.From.EnvVariable) require.Equal(t, "1.18.2", *res.Container.From.EnvVariable) err = testutil.Query( `{ container { from(address: "golang:1.18.2-alpine") { envVariable(name: "UNKNOWN") } } }`, &res, nil) require.NoError(t, err) require.Nil(t, res.Container.From.EnvVariable) } func TestContainerWithoutVariable(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
t.Parallel() res := struct { Container struct { From struct { WithoutEnvVariable struct { EnvVariables []schema.EnvVariable WithExec struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Stdout string } } } } }{} err := testutil.Query( `{ container { from(address: "golang:1.18.2-alpine") { withoutEnvVariable(name: "GOLANG_VERSION") { envVariables { name value } withExec(args: ["env"]) { stdout } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.WithoutEnvVariable.EnvVariables, []schema.EnvVariable{ {Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, {Name: "GOPATH", Value: "/go"}, }) require.NotContains(t, res.Container.From.WithoutEnvVariable.WithExec.Stdout, "GOLANG_VERSION") } func TestContainerEnvVariablesReplace(t *testing.T) {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
t.Parallel() res := struct { Container struct { From struct { WithEnvVariable struct { EnvVariables []schema.EnvVariable WithExec struct { Stdout string } }
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
} } }{} err := testutil.Query( `{ container { from(address: "golang:1.18.2-alpine") { withEnvVariable(name: "GOPATH", value: "/gone") { envVariables { name value } withExec(args: ["env"]) { stdout } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.WithEnvVariable.EnvVariables, []schema.EnvVariable{ {Name: "PATH", Value: "/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}, {Name: "GOLANG_VERSION", Value: "1.18.2"}, {Name: "GOPATH", Value: "/gone"}, }) require.Contains(t, res.Container.From.WithEnvVariable.WithExec.Stdout, "GOPATH=/gone\n") } func TestContainerWorkdir(t *testing.T) { t.Parallel() res := struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
Container struct { From struct { Workdir string WithExec struct { Stdout string } } } }{} err := testutil.Query( `{ container { from(address: "golang:1.18.2-alpine") { workdir withExec(args: ["pwd"]) { stdout } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.Workdir, "/go") require.Equal(t, res.Container.From.WithExec.Stdout, "/go\n") } func TestContainerWithWorkdir(t *testing.T) { t.Parallel() res := struct { Container struct {
closed
dagger/dagger
https://github.com/dagger/dagger
3,025
Include output of failed exec in graphql errors
Right now if an exec fails the graphql error just says that it exited non-zero. This makes it hard to debug unless you go look at the buildkit progress output. We should instead include the output of the execop in the graphql error to help debugging. The implementation is not incredibly straightforward. Buildkit has the ability to obtain the FS of a failed exec op (including changes made during the command): https://github.com/moby/buildkit/blob/c9a0f4d2de095591e742d7f411d9ed36a03a1c4e/client/build_test.go#L1278-L1310 We will probably need to use that to obtain the output as written to the output files by the shim. We should also make sure to limit the size of the output included so if there's a failure during a command with many megabytes of output (e.g. compiling a large project) we don't try to transfer all of that in the error. Instead, we can just return the last N bytes.
https://github.com/dagger/dagger/issues/3025
https://github.com/dagger/dagger/pull/4161
5257ac03f6bae55e7f8ac4d0713251b9e0499aa3
a795bea02f59a980912cf95e04902b5a77cab39a
2022-09-07T20:42:51Z
go
2022-12-12T21:30:21Z
core/integration/container_test.go
From struct { WithWorkdir struct { Workdir string WithExec struct { Stdout string } } } } }{} err := testutil.Query( `{ container { from(address: "golang:1.18.2-alpine") { withWorkdir(path: "/usr") { workdir withExec(args: ["pwd"]) { stdout } } } } }`, &res, nil) require.NoError(t, err) require.Equal(t, res.Container.From.WithWorkdir.Workdir, "/usr") require.Equal(t, res.Container.From.WithWorkdir.WithExec.Stdout, "/usr\n") } func TestContainerWithMountedDirectory(t *testing.T) { t.Parallel() dirRes := struct {