#Failed ExecOp
1 messages · Page 1 of 1 (latest)
Example of what I mean:
query {
container {
from(address: "alpine") {
withExec(args: ["false"]) {
withExec(args: ["echo", "hello"]) {
stdout
}
}
}
}
}
Failed ExecOp
Yeah the information needed to determine that is available, when we catch the error we also get the raw LLB for the exec op that failed: https://github.com/dagger/dagger/blob/51f6dd9c5c2e64e55ff497a48ce1886bbca77103/core/gateway.go#L138
That being said, we'd need to be able to map that LLB object to our higher-level exec object. I don't think that'd be too hard, just need to setup a little more plumbing
Curious what the precise use case is though too
Use case is to be able to know in stdout if error is from last command or not, for the possibility of getting that value only for last exec.
If you run a test suite, linter, etc… some people need the full stdout/stderr in case of failure. Right now it doesn’t work but only makes sense to not fail if it’s the last exec, like it says in the api docs.
Any pointers on how you’d map that? In other words what can be used from Op_Exec (from SolveError) for that?
Yeah the connection point is when we marshal LLB in WithExec's implementation: https://github.com/sipsma/dagger/blob/52d5756ebc97ead1a175c59f812d883a74982a8f/core/container.go#L1200-L1200
You get a *pb.Definition, which has field Def of type [][]byte: https://github.com/sipsma/buildkit/blob/f1223ede9c643b08b06e4a740a82977c900b10c6/solver/pb/ops.pb.go#L1857-L1857
You can unmarshal those bytes in Def to get pb.Ops. There's an example of doing this in some buildkit debugging tooling here: https://github.com/sipsma/buildkit/blob/f1223ede9c643b08b06e4a740a82977c900b10c6/cmd/buildctl/debug/dumpllb.go#L70-L76
That is the same structure you get in SolveError: https://github.com/dagger/dagger/blob/51f6dd9c5c2e64e55ff497a48ce1886bbca77103/core/gateway.go#L134
We can compare the two using the digest of the bytes (same as what 's done here: https://github.com/sipsma/buildkit/blob/f1223ede9c643b08b06e4a740a82977c900b10c6/cmd/buildctl/debug/dumpllb.go#L76)
I think there's some extra tracking/plumbing that we'd need in our core/ code to actually know which pb.Ops correspond to which Execs in the current pipeline. Not immediately sure the precise form that could take, but also feels possible
Cool, that helps, thanks 🙂
Ok, got the digests to match so it's doable. 👍
command: [sh -c echo false; exit 11]
digest: sha256:0749c3b04db5493d0dc6fece34c1bca85fa0c59968f9f937048954c75e1062cc
command: [echo hello]
digest: sha256:336e47881a0436b387d000968edc69b9c21c277ad9332decc34101a723c948d7
{
"data": null,
"errors": [
{
"message": "process \"sh -c echo false; exit 11\" did not complete successfully: exit code: 11",
"locations": [
{
"line": 1,
"column": 137
}
],
"path": [
"container",
"from",
"withExec",
"withExec",
"stdout"
],
"extensions": {
"CMD": "sh -c echo false; exit 11",
"DIGEST": "sha256:0749c3b04db5493d0dc6fece34c1bca85fa0c59968f9f937048954c75e1062cc",
"EXIT_CODE": 11,
"STDERR": "",
"STDOUT": "false"
}
}
]
}