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

share pid namespace for Pod container #1149

Merged
merged 1 commit into from Nov 17, 2017

Conversation

weiwei04
Copy link
Contributor

@weiwei04 weiwei04 commented Nov 13, 2017

Signed-off-by: Wei Wei weiwei.inf@gmail.com

- What I did

enable share pid namespace for containers in a pod, and add a --disable-share-pid-namespace flag to disable this feature

- How I did it

vim

- How to verify it

start crio with/without --disable-shared-pid-namespace

- Description for the changelog

enable share pid namespace for containers in a pod and add a --disable-share-pid-namespace flag to disable this feature

closes #1135
closes #488

@openshift-ci-robot
Copy link

Hi @weiwei04. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 13, 2017
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. cncf-cla: yes labels Nov 13, 2017
@weiwei04
Copy link
Contributor Author

@rhatdan @runcom please take a look, thanks :)

@rhatdan
Copy link
Contributor

rhatdan commented Nov 13, 2017

/ok-to-test

@openshift-ci-robot openshift-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Nov 13, 2017
@@ -115,6 +115,9 @@ default_mounts = [
# pids_limit is the number of processes allowed in a container
pids_limit = {{ .PidsLimit }}

# using a shared PID namespace for containers in a pod
Copy link
Contributor

Choose a reason for hiding this comment

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

default to using shared PID Namespace for containers in a pod

cmd/crio/main.go Outdated
@@ -296,6 +299,10 @@ func main() {
Value: libkpod.DefaultPidsLimit,
Usage: "maximum number of processes allowed in a container",
},
cli.BoolFlag{
Name: "share-pid-namespace",
Usage: "using a shared PID namespace for containers in a pod",
Copy link
Contributor

Choose a reason for hiding this comment

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

default to use a spared PID Namespace for containes in a pod (Default is false)

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want the default to be true?

docs/crio.8.md Outdated
@@ -118,6 +118,9 @@ set the CPU profile file path
**--pids-limit**=""
Maximum number of processes allowed in a container (default: 1024)

**--share-pid-namespace**=""
Using a shared PID namespace for containers in a pod (default: false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Default to use ashared PID namespace for containers in a pod (default: false)

@@ -87,6 +87,9 @@ Example:
**pids_limit**=""
Maximum number of processes allowed in a container (default: 1024)

**share_pid_namespace**=""
Using a shared PID namespace for containers in a pod (default: false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Default to use a shared PID namespace for containers in a pod (default: false)

@@ -121,6 +121,9 @@ type RuntimeConfig struct {
// NoPivot instructs the runtime to not use `pivot_root`, but instead use `MS_MOVE`
NoPivot bool `toml:"no_pivot"`

// SharePidNamespace instructs the runtime to share pid namespace
Copy link
Contributor

Choose a reason for hiding this comment

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

// SharePidNamespace instructs the runtime to share pid namespace by default

@rhatdan
Copy link
Contributor

rhatdan commented Nov 13, 2017

Thanks this looks pretty good, except for some nits on docs.
Could you add a test.

@rhatdan
Copy link
Contributor

rhatdan commented Nov 13, 2017

Biggest question for @mrunalp and @runcom is should we default this to True.

@runcom
Copy link
Member

runcom commented Nov 13, 2017

Biggest question for @mrunalp and @runcom is should we default this to True.

I think so, docker in kube already share the pid ns kubernetes/kubernetes#45236
but the first thing it comes to mind is openshift builds, they use the pid of the cri-o container to get the network namespace afaict and this could break that.

This is related to #488 and that issue talks about an init container as well

@mrunalp
Copy link
Member

mrunalp commented Nov 13, 2017

There was some discussion around this being passed over the CRI. That hasn't happened yet and so I think that we should probably default to False instead till that CRI field is added.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Nov 14, 2017
@weiwei04 weiwei04 force-pushed the share_pid_namespace branch 2 times, most recently from 4a253bd to 80285f6 Compare November 14, 2017 07:01
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 14, 2017
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 14, 2017
@weiwei04 weiwei04 force-pushed the share_pid_namespace branch 2 times, most recently from 5367b83 to e91916b Compare November 14, 2017 08:27
@weiwei04
Copy link
Contributor Author

changed from --share-pid-namespace to --disable-pid-namespace(like kubelet --docker-disable-shared-pid flag) add a e2e test, please take a look @rhatdan @runcom @mrunalp thanks :)

Some TODOs:

  1. For unit test, I'd like to open another pr to split createSandboxContainer into smaller functions and add more unit test. (Also glad to add more unit tests in other file/function, If you have some important files/functions want to add more unit test in mind)

  2. When I add the e2e, make validate are enforcing deprecate crioctl in favor of crictl, so I add a separate namespaces.bats file for share pid namespace e2e. Are we planning to replace crioctl in *.bats with crictl, if so I and my colleague would like to help.

@rhatdan
Copy link
Contributor

rhatdan commented Nov 14, 2017

Yes we are planning on moving from crioctl to crictl.
This PR Needs a Rebase.
I am fine with merging this once we pass tests.
@weiwei04 Tests sound great, and help on moving from crioctl to crictl, would be great.

@runcom
Copy link
Member

runcom commented Nov 14, 2017

Are we planning to replace crioctl in *.bats with crictl, if so I and my colleague would like to help.

❤️

@weiwei04
Copy link
Contributor Author

Rebased @rhatdan please take a look :)

Copy link
Contributor

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

(moved comment to correct line).

Copy link
Contributor

@TomSweeneyRedHat TomSweeneyRedHat left a comment

Choose a reason for hiding this comment

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

Otherwise the code LGTM.

@@ -115,6 +115,9 @@ default_mounts = [
# pids_limit is the number of processes allowed in a container
pids_limit = {{ .PidsLimit }}

# disable using a shared PID namespace for containers in a pod
disable_share_pid_namespace = {{ .DisableSharePIDNamespace }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Shoulda spotted this yesterday, but I think this variable and especially the customer facing parameter should be
disable_shared_pid_namespace (added 'd' to share). I'd make all of the variables 'shared' instead of "share".

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree change it to shared.

@weiwei04 weiwei04 force-pushed the share_pid_namespace branch 2 times, most recently from fab79f3 to 9468bdf Compare November 15, 2017 16:00
@weiwei04
Copy link
Contributor Author

@TomSweeneyRedHat changed to disable-shared-pid-namespace, please take a look, thanks! :)

@TomSweeneyRedHat
Copy link
Contributor

@weiwei04 LGTM, thanks for the touch up. Going to kick off the tests as you've initial green happiness.

@TomSweeneyRedHat
Copy link
Contributor

/test all

@mrunalp
Copy link
Member

mrunalp commented Nov 16, 2017

/test e2e_fedora

@weiwei04
Copy link
Contributor Author

Ping @rhatdan for merge :)

@test "pod disable shared pid namespace" {
export DISABLE_SHARED_PID_NAMESPACE="true"

start_crio
Copy link
Member

Choose a reason for hiding this comment

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

You can just do

DISABLE_SHARED_PID_NAMESPACE="true" start_crio

There is no need to export or add in cleanup then.

Signed-off-by: Wei Wei <weiwei.inf@gmail.com>
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 17, 2017
@mrunalp
Copy link
Member

mrunalp commented Nov 17, 2017

/test all

@mrunalp
Copy link
Member

mrunalp commented Nov 17, 2017

LGTM

@mrunalp mrunalp merged commit d68da89 into cri-o:master Nov 17, 2017
@rhatdan
Copy link
Contributor

rhatdan commented Nov 17, 2017

Should this be backported into the v1.8 branch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

why not share pid namespace Add support for sharing pid namespace
7 participants