summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go36
1 files changed, 33 insertions, 3 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index d8187c609..2d12a90d1 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -634,6 +634,12 @@ func resetState(state *ContainerState) {
state.RestartPolicyMatch = false
state.RestartCount = 0
state.Checkpointed = false
+ state.Restored = false
+ state.CheckpointedTime = time.Time{}
+ state.RestoredTime = time.Time{}
+ state.CheckpointPath = ""
+ state.CheckpointLog = ""
+ state.RestoreLog = ""
}
// Refresh refreshes the container's state after a restart.
@@ -756,7 +762,7 @@ func (c *Container) export(path string) error {
if !c.state.Mounted {
containerMount, err := c.runtime.store.Mount(c.ID(), c.config.MountLabel)
if err != nil {
- return errors.Wrapf(err, "error mounting container %q", c.ID())
+ return errors.Wrapf(err, "mounting container %q", c.ID())
}
mountPoint = containerMount
defer func() {
@@ -1111,6 +1117,12 @@ func (c *Container) init(ctx context.Context, retainRetries bool) error {
}
c.state.Checkpointed = false
+ c.state.Restored = false
+ c.state.CheckpointedTime = time.Time{}
+ c.state.RestoredTime = time.Time{}
+ c.state.CheckpointPath = ""
+ c.state.CheckpointLog = ""
+ c.state.RestoreLog = ""
c.state.ExitCode = 0
c.state.Exited = false
c.state.State = define.ContainerStateCreated
@@ -1877,7 +1889,7 @@ func (c *Container) cleanupStorage() error {
return cleanupErr
}
-// Unmount the a container and free its resources
+// Unmount the container and free its resources
func (c *Container) cleanup(ctx context.Context) error {
var lastError error
@@ -1885,7 +1897,7 @@ func (c *Container) cleanup(ctx context.Context) error {
// Remove healthcheck unit/timer file if it execs
if c.config.HealthCheckConfig != nil {
- if err := c.removeTimer(); err != nil {
+ if err := c.removeTransientFiles(ctx); err != nil {
logrus.Errorf("Removing timer for container %s healthcheck: %v", c.ID(), err)
}
}
@@ -2206,6 +2218,24 @@ func (c *Container) canWithPrevious() error {
// prepareCheckpointExport writes the config and spec to
// JSON files for later export
func (c *Container) prepareCheckpointExport() error {
+ networks, err := c.networks()
+ if err != nil {
+ return err
+ }
+ // make sure to exclude the short ID alias since the container gets a new ID on restore
+ for net, opts := range networks {
+ newAliases := make([]string, 0, len(opts.Aliases))
+ for _, alias := range opts.Aliases {
+ if alias != c.config.ID[:12] {
+ newAliases = append(newAliases, alias)
+ }
+ }
+ opts.Aliases = newAliases
+ networks[net] = opts
+ }
+
+ // add the networks from the db to the config so that the exported checkpoint still stores all current networks
+ c.config.Networks = networks
// save live config
if _, err := metadata.WriteJSONFile(c.config, c.bundlePath(), metadata.ConfigDumpFile); err != nil {
return err