Merge pull request #331 from dagger/fix-double-exec
Fixed duplicated execution on `op.#Exec.always: true`
This commit is contained in:
commit
84f914216d
@ -385,13 +385,10 @@ func (p *Pipeline) Exec(ctx context.Context, op *compiler.Value, st llb.State) (
|
||||
}
|
||||
|
||||
// always?
|
||||
// FIXME: initialize once for an entire compute job, to avoid cache misses
|
||||
if cmd.Always {
|
||||
cacheBuster, err := randomID(8)
|
||||
if err != nil {
|
||||
return st, err
|
||||
}
|
||||
opts = append(opts, llb.AddEnv("DAGGER_CACHEBUSTER", cacheBuster))
|
||||
// FIXME: also disables persistent cache directories
|
||||
// There's an ongoing proposal that would fix this: https://github.com/moby/buildkit/issues/1213
|
||||
opts = append(opts, llb.IgnoreCache)
|
||||
}
|
||||
// mounts
|
||||
if mounts := op.Lookup("mount"); mounts.Exists() {
|
||||
|
@ -1,15 +0,0 @@
|
||||
package dagger
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func randomID(size int) (string, error) {
|
||||
b := make([]byte, size)
|
||||
_, err := rand.Read(b)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return fmt.Sprintf("%x", b), nil
|
||||
}
|
@ -19,9 +19,7 @@ import (
|
||||
out: string
|
||||
|
||||
aws.#Script & {
|
||||
// FIXME: we should not rely on the cache for this but it's being
|
||||
// executed several times if enabled: https://github.com/dagger/dagger/issues/42
|
||||
// always: true
|
||||
always: true
|
||||
|
||||
files: {
|
||||
"/inputs/listenerArn": listenerArn
|
||||
|
@ -45,6 +45,7 @@ package op
|
||||
do: "exec"
|
||||
args: [...string]
|
||||
env?: [string]: string
|
||||
// `true` means also ignoring the mount cache volumes
|
||||
always?: true | *false
|
||||
dir: string | *"/"
|
||||
mount: [string]: "tmpfs" | "cache" | {from: _, path: string | *"/"}
|
||||
|
25
tests/compute/success/exec-nocache/main.cue
Normal file
25
tests/compute/success/exec-nocache/main.cue
Normal file
@ -0,0 +1,25 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"dagger.io/alpine"
|
||||
"dagger.io/dagger/op"
|
||||
)
|
||||
|
||||
rand: {
|
||||
string
|
||||
|
||||
#up: [
|
||||
op.#Load & {from: alpine.#Image},
|
||||
op.#Exec & {
|
||||
always: true
|
||||
args: ["sh", "-c", """
|
||||
tr -dc A-Za-z0-9 </dev/urandom | head -c 13 > /id
|
||||
"""]
|
||||
},
|
||||
op.#Export & {source: "/id"},
|
||||
]
|
||||
}
|
||||
|
||||
// If rand is executed twice, cue won't validate
|
||||
ref1: rand
|
||||
ref2: ref1
|
@ -35,6 +35,8 @@ test::compute::simple(){
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/overload/flat
|
||||
test::one "Compute: overloading #Component should work" --exit=0 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/overload/wrapped
|
||||
test::one "Compute: Disabling the cache on exec should not compute twice when referenced by another key" --exit=0 \
|
||||
"$dagger" "${DAGGER_BINARY_ARGS[@]}" compute "$d"/compute/success/exec-nocache
|
||||
}
|
||||
|
||||
test::compute::dependencies(){
|
||||
|
Reference in New Issue
Block a user