summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorAdrian Reber <areber@redhat.com>2019-08-01 17:23:02 +0000
committerAdrian Reber <areber@redhat.com>2019-08-02 10:10:54 +0200
commitc23b92b4090d1aab96ddde2c897db8869eb6261e (patch)
tree177a3b86284af7c0bfcf260e687d3c32ba955304 /libpod
parentafb493ae9b1cc98db1f6d9a211b561bb245692de (diff)
downloadpodman-c23b92b4090d1aab96ddde2c897db8869eb6261e.tar.gz
podman-c23b92b4090d1aab96ddde2c897db8869eb6261e.tar.bz2
podman-c23b92b4090d1aab96ddde2c897db8869eb6261e.zip
restore: added --ignore-static-ip option
If a container is restored multiple times from an exported checkpoint with the help of '--import --name', the restore will fail if during 'podman run' a static container IP was set with '--ip'. The user can tell the restore process to ignore the static IP with '--ignore-static-ip'. Signed-off-by: Adrian Reber <areber@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_api.go5
-rw-r--r--libpod/container_internal_linux.go10
2 files changed, 14 insertions, 1 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index cd020e429..5ed474a98 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -773,6 +773,11 @@ type ContainerCheckpointOptions struct {
// IgnoreRootfs tells the API to not export changes to
// the container's root file-system (or to not import)
IgnoreRootfs bool
+ // IgnoreStaticIP tells the API to ignore the IP set
+ // during 'podman run' with '--ip'. This is especially
+ // important to be able to restore a container multiple
+ // times with '--import --name'.
+ IgnoreStaticIP bool
}
// Checkpoint checkpoints a container
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 6dbd53fbf..047b73d65 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -743,6 +743,14 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
return err
}
+ // If a container is restored multiple times from an exported checkpoint with
+ // the help of '--import --name', the restore will fail if during 'podman run'
+ // a static container IP was set with '--ip'. The user can tell the restore
+ // process to ignore the static IP with '--ignore-static-ip'
+ if options.IgnoreStaticIP {
+ c.config.StaticIP = nil
+ }
+
// Read network configuration from checkpoint
// Currently only one interface with one IP is supported.
networkStatusFile, err := os.Open(filepath.Join(c.bundlePath(), "network.status"))
@@ -752,7 +760,7 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
// TODO: This implicit restoring with or without IP depending on an
// unrelated restore parameter (--name) does not seem like the
// best solution.
- if err == nil && options.Name == "" {
+ if err == nil && options.Name == "" && !options.IgnoreStaticIP {
// The file with the network.status does exist. Let's restore the
// container with the same IP address as during checkpointing.
defer networkStatusFile.Close()