Skip to content

Commit

Permalink
update bootstrappolicy/dead addDeadClusterRole to include systemOnly …
Browse files Browse the repository at this point in the history
…annotation

Roles that have been replaced by kube controller roles should receive
the systemOnly annotation to ensure they are not visible to typical
end users (such as those who would use the web console).

- updates bootstrappolicy/dead addDeadClusterRole
- updates bootstrappolicy/web_console_role_test TestSystemOnlyRoles
	- still skips controller roles (maintenance simplicity), but will throw an error if the annotation is missing
  • Loading branch information
benjaminapetersen authored and liggitt committed Jul 18, 2017
1 parent 20e72f7 commit f2263f6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
7 changes: 6 additions & 1 deletion pkg/cmd/server/bootstrappolicy/dead.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ func addDeadClusterRole(name string) {

deadClusterRoles = append(deadClusterRoles,
authorizationapi.ClusterRole{
ObjectMeta: metav1.ObjectMeta{Name: name},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Annotations: map[string]string{
roleSystemOnly: roleIsSystemOnly,
},
},
},
)
}
Expand Down
9 changes: 6 additions & 3 deletions pkg/cmd/server/bootstrappolicy/web_console_role_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ func TestSystemOnlyRoles(t *testing.T) {

for _, role := range GetBootstrapClusterRoles() {
if isControllerRole(&role) {
continue // assume all controller roles can be ignored
if !isSystemOnlyRole(&role) {
t.Errorf("Controller role %q is missing the system only annotation", role.Name)
}
continue // assume all controller roles can be ignored even though we require the annotation
}
if isSystemOnlyRole(role) {
if isSystemOnlyRole(&role) {
hide.Insert(role.Name)
} else {
show.Insert(role.Name)
Expand All @@ -86,7 +89,7 @@ func TestSystemOnlyRoles(t *testing.T) {

// this logic must stay in sync w/the web console for this test to be valid/valuable
// it is the same logic that is run on the membership page
func isSystemOnlyRole(role authorizationapi.ClusterRole) bool {
func isSystemOnlyRole(role *authorizationapi.ClusterRole) bool {
return role.Annotations[roleSystemOnly] == roleIsSystemOnly
}

Expand Down
30 changes: 30 additions & 0 deletions test/testdata/bootstrappolicy/bootstrap_cluster_roles.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2838,90 +2838,120 @@ items:
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:replication-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:endpoint-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:replicaset-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:garbage-collector-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:job-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:hpa-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:daemonset-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:disruption-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:namespace-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:gc-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:certificate-signing-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:statefulset-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:build-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:deploymentconfig-controller
rules: []
- apiVersion: v1
kind: ClusterRole
metadata:
annotations:
authorization.openshift.io/system-only: "true"
creationTimestamp: null
name: system:deployment-controller
rules: []
Expand Down

0 comments on commit f2263f6

Please sign in to comment.