Bug 1382454 - Can not add custom role to group
Summary: Can not add custom role to group
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: apiserver-auth
Version: 3.3.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Jordan Liggitt
QA Contact: weiwei jiang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-10-06 18:06 UTC by Ian Tewksbury
Modified: 2016-10-30 22:55 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-10-06 19:52:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Ian Tewksbury 2016-10-06 18:06:01 UTC
Description of problem:

If a custom role is created it can not then be added to a group. An error message is returned.


Version-Release number of selected component (if applicable):


How reproducible:

100% of the time. Had multiple people reproduce on different OCP 3.2 and 3.3 clusters.


Steps to Reproduce:

> cat custom-role.json
{
    "kind": "Role",
    "apiVersion": "v1",
    "metadata": {
        "name": "template-editor"
    },
    "rules": [
        {
            "verbs": [
                "get",
                "list",
                "create",
                "update"
            ],
            "resources": [
                "templates"
            ]
        }
    ]
}
> oc create -f custom-role.json
> oadm policy add-role-to-group template-editor system:authenticated -n openshift
Error from server: role "template-editor" not found

Actual results:

Using the oadm to add the custom role failed.

Expected results:

The role should have been added.

Additional info:

A work around was found if the role binding is added via an oc create command.

> cat add-template-editor-to-authenticated.yml 
apiVersion: v1
groupNames:
- system:authenticated
kind: RoleBinding
metadata:
  name: template-editor
  namespace: openshift
roleRef:
  name: template-editor
  namespace: openshift
subjects:
- kind: SystemGroup
  name: system:authenticated
userNames: null
> oc create -f add-template-editor-to-authenticated.yml 
rolebinding "template-editor" created

Comment 2 Jordan Liggitt 2016-10-06 19:52:53 UTC
to grant a role defined within a namespace, use `... add-role-to-user ... --role-namespace=<namespace containing role>`

Comment 3 Ian Tewksbury 2016-10-06 20:10:02 UTC
Jordan,

Where is that in the doc?

~Ian

Comment 4 Jordan Liggitt 2016-10-06 20:11:08 UTC
$ oadm policy add-role-to-user --help

Add a role to users or serviceaccounts for the current project

Usage:
  oadm policy add-role-to-user ROLE (USER | -z SERVICEACCOUNT) [USER ...] [options]

Examples:
  # Add the 'view' role to user1 for the current project
  oadm policy add-role-to-user view user1

  # Add the 'edit' role to serviceaccount1 for the current project
  oadm policy add-role-to-user edit -z serviceaccount1

Options:
      --role-namespace='': namespace where the role is located: empty means a role defined in cluster policy
  -z, --serviceaccount=[]: service account in the current namespace to use as a user


Note You need to log in before you can comment on or make changes to this bug.