-
Notifications
You must be signed in to change notification settings - Fork 616
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
non-ECS image cleanup: cleanup dangling images #2023
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changes lgtm. i wonder if we can do something to make that exclusion list handling logic a little clearer, but yea i know it was already before your changes.
oh also this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left couple of NIT. 🚢
just a general question: |
agent/engine/docker_image_manager.go
Outdated
seelog.Infof("Removing non-ECS Image: %s", kv.ImageName) | ||
err := imageManager.client.RemoveImage(ctx, kv.ImageName, dockerclient.RemoveImageTimeout) | ||
seelog.Debugf("Removing non-ECS Image: %s (Tags: %s)", image.ImageID, image.RepoTags) | ||
err := imageManager.client.RemoveImage(ctx, image.ImageID, dockerclient.RemoveImageTimeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has the case been tested where there can be two images with same image ID, but different names?
Does this remove both the images?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They should both be removed, though I haven't tested this case explicitly. I can add a unit test for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please test manually once. on a quick testing, it does not remove the image
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest d131e0fa2585 2 weeks ago 102MB
ubuntu mirror d131e0fa2585 2 weeks ago 102MB
$ docker rmi d131e0fa2585
Error response from daemon: conflict: unable to delete d131e0fa2585 (must be forced) - image is referenced in multiple repositories
$ docker rmi ubuntu:mirror
Untagged: ubuntu:mirror
$ docker rmi d131e0fa2585
Untagged: ubuntu:latest
Untagged: ubuntu@sha256:70fc21e832af32eeec9b0161a805c08f6dddf64d341748379de9a527c01b6ca1
Deleted: sha256:d131e0fa2585a7efbfb187f70d648aa50e251d9d3b7031edf4730ca6154e221e
Deleted: sha256:c59a62c2bba8db73ca8b8847baa7fa77e4d573f38e57d69592a9716f9fa075c4
Deleted: sha256:a4eb6208f601c2f32e043972b9fa8e813767aef2e60676e91796cabf8a0afdc4
Deleted: sha256:a14c708b62677e8acfb75ac873147e71dd26aa7bf75a8b63b3408e0826b174dc
Deleted: sha256:604cbde1a4c8fee1b102f8b64d4f41e62d770b5f8a6b06fb809cfd873a2643c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I've added a change now to detect if an ImageID has multiple tags. If there are multiple tags on an ImageID, the tags will be removed first before removing the image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, do we have unit tests for this case as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change, the ImageID will always be used for both cleanup and inspection of images. |
2da5c60
to
a21a69c
Compare
2a0795e
to
43c488e
Compare
agent/engine/docker_image_manager.go
Outdated
seelog.Infof("Removing non-ECS Image: %s", kv.ImageName) | ||
err := imageManager.client.RemoveImage(ctx, kv.ImageName, dockerclient.RemoveImageTimeout) | ||
seelog.Debugf("Removing non-ECS Image: %s (Tags: %s)", image.ImageID, image.RepoTags) | ||
err := imageManager.client.RemoveImage(ctx, image.ImageID, dockerclient.RemoveImageTimeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, do we have unit tests for this case as well?
7dfcc8d
to
0d0c548
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please edit the commit message as well to mention this change is only for non-ECS images?
yes, done 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Use ImageID to cleanup images rather than tag name, to guarantee that we are passing a legitimate identifier to InspectImage and RemoveImage. closes aws#2017
Use ImageID to cleanup images rather than tag name, to guarantee that we
are passing a legitimate identifier to InspectImage and RemoveImage.
closes #2017
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.