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

capability defaulting #6470

Merged
merged 2 commits into from
Jan 16, 2016
Merged

capability defaulting #6470

merged 2 commits into from
Jan 16, 2016

Conversation

pweil-
Copy link

@pweil- pweil- commented Dec 22, 2015

@smarterclayton @eparis - here is the WIP for adding required add/drops into SCCs. PTAL

The mechanics are:

  1. You may define requiredCapabilities in the SCC which can include adds and drops
  2. Defaulting will produce
  3. Adds: all required caps + container requested adds - container requested drops (you can drop required adds if you want, just means your container can do less)
  4. Drops: all required drops + container requested drops
  5. Validation will ensure
  6. Adds: all adds must be in either the required or allowed add lists of the SCC
  7. Drops: all required drops are in the drop set

@smarterclayton
Copy link
Contributor

Do we need to be smart and not add defaults when they are already dropped (by the container or scc)?

@pweil-
Copy link
Author

pweil- commented Dec 22, 2015

Do we need to be smart and not add defaults when they are already dropped (by the container or scc)?

Since I'm using a string set and using the union it will not duplicate the adds. If the container is dropping something that is added by default it will be removed by the Difference call here: https://github.com/openshift/origin/pull/6470/files#diff-c7bf63e9488690fe18014ead17dbdd2cR61

@pweil- pweil- force-pushed the scc-caps branch 3 times, most recently from 14452c0 to 1aef128 Compare December 22, 2015 20:24
@smarterclayton
Copy link
Contributor

[test]

// the containers. Any capability listed in add will be added to the container even if
// it is not requested. Any capability listed in drop will be removed from the container
// even if it is requested to be added.
RequiredCapabilities Capabilities `json:"requiredCapabilities" description:"capabilities that must be added and dropped"`
Copy link
Contributor

Choose a reason for hiding this comment

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

added or dropped

@jwhonce
Copy link
Contributor

jwhonce commented Jan 5, 2016

@twiest FYI

@smarterclayton
Copy link
Contributor

One more question. An admin wants to run a pod. They have access to various high privilige sccs. When they run a pod that wants to ping, will they get defaulted to drop raw net caps?

@pweil-
Copy link
Author

pweil- commented Jan 11, 2016

One more question. An admin wants to run a pod. They have access to various high privilige sccs. When they run a pod that wants to ping, will they get defaulted to drop raw net caps?

In this case, the assumption would be that the admin has access to an SCC that does not require the net caps to be dropped. The admin should use prioritization to ensure that they get the defaults they expect when not requesting specific capabilities that would force validation failures (similar to requesting UID 0 before we could prioritize the anyuid SCC).

@smarterclayton
Copy link
Contributor

Ok - those changes will be follow up / split PR?

On Mon, Jan 11, 2016 at 2:52 PM, Paul Weil notifications@github.com wrote:

One more question. An admin wants to run a pod. They have access to
various high privilige sccs. When they run a pod that wants to ping, will
they get defaulted to drop raw net caps?

In this case, the assumption would be that the admin has access to an SCC
that does not require the net caps to be dropped. The admin should use
prioritization to ensure that they get the defaults they expect when not
requesting specific capabilities that would force validation failures
(similar to requesting UID 0 before we could prioritize the anyuid SCC).


Reply to this email directly or view it on GitHub
#6470 (comment).

@pweil-
Copy link
Author

pweil- commented Jan 11, 2016

Ok - those changes will be follow up / split PR?

Yes, wrapping up unit tests right now on this one for the mechanics and then we can do a follow up that will add in the default sets of caps to our bootstrap policies where appropriate.

@pweil-
Copy link
Author

pweil- commented Jan 11, 2016

Updated with more tests and cleaned up comments. Ready for review.

@pmorie @liggitt - could I get some eyes on this one when you get a chance?

@pweil- pweil- changed the title WIP: capability defaulting capability defaulting Jan 11, 2016
@smarterclayton
Copy link
Contributor

Changes LGTM but want another sign off.

@@ -2597,7 +2597,19 @@ type SecurityContextConstraints struct {

// AllowPrivilegedContainer determines if a container can request to be run as privileged.
AllowPrivilegedContainer bool `json:"allowPrivilegedContainer" description:"allow containers to run as privileged"`
// Required capabilities are the capability set that must be set or defaulted into
Copy link
Contributor

Choose a reason for hiding this comment

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

How about RequiredCapabilities are defaulted into containers. ?

Copy link
Author

Choose a reason for hiding this comment

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

done

@pweil- pweil- force-pushed the scc-caps branch 2 times, most recently from 509a0eb to 0e7c71f Compare January 13, 2016 21:19
@pweil-
Copy link
Author

pweil- commented Jan 13, 2016

@pmorie @liggitt @deads2k - any other comments on the mechanics here? I've run through my tests and it appears to be defaulting and restricting correctly. We can iterate on the actual values of the defaults separately (they are in #6627)

@pweil-
Copy link
Author

pweil- commented Jan 13, 2016

[test]

allowedCapListedInRequiredDrop.RequiredCapabilities = api.Capabilities{
Drop: []api.Capability{"foo"},
}
allowedCapListedInRequiredDrop.AllowedCapabilities = []api.Capability{"foo"}
Copy link
Contributor

Choose a reason for hiding this comment

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

what about a test case where a capability is in both add, drop, and allowed?

Copy link
Author

Choose a reason for hiding this comment

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

the validation doesn't care about that. It tests required.Add -> required.Drop and Allowed -> required.Drop. It is valid to have it in allowed and required.Add though I don't see why someone would do that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I'll buy that for now. If people find it incredibly confusing we can add a validation later.

Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a validation later if that would invalidate existing sccs?

Copy link
Author

Choose a reason for hiding this comment

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

I don't think we need validation for this but if someone really wants it I can add it. If you put something in both allowed and required.add it is just redundant but it isn't invalid. It is invalid to have something in (allowed or required.add) AND required.drop which is what we're validating.

@pweil-
Copy link
Author

pweil- commented Jan 14, 2016

re[test]

@smarterclayton
Copy link
Contributor

Any other comments on this?

On Wed, Jan 13, 2016 at 8:40 PM, OpenShift Bot notifications@github.com
wrote:

continuous-integration/openshift-jenkins/test FAILURE (
https://ci.openshift.redhat.com/jenkins/job/test_pull_requests_origin/8540/
)


Reply to this email directly or view it on GitHub
#6470 (comment).

@soltysh
Copy link
Contributor

soltysh commented Jan 14, 2016

/sub

},
// UC 3: if an SCC requires a cap then it should accept the pod request
// to add the cap.
"should accept cap add when in requied": {
Copy link
Contributor

Choose a reason for hiding this comment

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

required

@pweil-
Copy link
Author

pweil- commented Jan 14, 2016

Updates:

  1. Rename to InitialCapabilities
  2. Rename of strategy
  3. Added back case sensitivity - this seems the safest route because these are container runtime specific values
  4. Added tests for case sensitivity for add/drop generation and validation
  5. Added tests to ensure deduping of matched case items during generation of adds and drops
  6. Fixed typos

@liggitt @pmorie

@pweil-
Copy link
Author

pweil- commented Jan 14, 2016

re[test]

// 3. Capabilities in InitialCapabilities.Drop will be dropped from the container
// 4. Containers that request to add a capability that is required to be dropped will fail
// validation.
InitialCapabilities Capabilities `json:"initialCapabilities" description:"capabilities that will be added or dropped"`
Copy link
Contributor

Choose a reason for hiding this comment

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

This name makes it seem like capabilities can change over time. "initial" needs a time context to be understood, and it's a little odd because the sequence is: 1) pod spec submitted to the API may specify capabilities, 2) admission drops some capabilities, adds some capabilities unless dropped by the pod, 3) object is created and capabilities can never be changed.

What about "assignedCapabilities"? They are what admission will assign to the pod at creation time, and the pod author can explicitly opt out of some of the added capabilities by dropping them in their submitted pod spec.

Copy link
Member

Choose a reason for hiding this comment

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

I know it is bike shedding, but 'assigned' sounds to me like it would blindly overwrite things. Which it only sort of does. You don't end up with the 'assigned' caps. You end up with some amalgamation.

I'm not arguing for Initial either, I'll try to think of something to propose instead of just being a negative nancy...

Copy link
Author

Choose a reason for hiding this comment

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

Last IRC suggestion was:

allowedCapabilities []kapi.Capbility - what you're allowed to add (already exists)
defaultAddCapabilitiess []kapi.Capbility - what you'll be given by default unless you drop one of them explicitly
requiredDropCapabilitiess []kapi.Capbility - you must drop these

@smarterclayton @eparis @liggitt - satisfactory?

Copy link
Contributor

Choose a reason for hiding this comment

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

allowedAddCapabilities

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't change that one, it already exists

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 in love with the names but we don't have time to bike shed. Names are approved

@pweil-
Copy link
Author

pweil- commented Jan 15, 2016

@liggitt @eparis - updated, PTAL

// container specifically is dropping the cap) and container requested adds
// 2. a capabilities.Drop set containing all the required drops and container requested drops
func (s *defaultCapabilities) Generate(pod *api.Pod, container *api.Container) (*api.Capabilities, error) {
requiredAdd := makeCapSet(s.defaultAddCapabilities)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/requiredAdd/defaultAdd/

Copy link
Author

Choose a reason for hiding this comment

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

fixed

@pweil-
Copy link
Author

pweil- commented Jan 15, 2016

re[test]

@liggitt liggitt added this to the 1.1.1 milestone Jan 15, 2016
@pweil-
Copy link
Author

pweil- commented Jan 15, 2016

[test]

@openshift-bot
Copy link
Contributor

Evaluated for origin test up to ddf3dd0

@pweil-
Copy link
Author

pweil- commented Jan 15, 2016

@liggitt anything else on the revised code that looks fishy? I'm just fighting with jenkins at this point.

@openshift-bot
Copy link
Contributor

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

@liggitt
Copy link
Contributor

liggitt commented Jan 16, 2016

nope, LGTM

@smarterclayton
Copy link
Contributor

[merge]

@openshift-bot
Copy link
Contributor

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

@smarterclayton
Copy link
Contributor

[merge]

@openshift-bot
Copy link
Contributor

Evaluated for origin merge up to ddf3dd0

openshift-bot pushed a commit that referenced this pull request Jan 16, 2016
@openshift-bot openshift-bot merged commit 9b59dab into openshift:master Jan 16, 2016
@pweil- pweil- deleted the scc-caps branch January 19, 2016 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants