Skip to content

[CUE] #Exec: allow capturing exit status if command fails #1245

Closed as not planned

Description

@shykes

Currently, core.#Exec will interrupt DAG execution entirely if the command returns a non-zero exit code, aka an error. This makes it very difficult to write a Dagger configuration with custom behavior on command failure. The only way is to execute a wrapper command, for example a shell script, that will implement the exit code capture, and communicate back to the CUE config. This is repetitive and a bad DX.

Ideally, core.#Exec would allow 1) configuring whether or not to abort DAG execution on command failure, and 2) retrieving the exit code and perhaps error messages from the CUE configuration.

A first step in this direction is the current #Exec: exit: int & 0. The & 0 indicates that, at the moment, the if exit can be queried, that means that its value is zero (otherwise DAG execution would be terminated). This makes the field effectively useless - but it plants a flag in the ground for future API expansion. That API expansion is to be discussed, and its details finalized, in this issue.

Activity

  1. added this to the milestone on Dec 17, 2021
  2. changed the title [-]engine.#Exec: allow capturing exit status if command fails[/-] [+]Europa: engine.#Exec: allow capturing exit status if command fails[/+] on Jan 11, 2022
  3. changed the title [-]Europa: engine.#Exec: allow capturing exit status if command fails[/-] [+]#Exec: allow capturing exit status if command fails[/+] on Mar 27, 2022
  4. jpluscplusm commented on May 7, 2022

    @jpluscplusm
    Contributor

    I'm currently working on embedding (shell) tests as directly into Dagger as possible. I hope(!) this will help advance the state of art of short scripts being "simple" enough to embed directly into Plans, but where -- as we know happens all too often -- they accrete complexity and nuance over time ... but because no first-class-citizen test framework is available, they simultaneously accumulate no extra tests, if any were even present to begin with.

    Having the ability to assert against the exit code of a core.#Exec would reduce the implementation complexity of this subsystem /significantly/, as it would allow for meaningful negative assertions/tests to be part of the DAG. This is mentioned by @samalba in #989 (comment).

    As it stands, right now I'll have to do as @aluzzardi mentions in #74 (comment), and inject a custom entry point into each container that's used as a script execution environment, as well as dealing with stdin/stdout as per the options mentioned in #1620.

  5. reopened this on Oct 20, 2022
  6. changed the title [-]#Exec: allow capturing exit status if command fails[/-] [+][CUE] #Exec: allow capturing exit status if command fails[/+] on Oct 20, 2022
  7. shykes commented on Oct 20, 2022

    @shykes
    ContributorAuthor

    Sorry about the open/close flip-flop.

  8. shykes commented on Jan 4, 2023

    @shykes
    ContributorAuthor

    I'm closing this, since it's specific to the CUE SDK and we are not adding features to the CUE API at this time. Note that the issue is not yet fixed in the GraphQL API either, but it will be eventually. That is tracked in #3192

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions