restore: fix container restore into pod
Currently, when Podman restores a container into a Pod, it always fails
with the following error:
Error: cannot add container f96670b26e53e70f7f451191ea39a093c940c6c48b47218aeeef1396cb860042 to pod h2-pod: no such pod
This error occurs because r.state.Pod() is called in setupContainer()
with the Pod name instead of ID. This patch fixes this problem by
setting ctrConfig.Pod to pod.ID().
Reported-by: Stanislav Kosorin <stanokosorin4@gmail.com>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
parent
b8d95a5893
commit
7dc288dbed
|
|
@ -102,17 +102,18 @@ func CRImportCheckpoint(ctx context.Context, runtime *libpod.Runtime, restoreOpt
|
||||||
if !crutils.CRRuntimeSupportsPodCheckpointRestore(runtime.GetOCIRuntimePath()) {
|
if !crutils.CRRuntimeSupportsPodCheckpointRestore(runtime.GetOCIRuntimePath()) {
|
||||||
return nil, fmt.Errorf("runtime %s does not support pod restore", runtime.GetOCIRuntimePath())
|
return nil, fmt.Errorf("runtime %s does not support pod restore", runtime.GetOCIRuntimePath())
|
||||||
}
|
}
|
||||||
// Restoring into an existing Pod
|
|
||||||
ctrConfig.Pod = restoreOptions.Pod
|
|
||||||
|
|
||||||
// According to podman pod create a pod can share the following namespaces:
|
// According to podman pod create a pod can share the following namespaces:
|
||||||
// cgroup, ipc, net, pid, uts
|
// cgroup, ipc, net, pid, uts
|
||||||
// Let's make sure we are restoring into a pod with the same shared namespaces.
|
// Let's make sure we are restoring into a pod with the same shared namespaces.
|
||||||
pod, err := runtime.LookupPod(ctrConfig.Pod)
|
pod, err := runtime.LookupPod(restoreOptions.Pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("pod %q cannot be retrieved: %w", ctrConfig.Pod, err)
|
return nil, fmt.Errorf("pod %q cannot be retrieved: %w", ctrConfig.Pod, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restoring into an existing Pod
|
||||||
|
ctrConfig.Pod = pod.ID()
|
||||||
|
|
||||||
infraContainer, err := pod.InfraContainer()
|
infraContainer, err := pod.InfraContainer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot retrieve infra container from pod %q: %w", ctrConfig.Pod, err)
|
return nil, fmt.Errorf("cannot retrieve infra container from pod %q: %w", ctrConfig.Pod, err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue