tilt icon indicating copy to clipboard operation
tilt copied to clipboard

image pruner should work on custom_build images

Open nicks opened this issue 4 years ago • 3 comments

When Tilt builds an image with docker_build, it gets the label builtby=tilt.

Tilt uses this as a signal that it can clean these images up later to save on disk space.

But if you use custom_build to build your images, the tilt image pruner won't clean them up.

I can imagine a few different ways to fix this, including:

  • Tilt re-labeling the image post-build
  • Updating the custom_build examples to add the label, or otherwise update the API so that users add their own labels
  • Using another mechanism to find images from custom_build

nicks avatar Dec 20 '20 18:12 nicks

@dnephin - to answer some of your questions in the other bug you filed

  1. the dev.tilt.gc=true label was never intended as a full-service api for helping people write custom_build scripts that interoperate with the pruner, though i guess we could evolve it into one
  2. the custom_build api is complex with a lot of different modes, and a lot of gotchas, so we have to be a bit careful
  3. a simple example of point (2) is that you say your build is producing tags like tilt-20230602110058-29047, but..i don't think anything in Tilt produces tags like that? are you sure your script isn't producing those tags? i may be misremembering. i did not see tags like that when i tested on a project that used custom_build.

nicks avatar Jun 02 '23 19:06 nicks

@nicks Thank you for the response! I looked and you are correct that these image tags are from our script. I believe this was to satisfy the outputs_image_ref_to parameter to custom_build. Since it's not actually a content hash but a random tag, that is breaking the GC. The second problem definitely looks like something that I can fix outside of tilt.

What do you think about the first proposed change? Expanding HasDockerBuild so that the GC will run.

dnephin avatar Jun 02 '23 22:06 dnephin

@dnephin ya, that proposal seems good 👍

nicks avatar Jun 03 '23 04:06 nicks