You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expand the Engine API to give developers control over the standard streams (stdin, stdout, stderr) of the commands they’re executing.
This was part in the original Europa spec, but was temporarily removed to resolve outstanding design issues:
How to handle multiple writers? Are they forbidden? Do they randomly share the stream? Undefined behavior? Is the full stream multiplexed to each reader?
How to avoid deadlocks? Unix-style pipes require concurrent execution. But the original spec leads to sequential execution because the stdout/stdin link is considered to be a dependency. This requires further design discussion
How can the streams be used other than to chain commands? Could they eventually be exposed to the client as inputs or outputs?
For reference, here is the original spec:
package engine
#Stream: {
_stream: ID: string
}
#Exec: {
// […]
// Optionally attach to command standard input stream
stdin?: #Stream
// Optionally attach to command standard output stream
stdout?: #Stream
// Optionally attach to command standard error stream
stderr?: #Stream
}
I think this is a risky business. Dagger execution is non-linear and cached, unlike cue/cmd and shell scripts.
Users declare things that should happen -- IMHO dealing with streams is in the realm of imperative scripting and doesn't match the dagger execution model.
Beside the design issues listed above:
What happens with cached tasks?
a reads from b's stdout. Now b is cached. What happens?
Perhaps a gets an EOF immediately. But this means that caching is no longer just caching, it affects the outcome of computation. Which I think would make dagger unpredictable (e.g. running dagger up twice in a row might yield a different result, depending on individual task caching).
stdout / stderr as data
Maybe we can have the runtime helper write stdout/stderr to the filesystem. That way, the runtime could ReadFile at the end of Exec and get consistent results, whether the task was executed or cached. (similar to cue/cmd's stdout: string design)
stdin is a vertex input outside of buildkit
stdin is even more tricky. Since we'd have to rely on a runtime helper, stdin is not part of the LLB vertex.
Example (pseudo-code):
foo: exec.#Command& {
stdin: "foo"args: ["cat"]
}
Run once. foo.stdout is foo.
Now change foo.stdin to bar.
Run again. foo.stdout is stillfoo.
Since stdin is not part of the BuildKit vertex, changing it does not affect cache status.
Activity
aluzzardi commentedon Dec 15, 2021
I think this is a risky business. Dagger execution is non-linear and cached, unlike cue/cmd and shell scripts.
Users declare things that should happen -- IMHO dealing with streams is in the realm of imperative scripting and doesn't match the dagger execution model.
Beside the design issues listed above:
areads fromb's stdout. Nowbis cached. What happens?Perhaps
agets an EOF immediately. But this means that caching is no longer just caching, it affects the outcome of computation. Which I think would make dagger unpredictable (e.g. runningdagger uptwice in a row might yield a different result, depending on individual task caching).stdout/stderras dataMaybe we can have the runtime helper write stdout/stderr to the filesystem. That way, the runtime could ReadFile at the end of Exec and get consistent results, whether the task was executed or cached. (similar to
cue/cmd'sstdout: stringdesign)stdinis a vertex input outside of buildkitstdinis even more tricky. Since we'd have to rely on a runtime helper, stdin is not part of the LLB vertex.Example (pseudo-code):
foo.stdoutisfoo.foo.stdintobar.foo.stdoutis stillfoo.Since
stdinis not part of the BuildKit vertex, changing it does not affect cache status.shykes commentedon Jan 4, 2022
Design issues seem insurmountable, and nobody actually expressed a need for it yet. Closing for now. Resurrect if this becomes needed again.