8000 Cache volumes created by Pack are not cleaned up by `libcnb-test` · Issue #570 · heroku/libcnb.rs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Cache volumes created by Pack are not cleaned up by libcnb-test #570
Closed
@edmorley

Description

@edmorley

I recently ran into buildpack IO errors during a pack build that turned out to be due to disk space exhaustion on the macOS Docker Desktop created VM - caused by leftover Docker volumes used by Pack for caching.

There were ~800 named Docker volumes that consumed 40GB of disk space, of form:

$ docker volume ls
DRIVER    VOLUME NAME
local     pack-cache-library_libcnbtest_abnaipzkqlhfeopwdzgpcmwnldonle_latest-ce76e11c69c4.build
local     pack-cache-library_libcnbtest_abnaipzkqlhfeopwdzgpcmwnldonle_latest-ce76e11c69c4.launch
local     pack-cache-library_libcnbtest_actqilpclbkigdmjhdrhgnuwgealsm_latest-a44e7557da8c.build
local     pack-cache-library_libcnbtest_actqilpclbkigdmjhdrhgnuwgealsm_latest-a44e7557da8c.launch
local     pack-cache-library_libcnbtest_actyjtmpayftrpdhfehpwefuffycaf_latest-d0ec397b5241.build
local     pack-cache-library_libcnbtest_actyjtmpayftrpdhfehpwefuffycaf_latest-d0ec397b5241.launch
...

For normal (non-integration testing) usage of Pack CLI, one wouldn't end up with hundreds of these volumes, since caches are re-used/replaced for the same output image name. The reason we end up with hundreds when using libcnb-test is that it uses a random image name each time (which is the right thing for it to do), but whilst it deletes the images at the end of each test, it doesn't currently delete the image's associated Pack cache volumes.

I've started a discussion ups 5FAE tream about some potential improvements upstream (for example, adding pack cache prune commands or similar, and also asking why Pack is creating these volumes for layers that also exist in the final app image):
https://cloud-native.slack.com/archives/C0331B61A1Y/p1683817627443339

However, libcnb-test will need to handle this even with those improvements upstream.

To avoid this issue, libcnb-test can use the new --cache argument to pack build, and either:

  1. Continue to use volume-based caching, but pass in an explicit (and random) volume name, that libcnb-test can then remove when TestContext is dropped. (For example: --cache='type=build;format=volume;name=<volume-name>;type=launch;format=volume;name=<volume-name>')
  2. Or, switch to bind mount based caching, and pass in a temporary directory as the cache location, that libcnb-test can then remove when TestContext is dropped. (For example: --cache='type=build;format=bind;source=<a-tmp-dir>;type=launch;format=bind;source=<a-tmp-dir>')

GUS-W-13195631.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0