mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Track if a container is restored from an exported checkpoint
Instead of only tracking that a container is restored from a checkpoint locally in runtime_ctr.go this adds a flag to the Container structure. Upcoming patches to correctly label the root file-system mount-point need also to know if a container is restored from a checkpoint. Instead of passing a parameter around a lot of functions, this adds that information to the Container structure. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
@ -157,6 +157,9 @@ type Container struct {
|
|||||||
// being checkpointed. If requestedIP is set it will be used instead
|
// being checkpointed. If requestedIP is set it will be used instead
|
||||||
// of config.StaticIP.
|
// of config.StaticIP.
|
||||||
requestedIP net.IP
|
requestedIP net.IP
|
||||||
|
|
||||||
|
// This is true if a container is restored from a checkpoint.
|
||||||
|
restoreFromCheckpoint bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// ContainerState contains the current state of the container
|
// ContainerState contains the current state of the container
|
||||||
|
@ -55,7 +55,7 @@ func (r *Runtime) RestoreContainer(ctx context.Context, rSpec *spec.Spec, config
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error initializing container variables")
|
return nil, errors.Wrapf(err, "error initializing container variables")
|
||||||
}
|
}
|
||||||
return r.setupContainer(ctx, ctr, true)
|
return r.setupContainer(ctx, ctr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) initContainerVariables(rSpec *spec.Spec, config *ContainerConfig) (c *Container, err error) {
|
func (r *Runtime) initContainerVariables(rSpec *spec.Spec, config *ContainerConfig) (c *Container, err error) {
|
||||||
@ -71,6 +71,7 @@ func (r *Runtime) initContainerVariables(rSpec *spec.Spec, config *ContainerConf
|
|||||||
ctr.config.ShmSize = DefaultShmSize
|
ctr.config.ShmSize = DefaultShmSize
|
||||||
} else {
|
} else {
|
||||||
// This is a restore from an imported checkpoint
|
// This is a restore from an imported checkpoint
|
||||||
|
ctr.restoreFromCheckpoint = true
|
||||||
if err := JSONDeepCopy(config, ctr.config); err != nil {
|
if err := JSONDeepCopy(config, ctr.config); err != nil {
|
||||||
return nil, errors.Wrapf(err, "error copying container config for restore")
|
return nil, errors.Wrapf(err, "error copying container config for restore")
|
||||||
}
|
}
|
||||||
@ -122,10 +123,10 @@ func (r *Runtime) newContainer(ctx context.Context, rSpec *spec.Spec, options ..
|
|||||||
return nil, errors.Wrapf(err, "error running container create option")
|
return nil, errors.Wrapf(err, "error running container create option")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return r.setupContainer(ctx, ctr, false)
|
return r.setupContainer(ctx, ctr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Runtime) setupContainer(ctx context.Context, ctr *Container, restore bool) (c *Container, err error) {
|
func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (c *Container, err error) {
|
||||||
// Allocate a lock for the container
|
// Allocate a lock for the container
|
||||||
lock, err := r.lockManager.AllocateLock()
|
lock, err := r.lockManager.AllocateLock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -204,7 +205,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container, restore bo
|
|||||||
return nil, errors.Wrapf(ErrInvalidArg, "unsupported CGroup manager: %s - cannot validate cgroup parent", r.config.CgroupManager)
|
return nil, errors.Wrapf(ErrInvalidArg, "unsupported CGroup manager: %s - cannot validate cgroup parent", r.config.CgroupManager)
|
||||||
}
|
}
|
||||||
|
|
||||||
if restore {
|
if ctr.restoreFromCheckpoint {
|
||||||
// Remove information about bind mount
|
// Remove information about bind mount
|
||||||
// for new container from imported checkpoint
|
// for new container from imported checkpoint
|
||||||
g := generate.Generator{Config: ctr.config.Spec}
|
g := generate.Generator{Config: ctr.config.Spec}
|
||||||
|
Reference in New Issue
Block a user