-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
container: allow clone to an existing pod #13587
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Nice and simple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this behave with the namespaces?
Does the container actually use the pod namespaces? If so this would conflict with the network settings and maybe more.
I don't think it would join the namespaces |
it joins the ipc and uts namespaces, but it doesn't join the network namespace, checking the infra container init pid and the cloned container:
|
This sounds inconsistent. From a user experience I would expect it to join all shared namespaces from the pod. |
should we bark if the container sets up the network differently? /hold |
yeah I would either warn that the namespaces are going to be altered when joining the pod or fail altogether. |
I think you should just warn that the container is adopting the the pod's namespaces. |
fixed. Now I get:
and these that are expected to be different:
|
pkg/domain/infra/abi/containers.go
Outdated
allNamespaces := []*specgen.Namespace{&spec.PidNS, &spec.NetNS, &spec.CgroupNS, &spec.IpcNS, &spec.UtsNS} | ||
printWarning := false | ||
for _, n := range allNamespaces { | ||
if !n.IsDefault() { | ||
printWarning = true | ||
} | ||
*n = specgen.Namespace{NSMode: specgen.Default} | ||
} | ||
if printWarning { | ||
logrus.Debug("At least one namespace was set to the default configuration") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this works as expected, I think you should only do the check for the namespaces that are actually shared in the pod instead of all of them.
I tries the following commands as rootless with this patch:
podman pod create --name test --share ipc
podman run --network podman --name con1 alpine ip a
podman container clone --pod test con1
podman start --attach con1-clone
In this case since you reset the net namespace we loose the network information but the namespace was never shared so we should not reset it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for checking it.
Do you like the newer version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks good but I would like to have a test case for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test added
I am doing a large change to |
Signed-off-by: Giuseppe Scrivano <[email protected]>
Closes: containers#3979 Signed-off-by: Giuseppe Scrivano <[email protected]>
/lgtm |
/hold cancel |
Closes: #3979
Signed-off-by: Giuseppe Scrivano [email protected]