Skip to content

Fix volume dir label for e2e-docker - #3398

Merged
openshift-bot merged 5 commits into
openshift:masterfrom
ncdc:e2e-docker-selinux
Jun 25, 2015
Merged

openshift-bot merged 5 commits into
openshift:masterfrom
ncdc:e2e-docker-selinux

Conversation

@ncdc

@ncdc ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor

For test-end-to-end-docker.sh, use a volume directory under BASETMPDIR
and label it correctly.

The intermediate labeling solution is to chcon the volume dir on the host to
svirt_sandbox_file_t.

Longer term, we could

  1. Update the selinux policy for volume dirs under /var/lib/openshift,
    assuming that's the default location for volumes.
  2. Modify
    https://github.com/openshift/origin/blob/master/pkg/cmd/server/kubernetes/node.go#L102-L121
    to always call chcon when the node starts, instead of only if the volume
    dir doesn't exist and is therefore newly created.

This commit also changes the file name format of container logs captured
by the e2e tests. Instead of being container-$containerID.log, they are
now container-$podName-$containerName.log, such as
container-docker-registry-1-7sm9l-registry.log.

@ncdc

ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor Author

Related to #3392

@ncdc

ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor Author

[test]

@ncdc

ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor Author

@smarterclayton @pmorie PTAL

Comment thread hack/test-end-to-end-docker.sh Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tabs are off here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Will fix.

@ncdc
ncdc force-pushed the e2e-docker-selinux branch from 051ed34 to 313336c Compare June 23, 2015 17:30
@ncdc
ncdc force-pushed the e2e-docker-selinux branch 2 times, most recently from 193589d to 30801ef Compare June 23, 2015 17:39
@smarterclayton

Copy link
Copy Markdown
Contributor

I can't read you awk so I don't know what you're trying to do.

@ncdc

ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor Author

I'm taking a Docker container name such as k8s_registry.de8ff935_docker-registry-1-2tzeo_default_ba3e46f6-15d5-11e5-9305-001c422dcd49_a350b6b8 and extracting the pod name and container name.

@smarterclayton

Copy link
Copy Markdown
Contributor

Looks like no. Can you split this into a function though?

On Jun 23, 2015, at 1:47 PM, Andy Goldstein [email protected] wrote:

I'm taking a Docker container name such as k8s_registry.de8ff935_docker-registry-1-2tzeo_default_ba3e46f6-15d5-11e5-9305-001c422dcd49_a350b6b8 and extracting the pod name and container name.

—
Reply to this email directly or view it on GitHub.

@ncdc

ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor Author

@smarterclayton

Copy link
Copy Markdown
Contributor

I thought you used it in multiple places

On Jun 23, 2015, at 1:52 PM, Andy Goldstein [email protected] wrote:

You want https://github.com/ncdc/origin/blob/e2e-docker-selinux/hack/util.sh#L267-L273 in a separate function?

—
Reply to this email directly or view it on GitHub.

@ncdc

ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor Author

Not any more

On Jun 23, 2015, at 2:02 PM, Clayton Coleman [email protected] wrote:

I thought you used it in multiple places

On Jun 23, 2015, at 1:52 PM, Andy Goldstein [email protected] wrote:

You want https://github.com/ncdc/origin/blob/e2e-docker-selinux/hack/util.sh#L267-L273 in a separate function?

—
Reply to this email directly or view it on GitHub.

—
Reply to this email directly or view it on GitHub.

@ncdc

ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor Author

[test]

@ncdc

ncdc commented Jun 23, 2015

Copy link
Copy Markdown
Contributor Author

Green Jenkins!

Comment thread hack/test-end-to-end-docker.sh Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this the default volume path? any reason not to mount VOLUME_DIR instead, closer to what we do in e2e?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

unfortunate if we can't keep e2e bits under a single dir

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is the way this script was originally set up. I tried switching to use VOLUME_DIR under /tmp/openshift-e2e. It took me a while to figure out why the mount calls were failing. They use nsenter_mount.go, which runs nsenter using the mount namespace from the node's pid 1. I think it wasn't able to see the dir, but I can dig further if needed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I0623 20:16:24.164991       1 empty_dir.go:282] pod b85ea4a2-19e4-11e5-a518-001c422dcd49: mounting tmpfs for volume not-used with opts [rootcontext="system_u:object_r:user_tmp_t:s0"]
I0623 20:16:24.165006       1 nsenter_mount.go:97] nsenter Mounting tmpfs /var/lib/openshift/openshift.local.volumes/pods/b85ea4a2-19e4-11e5-a518-001c422dcd49/volumes/kubernetes.io~secret/default-token-43tbh tmpfs [rootcontext="system_u:object_r:user_tmp_t:s0"]
I0623 20:16:24.165019       1 nsenter_mount.go:100] Mount command: nsenter [--mount=/rootfs/proc/1/ns/mnt -- /bin/mount -t tmpfs -o rootcontext="system_u:object_r:user_tmp_t:s0" tmpfs /var/lib/openshift/openshift.local.volumes/pods/b85ea4a2-19e4-11e5-a518-001c422dcd49/volumes/kubernetes.io~secret/default-token-43tbh]
I0623 20:16:24.169217       1 nsenter_mount.go:104] Output from mount command: mount: mount point /var/lib/openshift/openshift.local.volumes/pods/b85ea4a2-19e4-11e5-a518-001c422dcd49/volumes/kubernetes.io~secret/default-token-43tbh does not exist
E0623 20:16:24.169294       1 kubelet.go:1114] Unable to mount volumes for pod "exec_default": exit status 32; skipping pod

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The /var/lib/openshift path doesn't exist on the host for pid 1 to see - it only exists in the container.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@liggitt

