-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Add node e2e tests for hostPid #44119
Conversation
} | ||
|
||
// the pid of 'sh' should not be 1 if it is in hostPid mode. | ||
if logs == "1\n" { |
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.
This would not work in the future if we enable shared pid namespace in the pod. Maybe we can create two host pid pods and check whether they can see each other.
You can also create a non-host-pid-ns pod, and verify that it cannot see others.
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.
This would not work in the future if we enable shared pid namespace in the pod. Maybe we can create to host pid pods and check whether they can see each other.
That's right. Will update.
88b199f
to
3c21c6b
Compare
busyboxPodName := "busybox-hostpid-" + string(uuid.NewUUID()) | ||
nginxPodName := "nginx-hostpid-" + string(uuid.NewUUID()) | ||
It("should create the pod in hostPid", func() { | ||
podClient.CreateSync(makeHostPidPod(nginxPodName, |
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.
The test will pass if there happens to be any nginx process running on the node. We should make sure the pid actually matches. You can get the pid of the process by exec
into the container and cat
the /var/run/nginx.pid
file.
In the other container, you should make sure if the output includes the pid we are looking for.
I'd still like to see a test for a non-hostpid pod to make sure we don't always use host pid.
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.
Agree. @xlgao-zju We could also test hostpid and hostipc in similar way.
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.
ACK
} | ||
busyboxPodName := "busybox-hostpid-" + string(uuid.NewUUID()) | ||
nginxPodName := "nginx-hostpid-" + string(uuid.NewUUID()) | ||
It("should create the pod in hostPid", func() { |
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.
nit: s/in hostPid/in the host PID namespace
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.
ACK
Adding @Random-Liu since we need an approver. |
busyboxPodName := "busybox-hostpid-" + string(uuid.NewUUID()) | ||
nginxPodName := "nginx-hostpid-" + string(uuid.NewUUID()) | ||
It("should create the pod in hostPid", func() { | ||
podClient.CreateSync(makeHostPidPod(nginxPodName, |
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.
Agree. @xlgao-zju We could also test hostpid and hostipc in similar way.
|
||
podClient.CreateSync(makeHostPidPod(busyboxPodName, | ||
"gcr.io/google_containers/busybox:1.24", | ||
[]string{"sh", "-c", "pgrep nginx; sleep 240"})) |
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.
Why sleep 240
? Maybe just tail -f /dev/null
[]string{"sh", "-c", "pgrep nginx; sleep 240"})) | ||
|
||
Eventually(func() error { | ||
logs, err := framework.GetPodLogs(f.ClientSet, f.Namespace.Name, busyboxPodName, busyboxPodName) |
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.
Even if you go with current solution, we should trim spaces here to make sure logs
is actually empty.
And I think yuju's suggestion is better and more reliable here.
LGTM |
440503f
to
dc034fc
Compare
test/e2e_node/security_context_test.go, line 63 at r4 (raw file):
Why not just Comments from Reviewable |
Good idea. Updated. |
Review status: 0 of 2 files reviewed at latest revision, 8 unresolved discussions. test/e2e_node/security_context_test.go, line 88 at r5 (raw file):
Why use test/e2e_node/security_context_test.go, line 113 at r5 (raw file):
Why use Comments from Reviewable |
/cc @Helen-Xie @heartlock |
438f1ca
to
06b89fd
Compare
@Random-Liu Fixed. PTAL. |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Random-Liu, feiskyer
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
Commit found in the "release-1.6" branch appears to be this PR. Removing the "cherrypick-candidate" label. If this is an error find help to get your PR picked. |
Automatic merge from submit-queue Automated cherry pick of kubernetes#44097 and kubernetes#44119 Cherry pick kubernetes#44097 and kubernetes#44119 for release-1.6. Fix container hostPid settings. **Release note**: ```release-note Fix container hostPid settings when CRI is enabled. ```
For #44118. Add node e2e tests for hostPid.
cc @yujuhong @kubernetes/sig-node-pr-reviews