Skip to content
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

Merged
merged 2 commits into from
Mar 24, 2022

Conversation

giuseppe
Copy link
Member

Closes: #3979

Signed-off-by: Giuseppe Scrivano [email protected]

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 22, 2022

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@giuseppe giuseppe mentioned this pull request Mar 22, 2022
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 22, 2022
@rhatdan
Copy link
Member

rhatdan commented Mar 22, 2022

Nice and simple.
LGTM

Copy link
Member

@Luap99 Luap99 left a 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.

@mheon
Copy link
Member

mheon commented Mar 22, 2022

I don't think it would join the namespaces

@giuseppe
Copy link
Member Author

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:

$ readlink  /proc/{2351872,2351892}/ns/ipc
ipc:[4026533360]
ipc:[4026533360]
$ readlink  /proc/{2351872,2351892}/ns/uts
uts:[4026533359]
uts:[4026533359]
$ readlink  /proc/{2351872,2351892}/ns/net
net:[4026533086]
net:[4026533364]

@Luap99
Copy link
Member

Luap99 commented Mar 22, 2022

This sounds inconsistent. From a user experience I would expect it to join all shared namespaces from the pod.

@giuseppe
Copy link
Member Author

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

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 22, 2022
@cdoern
Copy link
Contributor

cdoern commented Mar 22, 2022

yeah I would either warn that the namespaces are going to be altered when joining the pod or fail altogether.

@rhatdan
Copy link
Member

rhatdan commented Mar 23, 2022

I think you should just warn that the container is adopting the the pod's namespaces.

@giuseppe
Copy link
Member Author

fixed. Now I get:

$ readlink /proc/{2618221,2618232}/ns/net
net:[4026533449]
net:[4026533449]
$ readlink  /proc/{2618221,2618232}/ns/ipc
ipc:[4026533529]
ipc:[4026533529]
$ readlink /proc/{2618221,2618232}/ns/uts
uts:[4026533528]
uts:[4026533528]

and these that are expected to be different:

$ readlink /proc/{2618221,2618232}/ns/pid
pid:[4026533530]
pid:[4026533534]
$ readlink /proc/{2618221,2618232}/ns/cgroup
cgroup:[4026533531]
cgroup:[4026533535]

Comment on lines 1505 to 1525
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")
}
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test added

docs/source/markdown/podman-container-clone.1.md Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 24, 2022
@cdoern
Copy link
Contributor

cdoern commented Mar 24, 2022

I am doing a large change to ConfigToSpec in #13594 there are a number of things that seem to be broken just a heads up if that merges

Signed-off-by: Giuseppe Scrivano <[email protected]>
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 24, 2022
@rhatdan
Copy link
Member

rhatdan commented Mar 24, 2022

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 24, 2022
@rhatdan
Copy link
Member

rhatdan commented Mar 24, 2022

/hold cancel

@openshift-ci openshift-ci bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 24, 2022
@openshift-merge-robot openshift-merge-robot merged commit caaaf07 into containers:main Mar 24, 2022
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move container to pod
6 participants