#Mounting cache with `Owner` set doesn't cache

1 messages · Page 1 of 1 (latest)

nimble storm
#

Mounting a cache volume like

...
WithMountedCache("/mydir/.m2", c.CacheVolume("m2"), dagger.ContainerWithMountedCacheOpts{
  Owner: "jenkins:jenkins",
}).
...

Does not seem to work. The cache is empty even though the exec step populates it every run. This is the first time I am testing a cache like this. We have a tooling container that has a bunch of build tools but it is not allowed to be root within that container. So I have to use the Owner when setting the cache. It seems to do the same thing for WithMountedDirectory too as it seems to be mounting it every time when I have an Owner set.

strange epoch
#
    // A user:group to set for the mounted cache directory.
    //
    // Note that this changes the ownership of the specified mount along with the
    // initial filesystem provided by source (if any). It does not have any effect
    // if/when the cache has already been created.
    //
    // The user and group can either be an ID (1000:1000) or a name (foo:bar).
    //
    // If the group is omitted, it defaults to the same as the user.
    Owner string
#

so basically, if you're setting an Owner and the cache has already been created, it doesn't have any effect which means that it'll act as a standard cache mount for that Owner

nimble storm
#

Hmm I'll try resetting everything tomorrow. I am in the process of converting from a container that has root to one that is only runnable as a specific user. When I was running as root it was caching fine.

strange epoch
nimble storm
#

Reporting back on my findings. Cleaning up the engine+volumes via docker rm -fv worked. Now it's caching with the user. So there was the previous cache (with root) that was still hanging around. Could Dagger identify this sort of cache conflict and log it? If it detects the same CacheVolume present in the system but now it's changed to include an Owner. That would have helped me identify the issue. I ran with dagger run --debug but didn't see anything in the logs that would have helped in this case.

strange epoch
nimble storm
#

Ofc!