is there anything we can do to detect they've configured VOLUME_DIR to something that won't work (selinux-wise) ahead of time, ideally at server start?

nsenter issue aside, I think we can modify https://github.com/openshift/origin/blob/master/pkg/cmd/server/kubernetes/node.go#L102-L121 to always chcon the directory at startup. Right now it only does it if the directory needs to be created.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ncdc got it. still, can't we tell openshfit to use a different volumedir (the tmpdir path)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bparees yes, let me try that (it'll just have to match the path on the host).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@bparees @liggitt looks like using -v ${VOLUME_DIR}:${VOLUME_DIR} and --volume-dir=${VOLUME_DIR} works. Should I go ahead and make this change?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's my vote. 

@ncdc
ncdc force-pushed the e2e-docker-selinux branch from 30801ef to 62b9985 Compare June 23, 2015 20:55
@ironcladlou

Copy link
Copy Markdown
Contributor

The log part of this LGTM; I don't have any background on the labeling.

Andy Goldstein added 2 commits June 24, 2015 13:48
For test-end-to-end-docker.sh, use a volume directory under BASETMPDIR
and label it correctly.

The intermediate labeling solution is to chcon the volume dir on the host to
svirt_sandbox_file_t.

Longer term, we could

1. Update the selinux policy for volume dirs under /var/lib/openshift,
assuming that's the default location for volumes.
2. Modify
https://github.com/openshift/origin/blob/master/pkg/cmd/server/kubernetes/node.go#L102-L121
to always call chcon when the node starts, instead of only if the volume
dir doesn't exist and is therefore newly created.

This commit also changes the file name format of container logs captured
by the e2e tests. Instead of being container-$containerID.log, they are
now container-$podName-$containerName.log, such as
container-docker-registry-1-7sm9l-registry.log.
@ncdc
ncdc force-pushed the e2e-docker-selinux branch from 62b9985 to 2dea4d9 Compare June 24, 2015 17:50
@ncdc

ncdc commented Jun 24, 2015

Copy link
Copy Markdown
Contributor Author

[test]

@ncdc

ncdc commented Jun 24, 2015

Copy link
Copy Markdown
Contributor Author

Need to clean up the pods from e2e-docker before we can start normal e2e. e2e tries to delete /tmp/openshift-e2e, but there are some lingering mounts (secrets etc) from e2e-docker in there. Working on a fix.

Comment thread hack/test-end-to-end-docker.sh Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add -r to xargs to avoid running if there are no matching mounts

@ncdc
ncdc force-pushed the e2e-docker-selinux branch from fa68605 to ac542a1 Compare June 24, 2015 20:25
@ncdc

ncdc commented Jun 24, 2015

Copy link
Copy Markdown
Contributor Author

delete all flake [test]

@ncdc

ncdc commented Jun 24, 2015

Copy link
Copy Markdown
Contributor Author

[merge]

@ncdc

ncdc commented Jun 24, 2015

Copy link
Copy Markdown
Contributor Author

jinx!

@openshift-bot

Copy link
Copy Markdown
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/3342/) (Image: devenv-fedora_1868)

@openshift-bot

Copy link
Copy Markdown
Contributor

@ncdc

ncdc commented Jun 24, 2015

Copy link
Copy Markdown
Contributor Author

Looks like I'm going to have to do some more tweaking to get this fully resolved. I'll take a look in a bit, or tomorrow.

Comment thread hack/test-end-to-end-docker.sh Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

umount -f?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Also, if we're ok with this in general, adding it just before you rm -rf the temp-dir would be good insurance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm tempted to run oc delete all --all for the test and default projects, and then run a wait_for_command that waits for the # of mounts in VOLUME_DIR to be 0.

Also, while we can do this before we clean the temp dir, the issue I'm facing is that e2e-docker runs and creates mounts in /tmp/openshift-e2e/containerized/volumes, finishes running, and then e2e starts and tries to rm -rf /tmp/openshift-e2e. This fails because there are some lingering mounts from the e2e-docker run.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

long-term, I'd much rather give e2e and e2e-docker their own folders

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 to waiting for mounts to be cleaned up. Seems like better test coverage.

Hopefully delete all flakes are resolved...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cleanup can't really make assumptions about the API being available... it gets called in response to an exit signal, which could be from a failure halfway through...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

cleanup can't really make assumptions about the API being available... it gets called in response to an exit signal, which could be from a failure halfway through...

I thought we were talking about waiting for a condition after delete all, not verifying stuff following signal handling... did I misunderstand?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Change BASETMPDIR to /tmp/openshift-e2e-containerized so it does not
share a common directory with test-end-to-end.sh. When they share a
common directory, if the volume mounts don't get cleaned up for whatever
reason, running the tests in succession can fail when they try to rm -rf
BASETMPDIR.

During test cleanup, attempt to delete all resources from the test and
default projects, and then wait up to 2 minutes for the volume mounts to
clear (it should only take approximately 10 seconds).
@openshift-bot

Copy link
Copy Markdown
Contributor

Evaluated for origin up to ba9bea7

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is selinuxenabled available in all OSes we run e2e on?

openshift-bot pushed a commit that referenced this pull request Jun 25, 2015
@openshift-bot
openshift-bot merged commit dada0ee into openshift:master Jun 25, 2015
@ironcladlou

Copy link
Copy Markdown
Contributor

🎉 🎊 🎈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants