summaryrefslogtreecommitdiff
path: root/libpod/runtime_migrate.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/runtime_migrate.go')
-rw-r--r--libpod/runtime_migrate.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/libpod/runtime_migrate.go b/libpod/runtime_migrate.go
new file mode 100644
index 000000000..a084df289
--- /dev/null
+++ b/libpod/runtime_migrate.go
@@ -0,0 +1,47 @@
+package libpod
+
+import (
+ "path/filepath"
+
+ "github.com/pkg/errors"
+ "github.com/sirupsen/logrus"
+)
+
+func (r *Runtime) migrate() error {
+ runningContainers, err := r.GetRunningContainers()
+ if err != nil {
+ return err
+ }
+
+ allCtrs, err := r.state.AllContainers()
+ if err != nil {
+ return err
+ }
+
+ logrus.Infof("stopping all containers")
+ for _, ctr := range runningContainers {
+ logrus.Infof("stopping %s", ctr.ID())
+ if err := ctr.Stop(); err != nil {
+ return errors.Wrapf(err, "cannot stop container %s", ctr.ID())
+ }
+ }
+
+ for _, ctr := range allCtrs {
+ oldLocation := filepath.Join(ctr.state.RunDir, "conmon.pid")
+ if ctr.config.ConmonPidFile == oldLocation {
+ logrus.Infof("changing conmon PID file for %s", ctr.ID())
+ ctr.config.ConmonPidFile = filepath.Join(ctr.config.StaticDir, "conmon.pid")
+ if err := r.state.RewriteContainerConfig(ctr, ctr.config); err != nil {
+ return errors.Wrapf(err, "error rewriting config for container %s", ctr.ID())
+ }
+ }
+ }
+
+ for _, ctr := range runningContainers {
+ if err := ctr.Start(r.ctx, true); err != nil {
+ logrus.Errorf("error restarting container %s", ctr.ID())
+ }
+ }
+
+ return nil
+}