Merge pull request #331 from dagger/fix-double-exec

Fixed duplicated execution on `op.#Exec.always: true`
This commit is contained in:
Andrea Luzzardi
2021-04-15 13:09:00 -07:00
committed by GitHub
6 changed files with 32 additions and 24 deletions

View File

@@ -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() {

View File

@@ -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
}