Skip to content

Europa: finalize engine.#Exec #1211

Closed
Closed

Description

@shykes

Status

Issue description Status Notes
Missing field: user ✅ Added
Missing field: always ✅ Added
Missing field: hosts ✅ Added
Unresolved design issues: stdin, stdout, stderr ✅ Removed Needs more design work. Bring back when it’s ready
Unresolved design issues: exit ✅ Left a exit: 0 field to indicate need for future API expansion Expand API when implementation allows
env: map or list? ✅ Changed to map Let’s follow our principles of maximizing CUE nativeness, and not over-optimize for a develop error scenario that is still hypothetical. If it becomes an issue, we can remediate with scanning, best practice documentation, etc.
mounts: map or list? ✅ Changed to map see env
#CacheDir.id: is this useful? ✅ added to the spec to support TheChangelog use case. This seems like the correct DX. cc @gerhard @grouville @jlongtine
mounts: [string]: { contents: #Secret, optional: bool } what does optional do? ✅ maps to buildkit API

Discussion

Feedback from @aluzzardi, with inline resolution status.

Just started implementing this. A few questions when comparing to op.#Exec:

Missing:

  • user

Will add.

  • always

Will add.

  • hosts

Will add.

Extra features, not doable without exec helper:

  • stdout
  • stdin
  • stderr
  • exit
  • Based on our understanding of how a future exec helper will work, does the current API seem accurate (if not, I will change now)
  • I will modify the package so that it’s clear the feature is 1) planned for future versions, 2) not yet implemented.

Changes:

  • env used to be a map, now it's an array of strings named environ --> why?

This is to discourage Cue-style inheritance / specialization between #Exec calls, which would not work as the developer expects, because of runtime IDs.

For example:

foo: engine.#Exec & {
  args: [“echo”, “hello”]
}

bar: foo & {
  env: “DEBUG”: “1”
}

This will break because the engine will only fill a single exec ID, and it will be shared between 2 commands. We replace maps with lists in engine to discourage this pattern, similar to how Go randomizes maps to discourage relying on stable order.

  • args is either an array or a string --> is the runtime supposed to shlex args?

No, engine should never shlex. There is a pure CUE convenience in the higher-level docker package.

  • mounts used to be a map, it's now a list of #Mount --> why?

Same as env.

  • #CacheDir now takes an id, how is the user supposed to use that?

This is from @gerhard ‘s Changelog configuration, pinging @jlongtine and @grouville for more context :)

  • secret mounts have an optional field, what does it do?

(FIXME I will look into this one shortly)

Activity

  1. added this to the milestone on Dec 13, 2021
  2. self-assigned this
    on Dec 13, 2021
  3. aluzzardi commented on Dec 14, 2021

    @aluzzardi
    Contributor

    Missing:

    • user

    Will add.

    👍

    • always

    Will add.

    👍

    • hosts

    Will add.

    👍

    Extra features, not doable without exec helper:

    • stdout
    • stdin
    • stderr
    • exit

    Based on our understanding of how a future exec helper will work, does the current API seem accurate (if not, I will change now)

    For stdin/stdout/stderr there's the open question about dagger.#Stream (and the deadlock)

    For exit, I'm wondering how to control the behavior (e.g. "continue on failure"). But that's probably orthogonal to defining the exit field.

    Changes:

    • env used to be a map, now it's an array of strings named environ --> why?

    This is to discourage Cue-style inheritance / specialization between #Exec calls, which would not work as the developer expects, because of runtime IDs.

    For example:

    foo: engine.#Exec & {
      args: [“echo”, “hello”]
    }
    
    bar: foo & {
      env: “DEBUG”: “1”
    }
    

    Ok, I get it now.

    But aren't we just pushing the problem around? If you replace engine.#Exec with docker.#Run in the snippet above, we'd end up in the same situation I think.

    • args is either an array or a string --> is the runtime supposed to shlex args?

    No, engine should never shlex. There is a pure CUE convenience in the higher-level docker package.

    Does it behave like a single element array? Can't the high level package just deal with it?

    • mounts used to be a map, it's now a list of #Mount --> why?

    Same as env.

    👍

    • #CacheDir now takes an id, how is the user supposed to use that?

    This is from @gerhard ‘s Changelog configuration, pinging @jlongtine and @grouville for more context :)

    Sounds good. Curious about context, specifically the implication is packages (e.g. yarn) are now supposed to take a #CacheDir as argument rather than declaring their own. Which is totally fine but changes the way we write packages.

    • secret mounts have an optional field, what does it do?

    (FIXME I will look into this one shortly)

    👍

  4. shykes commented on Dec 14, 2021

    @shykes
    ContributorAuthor
    • env used to be a map, now it's an array of strings named environ --> why?

    This is to discourage Cue-style inheritance / specialization between #Exec calls, which would not work as the developer expects, because of runtime IDs.

    For example:

    foo: engine.#Exec & {
      args: [“echo”, “hello”]
    }
    
    bar: foo & {
      env: “DEBUG”: “1”
    }
    

    Ok, I get it now.

    But aren't we just pushing the problem around? If you replace engine.#Exec with docker.#Run in the snippet above, we'd end up in the same situation I think.

    Ouch… You’re right! Goddamn.

    • args is either an array or a string --> is the runtime supposed to shlex args?

    No, engine should never shlex. There is a pure CUE convenience in the higher-level docker package.

    Does it behave like a single element array? Can't the high level package just deal with it?

    My bad, it should be args: […string. I will clean it up.

    • mounts used to be a map, it's now a list of #Mount --> why?

    Same as env.

    👍

    So, same problem as env…

  5. shykes commented on Dec 14, 2021

    @shykes
    ContributorAuthor

    Status update:

    Missing:

    • user

    Will add.

    Added in #1223 .

    • always

    Will add.

    Added in #1223.

    • hosts

    Will add.

    Added in #1223.

    Extra features, not doable without exec helper:

    • stdout
    • stdin
    • stderr

    I decided to remove those 3 fields in #1223, and opened #1222 to track outstanding API design discussion. Seems cleaner and simpler that way.

    • secret mounts have an optional field, what does it do?

    This is from the Buildkit API. It tells Buildkit whether it’s OK for the source secret file to not exist. I just mapped it as is.

  6. shykes commented on Dec 15, 2021

    @shykes
    ContributorAuthor

    @aluzzardi I added a status table at the top, to make it more readable. There are 3 issues left that require discussion:

    • exit hardcode to zero, or remove for now? I propose hardcode to zero.
    • env: map or list? I propose list.
    • mounts: map or list? I propose list.
  7. shykes commented on Dec 17, 2021

    @shykes
    ContributorAuthor

    All outstanding issues are resolved in #1223.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions