Skip to content
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

[bug report] If container is committed to a image, after the image is removed, the snapshots for the image still exist. #2556

Closed
wangforthinker opened this issue Dec 13, 2018 · 2 comments · Fixed by #2635
Assignees
Labels
kind/bug This is bug report for project

Comments

@wangforthinker
Copy link
Contributor

wangforthinker commented Dec 13, 2018

Ⅰ. Issue Description

A image is built by container committed, when we remove the image, the snapshots for the image still exist.

Ⅱ. Describe what happened

As said above.

Ⅲ. Describe what you expected to happen

If a image is removed, the snapshots for the image should be cleaned. (Except the image is parent of committed containers).

Ⅳ. How to reproduce it (as minimally and precisely as possible)

  1. Create a container by a image, like registry.hub.docker.com/library/busybox:1.28.
[root@xxxx /home/allen]
#pouch ps -a
Name   ID       Status                Created        Image                                          Runtime
test   f63087   Exited (0) 1 minute   1 minute ago   registry.hub.docker.com/library/busybox:1.28   runc

[root@xxxx /home/allen]
#ls /home/pouch/containerd/root/io.containerd.snapshotter.v1.overlayfs/snapshots/
1  2

We can see snapshots 1 and 2.

  1. Commit the container to a new image ( committed_image:test ). We can know a snapshot (such as 4) is for the new image. We could get it from containerd snapshot dir( such as /home/pouch/containerd/root/io.containerd.snapshotter.v1.overlayfs/snapshots/ ).
[root@xxxx /home/allen]
#pouch commit test committed_image:test
a5931cafb3f2

[root@xxxx /home/allen]
#ls /home/pouch/containerd/root/io.containerd.snapshotter.v1.overlayfs/snapshots/
1  2  4
  1. Remove the new image committed_image:test. And the snapshot (a dir as /home/pouch/containerd/root/io.containerd.snapshotter.v1.overlayfs/snapshots/4) still exists.
[root@xxxx /home/allen]
#pouch rmi committed_image:test
committed_image:test

[root@xxxx /home/allen]
#ls /home/pouch/containerd/root/io.containerd.snapshotter.v1.overlayfs/snapshots/
1  2  4

Even though I remove all containers and images, the snapshot 4 is still existed.

[root@xxxx /home/allen]
#pouch ps -a
Name   ID   Status   Created   Image   Runtime

[root@xxxx /home/allen]
#pouch images
IMAGE ID   IMAGE NAME   SIZE

[root@xxxx /home/allen]
#ls /home/pouch/containerd/root/io.containerd.snapshotter.v1.overlayfs/snapshots/
1  4

Ⅴ. Anything else we need to know?

when a container is committed to a image, Pouch will new a snapshot for the diff content in container. When a snapshot is created, it sets a label "containerd.io/gc.root". A snapshot with the label will not be removed, Even though the snapshot is not referred. ( Related to https://github.com/alibaba/pouch/blob/master/ctrd/image_commit.go#L266)

Ⅵ. Environment:

#pouch version
GitCommit:       7acb407
GoVersion:       go1.9.1
KernelVersion:   4.9.93-010.ali3000.alios7.x86_64
Os:              linux
Version:         1.0.0
APIVersion:      1.24
Arch:            amd64
BuildTime:       2018-11-19T07:08:36+00:00
  • pouch version (use pouch version):
  • OS (e.g. from /etc/os-release):
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:
@pouchrobot pouchrobot added the kind/bug This is bug report for project label Dec 13, 2018
@wangforthinker wangforthinker changed the title [bug] If container is committed to a image, after the image is cleaned, the snapshots for the image still exist. [bug] If container is committed to a image, after the image is removed, the snapshots for the image still exist. Dec 13, 2018
@Ace-Tang
Copy link
Contributor

I will figure this out, these days are so busy

@fuweid fuweid pinned this issue Dec 19, 2018
@fuweid fuweid changed the title [bug] If container is committed to a image, after the image is removed, the snapshots for the image still exist. [bug report] If container is committed to a image, after the image is removed, the snapshots for the image still exist. Dec 27, 2018
@fuweid fuweid assigned fuweid and unassigned Ace-Tang Dec 29, 2018
@fuweid
Copy link
Contributor

fuweid commented Dec 29, 2018

I am working on this @Ace-Tang

Ace-Tang pushed a commit that referenced this issue Jan 2, 2019
For `containerd.io/gc.root` label means the content/snapshot cannot be
removed during gc. If we use it for snapshot, the snapshot cannot be
removed during removing image.

By default, we should add
`containerd.io/gc.ref.snapshot.{snapshot-name}` gc label to the image
config so that gc can remove the snapshot if user tries to remove the
image.

close #2556

Signed-off-by: Wei Fu <fuweid89@gmail.com>
@ZYecho ZYecho unpinned this issue Jan 4, 2019
Ace-Tang pushed a commit that referenced this issue Mar 12, 2019
For `containerd.io/gc.root` label means the content/snapshot cannot be
removed during gc. If we use it for snapshot, the snapshot cannot be
removed during removing image.

By default, we should add
`containerd.io/gc.ref.snapshot.{snapshot-name}` gc label to the image
config so that gc can remove the snapshot if user tries to remove the
image.

close #2556

Signed-off-by: Wei Fu <fuweid89@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug This is bug report for project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants