#Failed ExecOp

1 messages · Page 1 of 1 (latest)

tulip night
#

Example of what I mean:

query {
  container {
    from(address: "alpine") {
      withExec(args: ["false"]) {
        withExec(args: ["echo", "hello"]) {
          stdout
        }
      }
    }
  }
}
#

Failed ExecOp

tulip hearth
#

Curious what the precise use case is though too

tulip night
#

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?

tulip hearth
# tulip night Any pointers on how you’d map that? In other words what can be used from Op_Exec...

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

#

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

tulip night
#

Cool, that helps, thanks 🙂

tulip night
#

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"
      }
    }
  ]
}