Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
a674335c
Unverified
Commit
a674335c
authored
May 13, 2018
by
Jordan Liggitt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid copying aggregated admin/edit/view roles during bootstrap
parent
b617748f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
reconcile_role.go
pkg/registry/rbac/reconciliation/reconcile_role.go
+5
-0
reconcile_role_test.go
pkg/registry/rbac/reconciliation/reconcile_role_test.go
+26
-0
storage_rbac.go
pkg/registry/rbac/rest/storage_rbac.go
+4
-0
No files found.
pkg/registry/rbac/reconciliation/reconcile_role.go
View file @
a674335c
...
@@ -214,6 +214,11 @@ func computeReconciledRole(existing, expected RuleOwner, removeExtraPermissions
...
@@ -214,6 +214,11 @@ func computeReconciledRole(existing, expected RuleOwner, removeExtraPermissions
_
,
result
.
MissingAggregationRuleSelectors
=
aggregationRuleCovers
(
existing
.
GetAggregationRule
(),
expected
.
GetAggregationRule
())
_
,
result
.
MissingAggregationRuleSelectors
=
aggregationRuleCovers
(
existing
.
GetAggregationRule
(),
expected
.
GetAggregationRule
())
switch
{
switch
{
case
expected
.
GetAggregationRule
()
==
nil
&&
existing
.
GetAggregationRule
()
!=
nil
:
// we didn't expect this to be an aggregated role at all, remove the existing aggregation
result
.
Role
.
SetAggregationRule
(
nil
)
result
.
Operation
=
ReconcileUpdate
case
!
removeExtraPermissions
&&
len
(
result
.
MissingAggregationRuleSelectors
)
>
0
:
case
!
removeExtraPermissions
&&
len
(
result
.
MissingAggregationRuleSelectors
)
>
0
:
// add missing rules in the union case
// add missing rules in the union case
aggregationRule
:=
result
.
Role
.
GetAggregationRule
()
aggregationRule
:=
result
.
Role
.
GetAggregationRule
()
...
...
pkg/registry/rbac/reconciliation/reconcile_role_test.go
View file @
a674335c
...
@@ -350,6 +350,32 @@ func TestComputeReconciledRoleAggregationRules(t *testing.T) {
...
@@ -350,6 +350,32 @@ func TestComputeReconciledRoleAggregationRules(t *testing.T) {
expectedReconciledRole
:
aggregatedRole
(
aggregationrule
([]
map
[
string
]
string
{{
"alpha"
:
"bravo"
},
{
"foo"
:
"bar"
}})),
expectedReconciledRole
:
aggregatedRole
(
aggregationrule
([]
map
[
string
]
string
{{
"alpha"
:
"bravo"
},
{
"foo"
:
"bar"
}})),
expectedReconciliationNeeded
:
true
,
expectedReconciliationNeeded
:
true
,
},
},
"unexpected aggregation"
:
{
// desired role is not aggregated
expectedRole
:
role
(
rules
(
"pods"
,
"nodes"
,
"secrets"
),
nil
,
nil
),
// existing role is aggregated
actualRole
:
aggregatedRole
(
aggregationrule
([]
map
[
string
]
string
{{
"alpha"
:
"bravo"
}})),
removeExtraPermissions
:
false
,
// reconciled role should have desired permissions and not be aggregated
expectedReconciledRole
:
role
(
rules
(
"pods"
,
"nodes"
,
"secrets"
),
nil
,
nil
),
expectedReconciliationNeeded
:
true
,
},
"unexpected aggregation with differing permissions"
:
{
// desired role is not aggregated
expectedRole
:
role
(
rules
(
"pods"
,
"nodes"
,
"secrets"
),
nil
,
nil
),
// existing role is aggregated and has other permissions
actualRole
:
func
()
*
rbac
.
ClusterRole
{
r
:=
aggregatedRole
(
aggregationrule
([]
map
[
string
]
string
{{
"alpha"
:
"bravo"
}}))
r
.
Rules
=
rules
(
"deployments"
)
return
r
}(),
removeExtraPermissions
:
false
,
// reconciled role should have aggregation removed, preserve differing permissions, and include desired permissions
expectedReconciledRole
:
role
(
rules
(
"deployments"
,
"pods"
,
"nodes"
,
"secrets"
),
nil
,
nil
),
expectedReconciliationNeeded
:
true
,
},
}
}
for
k
,
tc
:=
range
tests
{
for
k
,
tc
:=
range
tests
{
...
...
pkg/registry/rbac/rest/storage_rbac.go
View file @
a674335c
...
@@ -320,6 +320,10 @@ func primeAggregatedClusterRoles(clusterRolesToAggregate map[string]string, clus
...
@@ -320,6 +320,10 @@ func primeAggregatedClusterRoles(clusterRolesToAggregate map[string]string, clus
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
if
existingRole
.
AggregationRule
!=
nil
{
// the old role already moved to an aggregated role, so there are no custom rules to migrate at this point
return
nil
}
glog
.
V
(
1
)
.
Infof
(
"migrating %v to %v"
,
existingRole
.
Name
,
newName
)
glog
.
V
(
1
)
.
Infof
(
"migrating %v to %v"
,
existingRole
.
Name
,
newName
)
existingRole
.
Name
=
newName
existingRole
.
Name
=
newName
existingRole
.
ResourceVersion
=
""
// clear this so the object can be created.
existingRole
.
ResourceVersion
=
""
// clear this so the object can be created.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment