-
Notifications
You must be signed in to change notification settings - Fork 185
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
Add ig image remove
command
#2162
Conversation
Thanks for looking into this, I have been doing |
It is named |
9f17a51
to
a69a378
Compare
I was able to come up with some code to remove the whole graph based on upstream work: $ sudo ls -1 /var/lib/ig/oci-store/blobs/sha256 | wc -l francis/rmi % u+2-2
12
$ sudo -E ./ig image list francis/rmi % u+2-2
INFO[0000] Experimental features enabled
REPOSITORY TAG DIGEST
ghcr.io/inspektor-gadget/gadget/trace_exec latest 30d2db19d0af
ghcr.io/inspektor-gadget/gadget/trace_open latest 842e69c79177
$ sudo -E ./ig image remove ghcr.io/inspektor-gadget/gadget/trace_open
INFO[0000] Experimental features enabled
$ sudo -E ./ig image remove ghcr.io/inspektor-gadget/gadget/trace_exec
INFO[0000] Experimental features enabled
$ sudo -E ./ig image list francis/rmi % u+2-2
INFO[0000] Experimental features enabled
REPOSITORY TAG DIGEST
$ sudo ls -1 /var/lib/ig/oci-store/blobs/sha256 | wc -l francis/rmi % u+2-2
0 I will remove the |
a69a378
to
35b058d
Compare
This is helpful for #2171 as well. Let me test it!
Does that mean we can merge it or we still have to wait till upstream PRs are merged? |
It depends. |
35b058d
to
0496997
Compare
477d0dd
to
cb0aad7
Compare
There was no activity since 2 weeks on the upstream PR. Should we merge this now? |
cb0aad7
to
31caf69
Compare
I updated the commit to use latest modifications brought to this PR. |
e9533dd
to
d46f937
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.
I think there is something off, if there are two tags pointing to the same digest, deleting one of them causes the other one to be removed:
# there are not images at the beginning
$ sudo -E ig image list
INFO[0000] Experimental features enabled
REPOSITORY TAG DIGEST
# build an image
$ sudo -E ig image build -t mygadget . --local
INFO[0000] Experimental features enabled
Successfully built docker.io/library/mygadget:latest@sha256:0b34e37d953f64b800ccbb547481e47f5f517cf9bf0aa290ab4f4760c9bb92fa
$ sudo -E ig image list
INFO[0000] Experimental features enabled
REPOSITORY TAG DIGEST
docker.io/library/mygadget latest 0b34e37d953f
# tag an image with the above
$ sudo -E ig image tag mygadget foo
INFO[0000] Experimental features enabled
Successfully tagged with docker.io/library/foo:latest@sha256:0b34e37d953f64b800ccbb547481e47f5f517cf9bf0aa290ab4f4760c9bb92fa
$ sudo -E ig image list
INFO[0000] Experimental features enabled
REPOSITORY TAG DIGEST
docker.io/library/foo latest 0b34e37d953f
docker.io/library/mygadget latest 0b34e37d953f
# remove the first image
$ sudo -E ig image remove mygadget:latest
INFO[0000] Experimental features enabled
# second one is gone as well
$ sudo -E ig image list
INFO[0000] Experimental features enabled
REPOSITORY TAG DIGEST
514b831
to
ae248e3
Compare
I am marking this PR as |
@eiffel-fl have you seem my comment in #2162 (review)? I'm getting the same behavior with oras-project/oras-go#645. |
I am not Lucky Luke, so I do not code faster than my shadow. |
ae248e3
to
ad906d8
Compare
oras-project/oras-go#647 solves the above problem. |
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.
I tested and it works fine now.
I'm wondering if we should follow an garbage-collection approach for this too as suggested in oras-project/oras-go#645 (comment)?, deleting an image could be something like
untag()
collectGarbage()
Would you mind adding an entry to https://github.com/inspektor-gadget/inspektor-gadget/blob/main/docs/images.md?
I'm approving it now as does its job. It's up to you to merge or wait for the upstream PRs to be ready.
We're missing the tests for this (and other commands), we can do them in #2171.
While the comment from
I will first wait to get some feedback upstream before merging this one.
|
ad906d8
to
f35f499
Compare
814242a
to
7ad1bd4
Compare
7ad1bd4
to
cc26506
Compare
This function is the basics of ListGadgetImages(). Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
cc26506
to
141e0a9
Compare
As oras-project/oras-go#647 was merged, we can now use upstream at a specific commit. We will remove the |
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.
Besides two minor comments, LGTM!
This permits removing ig image built. Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
141e0a9
to
75f4e3a
Compare
Thank you for the reviews! |
Hi.
This PR adds
ig image remove
command.It depends on work in progress in oras-project/oras-go#614.
Best regards.