If image pull fails of context canceled, image layer will perform a
rollback operation. When image layer is released, the diff folder of layer
will be removed first, and then the digest folder will be removed.
If the diff folder fails to be removed, such as operation not permitted or
interrupted by others, both the digest folder and diff folder will remain
on the disk, this will cause image not be complete and not repairable.
So we should remove the digest folder first for image layers rollback
and ensure image can be re-pulled completely.
kill process directly should check whether exit file is exist already,
for avoid kill the new process which reused this pid
Signed-off-by: liuzekun <liuzekun@huawei.com>
containerd has two objects with regard to containers.
This is a "container" object which is metadata and a "task" which is
manging the actual runtime state.
When docker starts a container, it creates both the container metadata
and the task at the same time. So when a container exists, docker deletes
both of these objects as well.
This ensures that if, on start, when we go to create the container metadata object
in containerd, if there is an error due to a name conflict taht we go
ahead and clean that up and try again.
backport from upstream: https://github.com/moby/moby/pull/38364
Signed-off-by: Grooooot <isula@huawei.com>