-
Notifications
You must be signed in to change notification settings - Fork 503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only keep :latest tag for local images #88
Conversation
Images are built, tagged with registry and content-addressable tag, pushed, re-tagged as :latest, and the original tag is removed. This prevents Cog from using a ton of disk space, but builds are still fast since the cached layers from the last build are still kept around thanks to the :latest tag. Signed-off-by: andreasjansson <andreas@replicate.ai>
5601a99
to
57e9751
Compare
Unfortunately I don't think this fixes the issue. When you update a tag, the image the tag previously pointed at is not automatically removed. I tried this locally and the previous image does indeed remain when running a second build: But -- this does at least allow it to be freed up by As I suggested in #80 (but wasn't fully clear about), I think a pointer to the previous image needs to be kept so that when the There's a race condition in here if two images are being built at the same time. Perhaps when removing the image, if it fails it should be ignored. |
Hmm that's odd, there's a test case for exactly the situation you're describing here that checks that only the ":latest" tag is left after a build. This PR doesn't just re-tag, it also removes the old image with I don't think there's a race here, if two versions in the same model but with different IDs are built simultaneously, one of them will end up being tagged as The |
(I noticed another bit of odd behavior in here. The Docker image is being tagged with its id. This is a bit unusual and I think this is creating some confusion about what's going on here. I've prefixed the image IDs with Here is what is happening:
It now looks like this: Now, I push a new version:
It now looks like this: The previous image still exists and won't be cleaned up until I removed it with
The test only tests when an image is pushed the first time.
Sorry to be clear: the race condition exists in the behavior that is probably needed to fix this problem, where a pointer is kept to an image. That image might be removed twice if a push is happening in parallel. As mentioned above, Docker images are being tagged with their ID, which makes Docker behave a bit weirdly (tags and IDs are ambiguous in the user interface). Perhaps we should tag them with their build ID? |
I'm going to get this in because then at least |
This is causing some confusion in Docker behavior. See replicate#88 (comment) Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This is causing some confusion in Docker behavior. See replicate#88 (comment) Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This is causing some confusion in Docker behavior. See replicate#88 (comment) Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This is causing some confusion in Docker behavior. See replicate#88 (comment) Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This is causing some confusion in Docker behavior. See replicate#88 (comment) Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This is causing some confusion in Docker behavior. See replicate#88 (comment) Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This is causing some confusion in Docker behavior. See #88 (comment) Signed-off-by: Ben Firshman <ben@firshman.co.uk>
Following up from #88, this will keep Cog from leaving dangling Docker images that take lots of disk space. Signed-off-by: andreasjansson <andreas@replicate.ai>
Following up from #88, this will keep Cog from leaving dangling Docker images that take lots of disk space. Signed-off-by: andreasjansson <andreas@replicate.ai>
Images are built, tagged with registry and content-addressable tag,
pushed, re-tagged as :latest, and the original tag is removed.
This prevents Cog from using a ton of disk space, but builds are still
fast since the cached layers from the last build are still kept around
thanks to the :latest tag.
ref #80 #18
Signed-off-by: andreasjansson andreas@replicate.ai