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

if eventlistenertrigger sa not set, assume user means default sa #836

Closed

Conversation

gabemontero
Copy link
Contributor

Changes

/hold

A POC experiment related to #77 and mult-tenant event listeners

@dibyom @khrm @vdemeester FYI

First, I'm curious what breaks and what does not today when we take the "optional" nature of the ELT SA ref toward
always relevant, in that if they don't set it, we do the same thing k8s does with Pods, and assigns the default SA to the Pod.

Today, we end up using the EL's SA and its permissions when executing the trigger if this ELT SA is not set.

When multi-tenant event listeners become a full reality, the permission ramifications if any increase, as the multi tenant EL, presumably with enough permissions to operator on triggers with any of the namespaces it manages, come into play and only increases the potential enhanced and escalated permission flaw.

And thus, the need for making the ELT SA minimally explicit (i.e. we use default if not set) or required (they user has to put a valid sa ref) is more vital in the multi-tenant event listener case.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Release Notes

@tekton-robot tekton-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Nov 20, 2020
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign dibyom
You can assign the PR to them by writing /assign @dibyom in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 20, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/sink.go 78.9% 79.3% 0.4

@gabemontero
Copy link
Contributor Author

fyi even some unit tests failed ... I left them as is to help asses the total scope of change that would be required for changing behavior in this way

@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/sink.go 78.9% 82.1% 3.2

@gabemontero
Copy link
Contributor Author

So aside from the unit tests, only the one e2e I was sure would fail (since that is where I had to add the granular auth via impersonation stuff), TestEventListenerCreate actually failed.

though iirc and read the test output correctly, I do no think the integration run cycles through the examples at https://github.com/tektoncd/triggers/tree/master/examples

I would suspect failures in that set as well with this change, where set up would need to be changes to add requisite role bindings to the default SA in the associated namespace(s).

But I'll leave it at that and see what everyone's reactions are.

Note, I'll be on PTO all of Thanksgiving week next week, but should be able to check out comments afterward, as well as attend subsequent WG meetings.

@tekton-robot tekton-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 Nov 20, 2020
@tekton-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-tekton-triggers-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/sink/sink.go 78.9% 82.4% 3.6

@gabemontero
Copy link
Contributor Author

gabemontero commented Nov 20, 2020

I lied ... one more consideration ;-)

The same approach could be applied at the trigger SA as well. Essentially force it to the default SA instead of using the Sink's dynamic client (i.e. the SA associated with the sink).

separate commit pushed.

I now think the "defaulting" makes more sense at the trigger level than the eventlistenertrigger level, as that is where the "multi-tenant" dividing line will fall, if I recall the TEP correctly, but we can sort that out either in discussion here on in the next WG I can attend.

@tekton-robot
Copy link

@gabemontero: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-tekton-triggers-unit-tests 7e3d842 link /test tekton-triggers-unit-tests
pull-tekton-triggers-integration-tests 7e3d842 link /test pull-tekton-triggers-integration-tests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

1 similar comment
@tekton-robot
Copy link

@gabemontero: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-tekton-triggers-unit-tests 7e3d842 link /test tekton-triggers-unit-tests
pull-tekton-triggers-integration-tests 7e3d842 link /test pull-tekton-triggers-integration-tests

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@@ -173,6 +173,12 @@ func (r Sink) HandleEvent(response http.ResponseWriter, request *http.Request) {
func (r Sink) merge(et []triggersv1.EventListenerTrigger, trItems []*triggersv1.Trigger) ([]*triggersv1.Trigger, error) {
triggers := trItems
for _, t := range et {
// if ELT serviceAccountName not set, take that as assuming the user if fine with using the default SA;
// but no longer allow the EventListener SA and its permissions to influence what can be created
serviceAccountName := "default"
Copy link
Member

Choose a reason for hiding this comment

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

Curious - alternatively, instead of explicitly setting default SA, do you think it would also work to conditionally set TriggerSpec.serviceaccount based on presence of t.ServiceAccountName after 201, so we could leave it blank when omitted? Would that would achieve the same result, since the SA would default to default?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not exactly @iancoffey .... the intent on always setting it explicitly here is so that the event listener sink's use of k8s impersonation kicks in, and as a result, any subsequent creation of objects are from the start done using permissions OTHER than the permissions of the event listener sink.

@gabemontero
Copy link
Contributor Author

closing this experiment out for now ... may revisit as other features reach more maturation ... see #77 (comment)

@gabemontero gabemontero closed this Dec 2, 2020
@gabemontero gabemontero deleted the explicit-default-sa-default branch December 2, 2020 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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

3 participants