diff --git a/dagger/pipeline.go b/dagger/pipeline.go index 271dbb5d..c8f76b81 100644 --- a/dagger/pipeline.go +++ b/dagger/pipeline.go @@ -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() { diff --git a/dagger/utils.go b/dagger/utils.go deleted file mode 100644 index 211516c8..00000000 --- a/dagger/utils.go +++ /dev/null @@ -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 -} diff --git a/stdlib/aws/elb/elb.cue b/stdlib/aws/elb/elb.cue index c5077065..cd6a0851 100644 --- a/stdlib/aws/elb/elb.cue +++ b/stdlib/aws/elb/elb.cue @@ -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 diff --git a/stdlib/dagger/op/op.cue b/stdlib/dagger/op/op.cue index 6bdcc8a4..92ec4c53 100644 --- a/stdlib/dagger/op/op.cue +++ b/stdlib/dagger/op/op.cue @@ -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 | *"/"} diff --git a/tests/compute/success/exec-nocache/main.cue b/tests/compute/success/exec-nocache/main.cue new file mode 100644 index 00000000..fb9eef6b --- /dev/null +++ b/tests/compute/success/exec-nocache/main.cue @@ -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 /id + """] + }, + op.#Export & {source: "/id"}, + ] +} + +// If rand is executed twice, cue won't validate +ref1: rand +ref2: ref1 diff --git a/tests/test-compute.sh b/tests/test-compute.sh index 324d9a64..7d5c22e2 100644 --- a/tests/test-compute.sh +++ b/tests/test-compute.sh @@ -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(){