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

RBAC Support for Actions #2110

Merged
merged 23 commits into from
Oct 4, 2019
Merged

RBAC Support for Actions #2110

merged 23 commits into from
Oct 4, 2019

Conversation

simster7
Copy link
Member

@simster7 simster7 commented Aug 6, 2019

See #2002

@codecov
Copy link

codecov bot commented Aug 6, 2019

Codecov Report

Merging #2110 into master will decrease coverage by 0.27%.
The diff coverage is 16.32%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2110      +/-   ##
==========================================
- Coverage   38.53%   38.25%   -0.28%     
==========================================
  Files         103      103              
  Lines       14732    14547     -185     
==========================================
- Hits         5677     5565     -112     
+ Misses       8294     8239      -55     
+ Partials      761      743      -18
Impacted Files Coverage Δ
server/rbacpolicy/rbacpolicy.go 79.68% <ø> (ø) ⬆️
pkg/apis/application/v1alpha1/types.go 59.24% <ø> (ø) ⬆️
cmd/argocd/commands/app.go 1.81% <0%> (ø) ⬆️
server/application/application.go 25.19% <0%> (+0.09%) ⬆️
cmd/argocd/commands/app_actions.go 0% <0%> (ø) ⬆️
util/lua/lua.go 76.75% <72.72%> (-0.31%) ⬇️
util/ksonnet/ksonnet.go 34.61% <0%> (-8.79%) ⬇️
util/helm/helm.go 66.07% <0%> (-7.05%) ⬇️
util/kube/ctl.go 19.9% <0%> (-4.68%) ⬇️
util/kustomize/kustomize.go 71.84% <0%> (-3.84%) ⬇️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b502555...81dcae8. Read the comment docs.

@alexec alexec added this to the v1.3 milestone Aug 6, 2019
@alexec
Copy link
Contributor

alexec commented Aug 7, 2019

CI failure looks unrelated to change. Re-building.

@alexec alexec self-assigned this Aug 7, 2019
@evrardjp
Copy link
Contributor

evrardjp commented Aug 10, 2019

Not sure which tests are running, but it seems there is an error in build just after a git diff showing a spacing issue

-	ActionAction = "action"
+	ActionAction   = "action"

@simster7
Copy link
Member Author

Thanks @evrardjp. Seems current failure is due to unrelated tests? @alexec

@alexec
Copy link
Contributor

alexec commented Aug 12, 2019

The failed test is known flaky.

@simster7
Copy link
Member Author

Perfect. @jessesuen should be ready to merge

@alexec alexec removed their assignment Aug 14, 2019
Copy link
Member

@jessesuen jessesuen left a comment

Choose a reason for hiding this comment

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

There is a UI change to this which is not captured here.

@@ -1093,7 +1093,8 @@ func (s *Server) RunResourceAction(ctx context.Context, q *application.ResourceA
Version: q.Version,
Group: q.Group,
}
res, config, _, err := s.getAppResource(ctx, rbacpolicy.ActionOverride, resourceRequest)
actionRequest := fmt.Sprintf("%s/%s", rbacpolicy.ActionAction, q.Action)
res, config, _, err := s.getAppResource(ctx, actionRequest, resourceRequest)
Copy link
Member

Choose a reason for hiding this comment

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

Thinking about this more, action/<actionname> is not specific enough. We may have the same action name "pause", which works for both a Deployment, Rollout, and CronJob object. Granting "pause" privileges to all object types is potentially undesirable. We need a convention for actions which reflect the finer grained rbac. For example:

action/argoproj.io/Rollout/resume

Copy link
Member Author

Choose a reason for hiding this comment

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

Responded in #2181

Copy link
Member

Choose a reason for hiding this comment

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

As I understand, the convention being introduced is action/argoproj.io/Rollout:resume instead of action/argoproj.io/Rollout/resume. I feel the slash is more consistent with all our other RBAC as opposed to the colon.

