mirror of https://github.com/containers/podman.git
restore: fix missing network setup
The restore code path never called completeNetworkSetup() and this means that hosts/resolv.conf files were not populated. This fix is simply to call this function. There is a big catch here. Technically this is suposed to be called after the container is created but before it is started. There is no such thing for restore, the container runs right away. This means that if we do the call afterwards there is a short interval where the file is still empty. Thus I decided to call it before which makes it not working with PostConfigureNetNS (userns) but as this does not work anyway today so I don't see it as problem. Fixes #22901 Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
parent
32d4b1644d
commit
def182d396
|
@ -1725,6 +1725,15 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// setup hosts/resolv.conf files
|
||||||
|
// Note this should normally be called after the container is created in the runtime but before it is started.
|
||||||
|
// However restore starts the container right away. This means that if we do the call afterwards there is a
|
||||||
|
// short interval where the file is still empty. Thus I decided to call it before which makes it not working
|
||||||
|
// with PostConfigureNetNS (userns) but as this does not work anyway today so I don't see it as problem.
|
||||||
|
if err := c.completeNetworkSetup(); err != nil {
|
||||||
|
return nil, 0, fmt.Errorf("complete network setup: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
runtimeRestoreDuration, err = c.ociRuntime.CreateContainer(c, &options)
|
runtimeRestoreDuration, err = c.ociRuntime.CreateContainer(c, &options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
|
|
|
@ -247,6 +247,9 @@ function teardown() {
|
||||||
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
|
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
|
||||||
mac1="$output"
|
mac1="$output"
|
||||||
|
|
||||||
|
run_podman exec $cid cat /etc/hosts /etc/resolv.conf
|
||||||
|
pre_hosts_resolv_conf_output="$output"
|
||||||
|
|
||||||
run_podman container checkpoint $cid
|
run_podman container checkpoint $cid
|
||||||
is "$output" "$cid"
|
is "$output" "$cid"
|
||||||
run_podman container restore $cid
|
run_podman container restore $cid
|
||||||
|
@ -258,6 +261,10 @@ function teardown() {
|
||||||
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
|
run_podman inspect $cid --format "{{(index .NetworkSettings.Networks \"$netname\").MacAddress}}"
|
||||||
mac2="$output"
|
mac2="$output"
|
||||||
|
|
||||||
|
# Make sure hosts and resolv.conf are the same after restore (#22901)
|
||||||
|
run_podman exec $cid cat /etc/hosts /etc/resolv.conf
|
||||||
|
assert "$output" == "$pre_hosts_resolv_conf_output" "hosts/resolv.conf must be the same after checkpoint"
|
||||||
|
|
||||||
assert "$ip2" == "$ip1" "ip after restore should match"
|
assert "$ip2" == "$ip1" "ip after restore should match"
|
||||||
assert "$mac2" == "$mac1" "mac after restore should match"
|
assert "$mac2" == "$mac1" "mac after restore should match"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue