aboutsummaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-11-06 10:39:16 +0100
committerGitHub <noreply@github.com>2021-11-06 10:39:16 +0100
commitabbd6c167e8163a711680db80137a0731e06e564 (patch)
treec11c98dc0eeac187c62b74443ba98c5dcb0961f0 /libpod/container_internal.go
parent6805befec2ca9b9a816b1efda0bf43a67cee09a7 (diff)
parent0136a66a83d027049da6338f8ce6dfa8052c8ca3 (diff)
downloadpodman-abbd6c167e8163a711680db80137a0731e06e564.tar.gz
podman-abbd6c167e8163a711680db80137a0731e06e564.tar.bz2
podman-abbd6c167e8163a711680db80137a0731e06e564.zip
Merge pull request #11890 from Luap99/ports
libpod: deduplicate ports in db
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index b9805faa3..19b48e14b 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -667,6 +667,19 @@ func (c *Container) refresh() error {
c.state.NetworkStatus = nil
c.state.NetworkStatusOld = nil
+ // Rewrite the config if necessary.
+ // Podman 4.0 uses a new port format in the config.
+ // getContainerConfigFromDB() already converted the old ports to the new one
+ // but it did not write the config to the db back for performance reasons.
+ // If a rewrite must happen the config.rewrite field is set to true.
+ if c.config.rewrite {
+ // SafeRewriteContainerConfig must be used with care. Make sure to not change config fields by accident.
+ if err := c.runtime.state.SafeRewriteContainerConfig(c, "", "", c.config); err != nil {
+ return errors.Wrapf(err, "failed to rewrite the config for container %s", c.config.ID)
+ }
+ c.config.rewrite = false
+ }
+
if err := c.save(); err != nil {
return errors.Wrapf(err, "error refreshing state for container %s", c.ID())
}