mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
05cc737f54
- Refactor generic and path based cleanup functions into a single function. - Include aufs and zfs mounts in the mounts cleanup. - Containers that receive exit event on restore don't require manual cleanup. - Make missing sandbox id message a warning because currently sandboxes are always cleared on startup. libnetwork#975 - Don't unmount volumes for containers that don't have base path. Shouldn't be needed after #21372 Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
41 lines
1 KiB
Go
41 lines
1 KiB
Go
// +build !experimental
|
|
|
|
package libcontainerd
|
|
|
|
import (
|
|
"syscall"
|
|
"time"
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
)
|
|
|
|
func (clnt *client) Restore(containerID string, options ...CreateOption) error {
|
|
w := clnt.getOrCreateExitNotifier(containerID)
|
|
defer w.close()
|
|
cont, err := clnt.getContainerdContainer(containerID)
|
|
if err == nil && cont.Status != "stopped" {
|
|
clnt.lock(cont.Id)
|
|
container := clnt.newContainer(cont.BundlePath)
|
|
container.systemPid = systemPid(cont)
|
|
clnt.appendContainer(container)
|
|
clnt.unlock(cont.Id)
|
|
|
|
if err := clnt.Signal(containerID, int(syscall.SIGTERM)); err != nil {
|
|
logrus.Errorf("error sending sigterm to %v: %v", containerID, err)
|
|
}
|
|
select {
|
|
case <-time.After(10 * time.Second):
|
|
if err := clnt.Signal(containerID, int(syscall.SIGKILL)); err != nil {
|
|
logrus.Errorf("error sending sigkill to %v: %v", containerID, err)
|
|
}
|
|
select {
|
|
case <-time.After(2 * time.Second):
|
|
case <-w.wait():
|
|
return nil
|
|
}
|
|
case <-w.wait():
|
|
return nil
|
|
}
|
|
}
|
|
return clnt.setExited(containerID)
|
|
}
|