containerd integration: Implement ImageDelete for containerd#43820
containerd integration: Implement ImageDelete for containerd#43820cpuguy83 merged 1 commit intomoby:masterfrom
Conversation
3473542 to
224b540
Compare
daemon/containerd/image_delete.go
Outdated
| // FIXME(thaJeztah): implement ImageDelete "force" | ||
| // FIXME(thaJeztah): implement ImageDelete "prune" |
There was a problem hiding this comment.
Let me create tracking issues for these
There was a problem hiding this comment.
daemon/containerd/image_delete.go
Outdated
| panic("not implemented") | ||
| func (i *ImageService) ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]types.ImageDeleteResponseItem, error) { | ||
| // TODO(thaJeztah): implement ImageDelete "force" options; see https://github.com/moby/moby/issues/43850 | ||
| // TODO(thaJeztah): implement ImageDelete "prune" options; see https://github.com/moby/moby/issues/43849 |
There was a problem hiding this comment.
Per discussion in the maintainers meeting; we need to add more tracking issues for; partial IDs etc. (some of that logic is implemented in GetImage() as part of #43818)
daemon/containerd/image_delete.go
Outdated
| // TODO(thaJeztah): implement ImageDelete "force" options; see https://github.com/moby/moby/issues/43850 | ||
| // TODO(thaJeztah): implement ImageDelete "prune" options; see https://github.com/moby/moby/issues/43849 | ||
|
|
||
| records := []types.ImageDeleteResponseItem{} |
There was a problem hiding this comment.
There was a problem hiding this comment.
Hm, yeah, I don't always agree with that rule (sometimes it's really more convenient to initialise it if later on we need to (edit: ignore me on that one), and append()make(...) is a bit cumbersome (or sometimes overdoing it).
That said; it looks like (at least currently) it'll only ever create a single instance, so I don't think we need this variable at all; we can just return []types.ImageDeleteResponseItem{}{d} at the end of the function.
There was a problem hiding this comment.
sometimes it's really more convenient to initialise it if later on we need to
append()
Hmm? append() works on nil slices, same as non-nil but empty slices. You might be thinking of maps, where assigning to a nil map panics.
There was a problem hiding this comment.
Yes, I just edited, indeed had maps in mind 🙈
daemon/containerd/image_delete.go
Outdated
| ref := reference.TagNameOnly(parsedRef) | ||
|
|
||
| if err := i.client.ImageService().Delete(ctx, ref.String(), images.SynchronousDelete()); err != nil { | ||
| return []types.ImageDeleteResponseItem{}, err |
There was a problem hiding this comment.
How come an empty slice is returned here but the error-return for ParseNotmalizedNamed (line 52) returns nil?
There was a problem hiding this comment.
Good catch; at a glance, I think can be just nil as well, unless there's some expectation somewhere (nil vs nil type)? Overall the returned value shouldn't be used if there's an error.
Let me have a look at that.
| for _, ref := range refs { | ||
| imgDel, err := i.ImageDelete(ref.String(), false, true) | ||
| imgDel, err := i.ImageDelete(ctx, ref.String(), false, true) | ||
| if imageDeleteFailed(ref.String(), err) { |
There was a problem hiding this comment.
Looks like imageDeleteFailed() needs to be updated so it doesn't log a spurious warning when the context is canceled.
daemon/images/image_prune.go
Outdated
| case err == nil: | ||
| return false | ||
| case errdefs.IsConflict(err): | ||
| case errdefs.IsConflict(err), errors.Is(err, context.Canceled): |
There was a problem hiding this comment.
| case errdefs.IsConflict(err), errors.Is(err, context.Canceled): | |
| case errdefs.IsConflict(err), errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded): |
Annoyingly, you need to enumerate all the possible context errors.
There was a problem hiding this comment.
LOL; I actually had the DeadlineExceeded, and started to think if that one would be one to actually log, so removed it; let me add it back 😂
There was a problem hiding this comment.
And it's back (it was literally CMD+Z - last edit I made 😂 )
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
|
@AkihiroSuda @tonistiigi PTAL |
containerd integration: Implement ImageDelete for containerd Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
depends on add support for image inspect with containerd-integration #43818- What I did
Implemented image deletion for containerd