Skip to content

Conversation

@dgoodwin
Copy link
Contributor

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.

@liggitt
Copy link
Contributor

liggitt commented Jan 14, 2016

current SCCs allow empty dir, so we have to preserve that behavior

Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dgoodwin
Copy link
Contributor Author

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.

@dgoodwin dgoodwin changed the title (WIP) Add SCC support for blocking pods from using EmptyDir volumes. Add SCC support for blocking pods from using EmptyDir volumes. Jan 18, 2016
Copy link
Contributor

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).

Copy link
Contributor Author

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.

@dgoodwin
Copy link
Contributor Author

Updated for review, separate commit for now to help reviewers, will squash before merge.

@ironcladlou
Copy link
Contributor

LGTM, but probably need a final review from @liggitt or @pweil-.

Copy link
Contributor

Choose a reason for hiding this comment

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

undo whitespace change

@liggitt
Copy link
Contributor

liggitt commented Jan 21, 2016

split into three commits:

  1. all v1beta3 changes in a commit titled UPSTREAM: <carry>: v1beta3 scc
  2. all other Godep changes in a commit titled UPSTREAM: <carry>: scc
  3. all other changes in a regular commit

Copy link
Contributor

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

Copy link

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.

@dgoodwin
Copy link
Contributor Author

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.

@dgoodwin
Copy link
Contributor Author

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.

@liggitt
Copy link
Contributor

liggitt commented Jan 21, 2016

I'd still like @pweil-'s feedback, and if possible, to hold this until the rebase lands

@pweil-
Copy link

pweil- commented Jan 21, 2016

[test]

@dgoodwin
Copy link
Contributor Author

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.

@dgoodwin
Copy link
Contributor Author

Updated with a master rebase and some things @dobbymoodge caught.

  • renamed boolPtr helper to newBool to better match some other similar functions.
  • added a missed assertion in the v1beta3 defaults_test.go.
  • more closely match the spirit of some existing tests in both defaults_test.go files by explicitly setting an allowEmptyDirVolumePlugin value.

Still waiting on kube rebase for merge.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 27, 2016
@dgoodwin
Copy link
Contributor Author

Rebased on top of new k8s, test added per comments above.

Should be GTG on my side @liggitt .

@dgoodwin
Copy link
Contributor Author

re[test] please.

@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 27, 2016
Copy link
Contributor

Choose a reason for hiding this comment

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

...Child("volumes").Index(i)

@deads2k
Copy link
Contributor

deads2k commented Feb 1, 2016

@deads2k, I assume we're not at the point of holding this out for the rebase yet?

No, the queue is still open. This could take a while.

@dgoodwin
Copy link
Contributor Author

dgoodwin commented Feb 2, 2016

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
===== Verifying API Swagger Spec =====
Generating a fresh spec...
Diffing current spec against freshly generated spec...
SUCCESS: Swagger spec up to date.

Travis is claiming a diff on a few fields unrelated to this PR... trying to sort it out.

@dgoodwin
Copy link
Contributor Author

dgoodwin commented Feb 2, 2016

Alright that looks like a test infra flake. Re-[test] please.

@dgoodwin
Copy link
Contributor Author

dgoodwin commented Feb 3, 2016

Re[test] please.

@dgoodwin
Copy link
Contributor Author

dgoodwin commented Feb 3, 2016

[test]

@deads2k
Copy link
Contributor

deads2k commented Feb 3, 2016

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.

@dgoodwin
Copy link
Contributor Author

dgoodwin commented Feb 8, 2016

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.

@deads2k
Copy link
Contributor

deads2k commented Feb 8, 2016

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?

@dgoodwin
Copy link
Contributor Author

dgoodwin commented Feb 8, 2016

The only conflict was in the resource printer FWIW.

@dgoodwin
Copy link
Contributor Author

dgoodwin commented Feb 8, 2016

@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.

@dgoodwin
Copy link
Contributor Author

dgoodwin commented Feb 8, 2016

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.
@openshift-bot
Copy link
Contributor

Evaluated for origin test up to b6f497d

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/test SUCCESS (https://ci.openshift.redhat.com/jenkins/job/test_pr_origin/968/)

@deads2k
Copy link
Contributor

deads2k commented Feb 10, 2016

@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 :)

@pweil-
Copy link

pweil- commented Feb 10, 2016

I will give this one more review tomorrow and push it before I go any further on the next rebase.

@pweil-
Copy link

pweil- commented Feb 11, 2016

[merge]

@openshift-bot
Copy link
Contributor

continuous-integration/openshift-jenkins/merge SUCCESS (https://ci.openshift.redhat.com/jenkins/job/merge_pull_requests_origin/4923/) (Image: devenv-rhel7_3395)

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to b6f497d

openshift-bot pushed a commit that referenced this pull request Feb 11, 2016
@openshift-bot openshift-bot merged commit 4f6dfd8 into openshift:master Feb 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants