dagger: `Container { exitCode }` doesn't work if the command fails
We currently expose this API:
type Container {
exitCode: Int
}
…but the only possible value returned here is null or 0. If the command exits nonzero Buildkit will error instead.
We could have the shim mask the exit status, but we would probably only want to do that if the user is requesting exitCode, but then that changes the underlying LLB. 🤔
The same is true for stdout and stderr that share the same underlying code.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 6
- Comments: 30 (26 by maintainers)
Commits related to this issue
- fix: Use verbose logging always to see precommit output. This is a workaround for issue: https://github.com/dagger/dagger/issues/3192. — committed to mesosphere/d2iq-daggers by aweris 2 years ago
- fix: Use verbose logging always to see precommit output. (#30) This is a workaround for issue: https://github.com/dagger/dagger/issues/3192. — committed to mesosphere/d2iq-daggers by aweris 2 years ago
- Container: add Run helper This is a convenience API to replace this pattern: ```go code, err := container.ExitCode(ctx) if err != nil { return err } if code != 0 { return fmt.Errorf("exit code: ... — committed to vito/dagger by vito a year ago
- Container: add Run helper This is a convenience API to replace this pattern: ```go code, err := container.ExitCode(ctx) if err != nil { return err } if code != 0 { return fmt.Errorf("exit code: ... — committed to vito/dagger by vito a year ago
- Container: add Run helper This is a convenience API to replace this pattern: ```go code, err := container.ExitCode(ctx) if err != nil { return err } if code != 0 { return fmt.Errorf("exit code: ... — committed to vito/dagger by vito a year ago
- Container: add Run helper This is a convenience API to replace this pattern: ```go code, err := container.ExitCode(ctx) if err != nil { return err } if code != 0 { return fmt.Errorf("exit code: ... — committed to vito/dagger by vito a year ago
- Container: add Run helper This is a convenience API to replace this pattern: ```go code, err := container.ExitCode(ctx) if err != nil { return err } if code != 0 { return fmt.Errorf("exit code: ... — committed to vito/dagger by vito a year ago
- Container: add Run helper This is a convenience API to replace this pattern: ```go code, err := container.ExitCode(ctx) if err != nil { return err } if code != 0 { return fmt.Errorf("exit code: ... — committed to vito/dagger by vito a year ago
For me, this is a blocker for using Dagger in a local development environment.
Closing in favor of:
I’ve withdrawn the https://github.com/dagger/dagger/issues/4921 proposal, suggesting now a different direction:
That issue explains everything.
Thanks for the feedback @vito (Discord) and @sipsma. I’m clear on the technical feasibility, but I’m not entirely sure on caching yet.
apk install: A failure in this kind of command could be due to a network issue, but also referencing a package that doesn’t exist. You don’t want to cache on the former but it’s no use retrying on the latter.go test: Or lint, etc… most common issue in these cases is that the source code under test needs fixing. In this case I’d want to cache. The run time can easily be long but the result will be the same so it’s wasteful. On the other hand there could also be a bigger issue at hand and debugging it could be harder.It doesn’t seem like it’s possible to tell the difference in a smart way here, so what feels safest is to not cache by default, but add a flag to
withExecto allow caching on failure. That would enable tuning performance for the cases where it makes sense, but it would need to be explicit (thinking about verbosity in the common case of running tests).After writing this I realize that’s basically what you said for
1, @sipsma, so I agree. Just had to lay it out. 😁I’m just trying Dagger for the first time, and it looks broken on my first pass.
Container.Exec()(orWithExec()) returns an error if I execute/bin/false. This shouldn’t be an error: dagger was able to execute the program.Container.ExitCode()exists to check whether it exited as0or something else.