summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/abi
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2022-03-22 11:04:46 +0100
committerGiuseppe Scrivano <gscrivan@redhat.com>2022-03-24 14:24:50 +0100
commitb469bf5c05ce05e7b77852fa686f1e26dd59ec3e (patch)
tree5f4f087eb631acc3372ebb848d5b0ef4c4595807 /pkg/domain/infra/abi
parent809f82bdbd441d602e584b1c9c2b5597a739b10e (diff)
downloadpodman-b469bf5c05ce05e7b77852fa686f1e26dd59ec3e.tar.gz
podman-b469bf5c05ce05e7b77852fa686f1e26dd59ec3e.tar.bz2
podman-b469bf5c05ce05e7b77852fa686f1e26dd59ec3e.zip
container: allow clone to an existing pod
Closes: https://github.com/containers/podman/issues/3979 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi')
-rw-r--r--pkg/domain/infra/abi/containers.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index 1986228a6..f45bdeba5 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -1496,6 +1496,35 @@ func (ic *ContainerEngine) ContainerClone(ctx context.Context, ctrCloneOpts enti
return nil, err
}
+ if ctrCloneOpts.CreateOpts.Pod != "" {
+ pod, err := ic.Libpod.LookupPod(ctrCloneOpts.CreateOpts.Pod)
+ if err != nil {
+ return nil, err
+ }
+
+ allNamespaces := []struct {
+ isShared bool
+ value *specgen.Namespace
+ }{
+ {pod.SharesPID(), &spec.PidNS},
+ {pod.SharesNet(), &spec.NetNS},
+ {pod.SharesCgroup(), &spec.CgroupNS},
+ {pod.SharesIPC(), &spec.IpcNS},
+ {pod.SharesUTS(), &spec.UtsNS},
+ }
+
+ printWarning := false
+ for _, n := range allNamespaces {
+ if n.isShared && !n.value.IsDefault() {
+ *n.value = specgen.Namespace{NSMode: specgen.Default}
+ printWarning = true
+ }
+ }
+ if printWarning {
+ logrus.Warning("At least one namespace was reset to the default configuration")
+ }
+ }
+
err = specgenutil.FillOutSpecGen(spec, &ctrCloneOpts.CreateOpts, []string{})
if err != nil {
return nil, err