For example, rbac rules may be:
action/argoproj.io/Rollout/*

Which seems better than:
action/argoproj.io/Rollout:*

@jessesuen
Copy link
Member

jessesuen commented Aug 21, 2019

For the UI to understand and present the available actions. We need to implement action discovery better, as described in item (1) in #2181

@simster7
Copy link
Member Author

@jessesuen @alexec Sorry for the crazy delay, but points 1 and 2 from Jesse's issue (#2110) are now done. I intend to open a separate PR for the UI changes. A few points:

  1. The new syntax for actions is group/kind:actionName. Because of this, I have removed the group and kind parameters in argocd app actions run as they are now a part of the action name. Therefore, this is currently a breaking change as the call
argocd app actions run APPNAME resume --kind Rollout

is no longer supported and instead must be

argocd app actions run APPNAME argoproj.io/Rollout:resume

Not sure how to approach this, should I allow backwards compatibility with resume commands?

  1. argocd app actions list APPNAME now lists all actions across all resources by default and shows if they are available:
$ argocd app actions list blue-green

GROUP        KIND     NAME                       ACTION                      AVAILABLE
argoproj.io  Rollout  blue-green-helm-guestbook  argoproj.io/Rollout:resume  true
  1. Running an action no longer checks if it is available or not.

@alexec alexec requested a review from jessesuen September 20, 2019 22:26
Copy link
Member

@jessesuen jessesuen left a comment

Choose a reason for hiding this comment

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

Very close to what I was looking for. Great job.

pkg/apis/application/v1alpha1/types.go Outdated Show resolved Hide resolved
if len(groupKindSplit) != 2 {
log.Fatal("Action name is malformed")
}
return groupKindSplit[0], groupKindSplit[1], actionName
Copy link
Member

Choose a reason for hiding this comment

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

It appears we are making breaking changes here by requiring a new convention for running actions. I think it's okay if we start introducing a new convention, but we may need to preserve previous flags for backwards compatibility since many pipelines are depending on this behavior.

Copy link
Member Author

Choose a reason for hiding this comment

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

Introduced backwards compatibility with the following message:

$ argocd app actions run blue-green resume --kind Rollout

Warning: "resume" action has been deprecated. Please run the action as

	argocd app run blue-green argoproj.io/Rollout/resume

server/application/application.go Show resolved Hide resolved
@@ -1093,7 +1093,8 @@ func (s *Server) RunResourceAction(ctx context.Context, q *application.ResourceA
Version: q.Version,
Group: q.Group,
}
res, config, _, err := s.getAppResource(ctx, rbacpolicy.ActionOverride, resourceRequest)
actionRequest := fmt.Sprintf("%s/%s", rbacpolicy.ActionAction, q.Action)
res, config, _, err := s.getAppResource(ctx, actionRequest, resourceRequest)
Copy link
Member

Choose a reason for hiding this comment

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

As I understand, the convention being introduced is action/argoproj.io/Rollout:resume instead of action/argoproj.io/Rollout/resume. I feel the slash is more consistent with all our other RBAC as opposed to the colon.

For example, rbac rules may be:
action/argoproj.io/Rollout/*

Which seems better than:
action/argoproj.io/Rollout:*

@jessesuen
Copy link
Member

jessesuen commented Sep 21, 2019

My review comments above were made without first reading comment #2110 (comment). But yes, I am glad you recognized the breaking change.

is no longer supported and instead must be argocd app actions run APPNAME argoproj.io/Rollout:resume

How does this work when a user wants to run it against a specific rollout by name?

@simster7
Copy link
Member Author

@jessesuen Addressed all of your comments.

How does this work when a user wants to run it against a specific rollout by name?

There is a --resource-name argument available

@alexec alexec requested a review from jessesuen September 23, 2019 17:57
Copy link
Member

@jessesuen jessesuen left a comment

Choose a reason for hiding this comment

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

Conditional approval: there's one place where we still use the colon, but otherwise this LGTM. Please fix the last statement.

server/application/application.go Outdated Show resolved Hide resolved
@simster7
Copy link
Member Author

simster7 commented Oct 3, 2019

@alexec @jessesuen This should also be good to go!

@alexec
Copy link
Contributor

alexec commented Oct 3, 2019

@jessesuen do you want to merge please?

@jessesuen jessesuen merged commit dd21ab9 into argoproj:master Oct 4, 2019
@alexec
Copy link
Contributor

alexec commented Oct 7, 2019

Yay!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants