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

Bootstrap Kube namespaced roles and bindings #16517

Merged

Conversation

enj
Copy link
Contributor

@enj enj commented Sep 22, 2017

This change brings in the upstream namespaced roles that are used by controllers. These will never conflict with the openshift ones since they are required to be in namespaces prefixed with "kube-".

Signed-off-by: Monis Khan [email protected]

@openshift-ci-robot openshift-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Sep 22, 2017
@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 22, 2017
@@ -53,6 +55,7 @@ func NewCommandCreateBootstrapPolicyFile(commandName string, fullName string, ou

flags.StringVar(&options.File, "filename", DefaultPolicyFile, "The policy template file that will be written with roles and bindings.")
flags.StringVar(&options.OpenShiftSharedResourcesNamespace, "openshift-namespace", "openshift", "Namespace for shared resources.")
flags.MarkDeprecated("openshift-namespace", "this field is no longer supported and using it can lead to undefined behavior")
Copy link
Contributor

Choose a reason for hiding this comment

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

this entire command should just die.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

3.8

@@ -53,6 +55,7 @@ func NewCommandCreateBootstrapPolicyFile(commandName string, fullName string, ou

flags.StringVar(&options.File, "filename", DefaultPolicyFile, "The policy template file that will be written with roles and bindings.")
flags.StringVar(&options.OpenShiftSharedResourcesNamespace, "openshift-namespace", "openshift", "Namespace for shared resources.")
flags.MarkDeprecated("openshift-namespace", "this field is no longer supported and using it can lead to undefined behavior")
Copy link
Contributor

Choose a reason for hiding this comment

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

We got rid of openshift-infra choice. I don't remember removing the shared namespace choice. If openshift-infra was changed, we simply created what needed to be. If they used a custom shared namespace, we cannot recreate that for them.

@smarterclayton its easier if we remove it, but I'm not sure about breaks. Opinion?

Copy link
Contributor

Choose a reason for hiding this comment

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

We got rid of openshift-infra choice. I don't remember removing the shared namespace choice. If openshift-infra was changed, we simply created what needed to be. If they used a custom shared namespace, we cannot recreate that for them.

@smarterclayton its easier if we remove it, but I'm not sure about breaks. Opinion?

Ansible doesn't allow it to be set. If a user changes it, I think its up to him to make sure all his roles are ready

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deprecate in 3.7 and remove in 3.8 seems reasonable to me. Removing it completely in 3.7 seems a bit sudden, but I have a feeling that no sane person ever messed with this so I can stomp on it if you really want.

Copy link
Contributor

Choose a reason for hiding this comment

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

Deprecate in 3.7 and remove in 3.8 seems reasonable to me. Removing it completely in 3.7 seems a bit sudden, but I have a feeling that no sane person ever messed with this so I can stomp on it if you really want.

@enj You already have removed it in this pull. You just don't realize that you have. It no longer functions as it used to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm yeah I killed the bootstrapping of it which is what matters.

namespaceRoleBindings := map[string][]rbac.RoleBinding{}

addNamespaceRole(namespaceRoles,
DefaultOpenShiftSharedResourcesNamespace,
Copy link
Contributor

Choose a reason for hiding this comment

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

It ripples down to here.

@@ -87,32 +89,6 @@ var (
legacyNetworkGroup = networkapi.LegacyGroupName
)

func GetBootstrapOpenshiftRoles(openshiftNamespace string) []rbac.Role {
Copy link
Contributor

Choose a reason for hiding this comment

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


func buildNamespaceRolesAndBindings() (map[string][]rbac.Role, map[string][]rbac.RoleBinding) {
// namespaceRoles is a map of namespace to slice of roles to create
namespaceRoles := map[string][]rbac.Role{}
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the private, global map upstream has.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer the approach that @liggitt started upstream with plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go, especially since it allows us to mutate the output easily.

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the approach that @liggitt started upstream with plugin/pkg/auth/authorizer/rbac/bootstrappolicy/controller_policy.go, especially since it allows us to mutate the output easily.

Letting you do something you shouldn't do isn't a point in its favor. Unbork the output and you can have it though.

for _, roles := range ret {
for i := range roles {
role := &roles[i]
addDefaultMetadata(role)
Copy link
Contributor

Choose a reason for hiding this comment

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

upstream adds it as they go and I think has a test to ensure everyone gets it.

creationTimestamp: null
labels:
kubernetes.io/bootstrapping: rbac-defaults
Copy link
Contributor

Choose a reason for hiding this comment

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

don't add this

@enj
Copy link
Contributor Author

enj commented Sep 26, 2017

@deads2k label removed. #16512 (review) ?

@openshift-merge-robot openshift-merge-robot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 26, 2017
"github.com/golang/glog"
)

func addNamespaceRole(namespaceRoles map[string][]rbac.Role, namespace string, role rbac.Role) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not seeing a use-case where these shouldn't be auto-reconciled. Add the annotation here.

for _, roles := range ret {
for i := range roles {
role := &roles[i]
addDefaultMetadata(role)
Copy link
Contributor

Choose a reason for hiding this comment

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

don't mutate the upstream roles.

@@ -1047,6 +1016,11 @@ func GetBootstrapClusterRoleBindings() []rbac.ClusterRoleBinding {
}
}

for i := range finalClusterRoleBindings {
roleBinding := &finalClusterRoleBindings[i]
addDefaultMetadata(roleBinding)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we mutating upstream roles.

@openshift openshift deleted a comment from enj Sep 26, 2017
// add default metadata only to openshift cluster roles
for i := range finalClusterRoles {
role := &finalClusterRoles[i]
addDefaultMetadata(role)
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this should be done when you're building the roles. What is the use-case for having GetOpenshiftBootstrapClusterRoles to be missing annotations?

// add default metadata only to openshift cluster role bindings
for i := range finalClusterRoleBindings {
roleBinding := &finalClusterRoleBindings[i]
addDefaultMetadata(roleBinding)
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the use-case for GetOpenshiftBootstrapClusterRoleBindings to be missing annotations?

func GetBootstrapNamespaceRoles() map[string][]rbac.Role {
// openshift and kube are guaranteed never to conflict on these
// the openshift map is safe to mutate unlike the kube one
ret := NamespaceRoles()
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the use-case for this to return roles missing annotations?

func GetBootstrapNamespaceRoleBindings() map[string][]rbac.RoleBinding {
// openshift and kube are guaranteed never to conflict on these
// the openshift map is safe to mutate unlike the kube one
ret := NamespaceRoleBindings()
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the use-case for this to be missing annotations?

This change brings in the upstream namespaced roles that are used by
controllers.  These will never conflict with the openshift ones
since they are required to be in namespaces prefixed with "kube-".

Signed-off-by: Monis Khan <[email protected]>
@enj
Copy link
Contributor Author

enj commented Sep 27, 2017

@deads2k

image

@deads2k
Copy link
Contributor

deads2k commented Sep 27, 2017

/retest
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 27, 2017
@openshift-merge-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, enj

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 27, 2017
@deads2k
Copy link
Contributor

deads2k commented Sep 27, 2017

test integration flaked. killing the rest to free our queue

@deads2k
Copy link
Contributor

deads2k commented Sep 27, 2017

/retest

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue

@openshift-merge-robot openshift-merge-robot merged commit 56bc677 into openshift:master Sep 27, 2017
jim-minter pushed a commit to jim-minter/origin that referenced this pull request Sep 28, 2017
…e catalog example template.

Upstream role was added in openshift#16517.
jim-minter pushed a commit to jim-minter/origin that referenced this pull request Sep 28, 2017
…e catalog example template.

Upstream role was added in openshift#16517.
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. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants