-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add SCC support for blocking pods from using EmptyDir volumes. #6659
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
Conversation
|
current SCCs allow empty dir, so we have to preserve that behavior |
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.
if you need to distinguish between unset, true, and false, you can make the v1 field a *bool, the internal field a bool, use defaulting in v1 to preserve prior behavior, and use conversion to take the external *bool to a bool internally
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'm not sure we need to distinguish unset with a pointer type. I think we can use a defaulting function to set true.
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.
Whoops, nevermind. We need a pointer AND a defaulter.
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.
c4398e3 to
bd5a4dd
Compare
|
Thanks for the tips @liggitt & @ironcladlou Branch & commit message updated, now using a primitive bool on the API SCC but *bool on the versioned SCC types. Registered a default for the type as well to ensure we make this true whenever possible. The bootstrappolicy still needs to set it explicitly however as we're just creating the objects directly. The k8s "generated".go files are manually updated for the new struct field. Removing WIP as I think it's ready for full review. |
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 is the canonical format for a field error. Check out https://github.com/dgoodwin/origin/blob/block-emptydir-scc/Godeps/_workspace/src/k8s.io/kubernetes/pkg/securitycontextconstraints/provider.go#L264 for reference. I think you should address it as something like volumes[index] (and correctly prefixed).
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.
Original error:
Error creating: Pod "testrc-" is forbidden: unable to validate against any security context constraint: [provider restricted: .spec.containers[0].securityContext.VolumeMounts: invalid value 'container-data', Details: EmptyDir Volumes are not allowed to be used]
I changed it to this now:
Error creating: Pod "testrc-" is forbidden: unable to validate against any security context constraint: [provider restricted: .spec.containers[0].securityContext.volumes[0]: invalid value 'emptyDir', Details: EmptyDir volumes are not allowed to be used]
I also adjusted the HostPath error just above where I got the bad example originally.
|
Updated for review, separate commit for now to help reviewers, will squash before merge. |
hack/update-generated-conversions.sh
Outdated
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.
undo whitespace change
|
split into three commits:
|
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 incongruence makes me very sad, but I don't see a better way to keep the current behavior
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 makes me wonder if we should change the upstream proposal to be a blacklist of plugins rather than a whitelist.
ddab54e to
b5b4eea
Compare
|
Updated into three separate commits, rolled back whitespace change to script I didn't end up modifying. @liggitt I saw in email you were thinking about removing the change to the proposal .md file, but looks like you removed it. If github ate that somehow just say the word and I'll pull it out as well. |
|
UPDATE: github's stripping out the brackets thus why those commit messages didn't look right. I will add in carry as that looks like what most SCC commits are flagged, let me know if I've got that wrong. |
b5b4eea to
07b9402
Compare
|
I'd still like @pweil-'s feedback, and if possible, to hold this until the rebase lands |
|
[test] |
07b9402 to
b8db239
Compare
|
Brought the volume scanning into one loop guarded on both conditions, and my apologies that's a legit test failure, I somehow slipped breakage in while refactoring during review. Should be healthy now. |
b8db239 to
1973f56
Compare
|
Updated with a master rebase and some things @dobbymoodge caught.
Still waiting on kube rebase for merge. |
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.
Shouldn't this be expectedAllowEmptyDir: false,, since default is true?
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 then be identical to "preserve AllowEmptyDirVolumePlugin set to false" at the end, the only case missing was set to true and check true. Probably shouldn't be messing around with this test at all, it's named generically but I don't think it's actually meant for every property possible. Instead I should probably just add another test at the end for set true check true. Set nothing and expect true would be covered by all pre-existing tests.
1973f56 to
386c442
Compare
|
Rebased on top of new k8s, test added per comments above. Should be GTG on my side @liggitt . |
|
re[test] please. |
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.
...Child("volumes").Index(i)
No, the queue is still open. This could take a while. |
7241a60 to
b3b6990
Compare
|
My local swagger diff problem was caused by a vim .swp file floating around in there. However I am really not sure why it's still failing here. $ sudo hack/verify-generated-swagger-spec.sh Travis is claiming a diff on a few fields unrelated to this PR... trying to sort it out. |
b3b6990 to
11724f0
Compare
|
Alright that looks like a test infra flake. Re-[test] please. |
|
Re[test] please. |
|
[test] |
|
We're down to unit tests now. I'd like a hold on this until after the rebase (hopefully this week/early next week). Particularly since we're changing up how UPSTREAM patches are handled for rebases. |
11724f0 to
7008d99
Compare
|
Reapplied on top of the rebase but I don't think this is ready yet until master settles down, I'm seeing two issues that sound master related, one the default is coming out "false" suddenly, and two any attempt to edit an scc is met with a "apiVersion should not be changed" error. Will keep trying as master settles down. |
I'm not aware of either of those issues. Can you write them up with details so we can look at them? |
|
The only conflict was in the resource printer FWIW. |
|
@deads2k can do, one of them sounds similar to something in Clayton's email. I'll get issues up for both though one is kinda specific to my PR, not sure it can be reproduced otherwise. I'll start with the one that can though. |
|
The main one is reported in: #7085 I'll try to work a bit on the one that might be a problem with my PR and see if I can tell what it is or explain in a relevant way for an issue. |
v1beta3 changes for new SCC allowEmptyDirVolumePlugin. Uses bool pointers to allow distinction between set vs unset, allowing us to roll this change out without affecting the default behaviour today which is to implicitly allow EmptyDir volumes.
SCC support for allowing emptyDir volumes. Preserves current default behaviour of allowing.
7008d99 to
b6f497d
Compare
|
Evaluated for origin test up to b6f497d |
|
continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/968/) |
|
@pweil- I blocked this on the rebase last time. If its still good, he'd probably like a merge before the next one goes in :) |
|
I will give this one more review tomorrow and push it before I go any further on the next rebase. |
|
[merge] |
|
continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/4923/) (Image: devenv-rhel7_3395) |
|
Evaluated for origin merge up to b6f497d |
Merged by openshift-bot
Builds off the example of AllowHostDirVolumePlugin. Change is being implemented to satisfy some online/multi-tenant use cases, and roughly matches a planned feature for pod security policy: https://github.com/pweil-/kubernetes/blob/security-policy/docs/proposals/security-context-constraints.md
There is however an outstanding problem I could use some guidance on, today use of empty dir volumes is implicitly allowed, but this SCC parameter is a boolean to allow it, which will zero to false effectively breaking every SCC out in the wild. I am unsure how best to roll this out.
Ideas:
(1) reconcile-sccs command
(2) Inverting it to DenyEmptyDirVolumePlugin. There's nothing else in the SCC that would match this 'deny' convention, so it feels inconsistent, but it might be more technically correct for what it actually needs to do.
(3) Alternatively could we make it a string so we can have a legitimate third state? Empty string = unset, "true" and "false"?
We don't really need a third state so in some ways I'd kind of lean towards (2) as being the best option, but please let me know what you think or if there are other ideas.