From 9dabb16e6541a1b7bbb1c5a27a91e08863a5b491 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 9 May 2019 19:06:46 +0200 Subject: system: migrate stops the pause process Signed-off-by: Giuseppe Scrivano --- cmd/podman/main_local.go | 1 + libpod/runtime_migrate.go | 35 ++++++++++++++++++++++++++++++++++- libpod/runtime_migrate_unsupported.go | 11 +++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 libpod/runtime_migrate_unsupported.go diff --git a/cmd/podman/main_local.go b/cmd/podman/main_local.go index 2024d4b31..5af05a11e 100644 --- a/cmd/podman/main_local.go +++ b/cmd/podman/main_local.go @@ -132,6 +132,7 @@ func setupRootless(cmd *cobra.Command, args []string) error { became, ret, err := rootless.JoinUserAndMountNS(uint(pausePid), "") if err != nil { logrus.Errorf("cannot join pause process pid %d. You may need to remove %s and stop all containers", pausePid, pausePidPath) + logrus.Errorf("you can use `system migrate` to recreate the pause process") logrus.Errorf(err.Error()) os.Exit(1) } diff --git a/libpod/runtime_migrate.go b/libpod/runtime_migrate.go index 116885d3a..e32e6edf6 100644 --- a/libpod/runtime_migrate.go +++ b/libpod/runtime_migrate.go @@ -1,14 +1,47 @@ +// +build linux + package libpod import ( "context" "fmt" + "io/ioutil" + "os" "path/filepath" + "strconv" + "syscall" + "github.com/containers/libpod/pkg/rootless" + "github.com/containers/libpod/pkg/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) +func stopPauseProcess() error { + if rootless.IsRootless() { + pausePidPath, err := util.GetRootlessPauseProcessPidPath() + if err != nil { + return errors.Wrapf(err, "could not get pause process pid file path") + } + data, err := ioutil.ReadFile(pausePidPath) + if err != nil { + if os.IsNotExist(err) { + return nil + } + return errors.Wrapf(err, "cannot read pause process pid file %s", pausePidPath) + } + pausePid, err := strconv.Atoi(string(data)) + if err != nil { + return errors.Wrapf(err, "cannot parse pause pid file %s", pausePidPath) + } + if err := os.Remove(pausePidPath); err != nil { + return errors.Wrapf(err, "cannot delete pause pid file %s", pausePidPath) + } + syscall.Kill(pausePid, syscall.SIGKILL) + } + return nil +} + func (r *Runtime) migrate(ctx context.Context) error { runningContainers, err := r.GetRunningContainers() if err != nil { @@ -39,5 +72,5 @@ func (r *Runtime) migrate(ctx context.Context) error { } } - return nil + return stopPauseProcess() } diff --git a/libpod/runtime_migrate_unsupported.go b/libpod/runtime_migrate_unsupported.go new file mode 100644 index 000000000..1a9e46fdc --- /dev/null +++ b/libpod/runtime_migrate_unsupported.go @@ -0,0 +1,11 @@ +// +build !linux + +package libpod + +import ( + "context" +) + +func (r *Runtime) migrate(ctx context.Context) error { + return nil +} -- cgit v1.2.3-54-g00ecf