diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-10-11 19:56:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-11 19:56:13 +0200 |
commit | cee6478f9e5e5cdbfe3df8f4894e416e4c5926e4 (patch) | |
tree | 2936df1d29e417d4ab4e7a22802ed75f31591acc /libpod/runtime_migrate.go | |
parent | eb6ca054fc93e5f863581e72923cb1e80fc5ab88 (diff) | |
parent | feba94eb95f93fd571efff039cb7d7cdb5139169 (diff) | |
download | podman-cee6478f9e5e5cdbfe3df8f4894e416e4c5926e4.tar.gz podman-cee6478f9e5e5cdbfe3df8f4894e416e4c5926e4.tar.bz2 podman-cee6478f9e5e5cdbfe3df8f4894e416e4c5926e4.zip |
Merge pull request #4221 from mheon/reset_runtime
Migrate can move containers to a user-defined runtime
Diffstat (limited to 'libpod/runtime_migrate.go')
-rw-r--r-- | libpod/runtime_migrate.go | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/libpod/runtime_migrate.go b/libpod/runtime_migrate.go index c363991e6..d85652232 100644 --- a/libpod/runtime_migrate.go +++ b/libpod/runtime_migrate.go @@ -5,14 +5,15 @@ package libpod import ( "context" "fmt" - "github.com/containers/libpod/pkg/util" "io/ioutil" "os" "path/filepath" "strconv" "syscall" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/pkg/rootless" + "github.com/containers/libpod/pkg/util" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -63,11 +64,34 @@ func (r *Runtime) migrate(ctx context.Context) error { } } + // Did the user request a new runtime? + runtimeChangeRequested := r.migrateRuntime != "" + requestedRuntime, runtimeExists := r.ociRuntimes[r.migrateRuntime] + if !runtimeExists && runtimeChangeRequested { + return errors.Wrapf(define.ErrInvalidArg, "change to runtime %q requested but no such runtime is defined", r.migrateRuntime) + } + for _, ctr := range allCtrs { + needsWrite := false + + // Reset pause process location 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") + needsWrite = true + } + + // Reset runtime + if runtimeChangeRequested { + logrus.Infof("Resetting container %s runtime to runtime %s", ctr.ID(), r.migrateRuntime) + ctr.config.OCIRuntime = r.migrateRuntime + ctr.ociRuntime = requestedRuntime + + needsWrite = true + } + + if needsWrite { if err := r.state.RewriteContainerConfig(ctr, ctr.config); err != nil { return errors.Wrapf(err, "error rewriting config for container %s", ctr.ID()) } |