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
I was (naively?) expecting that "component" would run only once (and that "always: true" would ensure that it will re-run on subsequent executions), but in fact it's actually running twice (eg: it's acting like it has been inlined into test1 and test2).
Is this what you guys wanted/expected?
I guess it's somewhat confusing coming from a "usual" language.
Concretely, in a programing language I was expecting:
In that case, buildkit optimize out both random string generation (because they "look" the same to buildkit).
This kinda makes sense from a caching perspective, but is also confusing, for similar reasons as above.
As a developper the external "component" and the embedded one feel to me like they are really different "objects".
eg, in bash lingo, that would "naively" express as:
component=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13)
test1=$(echo $component)
test2=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13)
I was able to repro. I tried to implement the fix @aluzzardi suggested: set the env var DAGGER_CACHEBUSTER only if it was not set before. However it requires to store the info in the task (when setting the env var for the first time), so we can then check if the env var was already set previously. I did not find a clean way to store the info in the cue tree (requires a fill() inside the pipeline array).
A cleaner way would be to implement a task store for metadata that we could reuse for other things.
Activity
dubo-dubon-duponey commentedon Jan 15, 2021
Conversely, consider the following:
In that case, buildkit optimize out both random string generation (because they "look" the same to buildkit).
This kinda makes sense from a caching perspective, but is also confusing, for similar reasons as above.
As a developper the external "component" and the embedded one feel to me like they are really different "objects".
eg, in bash lingo, that would "naively" express as:
Which is clearly not what we get here.
aluzzardi commentedon Feb 5, 2021
Good one. Indeed, dagger naively sends every
#dagger: computeit finds to buildkit, letting it do deduplication.Which works out well most of the time. However,
always: trueforces buildkit not to cache and therefore, not to dedup.I agree this is very confusing, especially when doing a copy or a mount, you'd expect the component to be referenced, not embedded and re-executed.
Bumping this to a bug.
/cc @shykes
shykes commentedon Feb 5, 2021
Nice catch. I think we can implement
always: truein such a way that the same random cache-buster is re-used across an entire compute job.[-]Question about "shared" component execution [/-][+]Duplicate execution with `always: true`[/+]samalba commentedon Mar 9, 2021
I was able to repro. I tried to implement the fix @aluzzardi suggested: set the env var
DAGGER_CACHEBUSTERonly if it was not set before. However it requires to store the info in the task (when setting the env var for the first time), so we can then check if the env var was already set previously. I did not find a clean way to store the info in the cue tree (requires a fill() inside the pipeline array).A cleaner way would be to implement a task store for metadata that we could reuse for other things.