Open chris-stetter opened 1 year ago
It looks like the reason that this will happen is that our first step when using a docker image is to get an expanded image ID, including its sha256: https://github.com/pantsbuild/pants/blob/4a0af5e875f2fa53dea63415b50dbcb33be96a50/src/python/pants/core/util_rules/environments.py#L848-L877
...and currently the DockerResolveImageRequest
intrinsic is implemented by first pulling the image, and then docker inspect
ing it: https://github.com/pantsbuild/pants/blob/4a0af5e875f2fa53dea63415b50dbcb33be96a50/src/rust/engine/src/intrinsics.rs#L682-L736
Some googling shows that it should be possible to get an image ID without first pulling... but AFAICT it looks like that would require direct access to the docker registry, rather than being provided by the CLI or the bollard crate.
In the meantime: as shown in the first section, if you include the sha256
tag of your image in the image name in your docker_environment
target, we won't pull the image to append it.
Due to https://github.com/pantsbuild/pants/issues/17714, I tried building an image with pants first and then use its sha to use that image in a docker_environment
. As it always tries to pull first, this will not work.
Are there any plans to stabilize the environments feature?
I have a tentative fix for #17714, and that seems like a good step in solving this issue (or at least mitigating it). It doesn't solve the problem directly, but it pushes the problem one step back - so that better caching of Pants-created docker_image
s/meta will directly speed up the workflow and everything is kept in the ecosystem.
At the moment, my fix still asks for a BuiltPackage, and since that is run PER_SESSION
, there is still a perf hit.
The part I'm stuck on must be cacheable though, I just haven't gone through all the available APIs yet.
Describe the bug When using the new environments feature where a test is executed within a Docker container and remote caching is used, the Docker image still gets pulled even though the test is cached subsequently:
Pants version 2.15
OS GitHub Actions, so Linux
Additional info As pointed out by @stuhood in https://github.com/pantsbuild/pants/issues/15199#issuecomment-1376564332, the Docker image pull should not be triggered or canceled.