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

Fix oc policy remove-user to remove rolebindings too #18550

Merged
merged 1 commit into from Feb 13, 2018

Conversation

simo5
Copy link
Contributor

@simo5 simo5 commented Feb 9, 2018

Followup to #18102

@openshift-ci-robot openshift-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 9, 2018
@simo5
Copy link
Contributor Author

simo5 commented Feb 9, 2018

@soltysh this was a missing piece in #18102, PTAL and LGTM if you are ok with it

@juanvallejo
Copy link
Contributor

@soltysh this lgtm

@runcom
Copy link
Member

runcom commented Feb 10, 2018

/test crio

@enj
Copy link
Contributor

enj commented Feb 11, 2018

Please fix #18102 (comment)

@@ -90,7 +91,7 @@ func TestPolicyCommands(t *testing.T) {
}

viewers, err = haroldAuthorizationClient.RoleBindings(projectName).Get("view", metav1.GetOptions{})
if err != nil {
if !errors.IsNotFound(err) {
Copy link
Contributor

Choose a reason for hiding this comment

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

A comment explaining this would be helpful.

if len(currBinding.Subjects) > 0 {
_, err = o.Client.RoleBindings(o.BindingNamespace).Update(&currBinding)
} else {
err = o.Client.RoleBindings(o.BindingNamespace).Delete(currBinding.Name, &metav1.DeleteOptions{})
Copy link
Contributor

@enj enj Feb 11, 2018

Choose a reason for hiding this comment

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

These delete options should include the UID as a precondition (same with the other delete added in the last PR).

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm it is actually UID + RV that we want here. @liggitt do we have a way to specify that via delete options?

Copy link
Contributor

Choose a reason for hiding this comment

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

Preconditions doesn't support resource version today... no particular reason it couldn't

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 do not see why we want either UID or RV, most of these commands are not "safe" that way and they do not look they are meant to be or can be.

Copy link
Contributor

Choose a reason for hiding this comment

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

Pinning uid and rv as preconditions would ensure you only deleted the object in its current state (another modification that added another subject would change the rv and make your delete fail on a conflict error, notifying you you were deleting data added by some other process)

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 know what UID and RV do, but no other command in oc adm policy does that fore removal, so I do not think it makes sense to try to shoehorn that in this PR, which is just a followup to fix stuff for 3.9
We can open an Issue to make all these commands "safer" under this aspect if we think it makes sense to do so.

Copy link
Contributor

Choose a reason for hiding this comment

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

no other command in oc adm policy does that fore removal

no other command injects data into found resources either

so I do not think it makes sense to try to shoehorn that in this PR

agree it isn't required for this PR

Followup to openshift#18102

Signed-off-by: Simo Sorce <simo@redhat.com>
@openshift-ci-robot openshift-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Feb 12, 2018
@simo5
Copy link
Contributor Author

simo5 commented Feb 12, 2018

Fixed the first 2 nits, not the last on the Delete() as I do not think we need that.
@enj PTAL

@@ -513,6 +513,12 @@ func (o *RoleModificationOptions) RemoveRole() error {
if err != nil {
return err
}
// Check that we update the rolebinding for the intended role.
if existingRoleBinding.RoleRef.Name != o.RoleName || existingRoleBinding.RoleRef.Namespace != o.RoleNamespace {
return fmt.Errorf("rolebinding %s contains role %s in namespace %s, instead of role %s in namespace %s",
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a test that fails when this case is hit, otherwise LGTM.

Copy link
Contributor Author

@simo5 simo5 Feb 12, 2018

Choose a reason for hiding this comment

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

Please open a separate issue with all the nits in the original code that you'd like fixed.
I want this PR to unblock QA for 3.9, if time will permit I'll bring down tech debt in a separate PR that closes your issue

@simo5
Copy link
Contributor Author

simo5 commented Feb 12, 2018

/test gcp

@enj
Copy link
Contributor

enj commented Feb 12, 2018

/lgtm

Opened #18582 #18583 as followups.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 12, 2018
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

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

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-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 12, 2018
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

lgtm as well

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue (batch tested with PRs 18437, 18546, 18550, 18579).

@openshift-merge-robot openshift-merge-robot merged commit b1dd578 into openshift:master Feb 13, 2018
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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants