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

TEP-0022: Switch to immutable input event bodies #828

Merged
merged 2 commits into from
Nov 18, 2020

Conversation

dibyom
Copy link
Member

@dibyom dibyom commented Nov 13, 2020

Changes

There are two commits in this PR:

  1. TEP-0022: Add interface to support event bodies

This commit adds two new types for InterceptorRequest and
InterceptorResponse. Instead of just forwarding the incoming request,
EventListeners will use these types to send requests to interceptors.

This commit introduces an extensions field where Interceptors can add
additional data that is available to TriggerBindings. This replaces the
previous mechanism where Interceptors could freely modify the input
bodies. With this change, the input bodies are immutable, and any extra
fields added by Interceptors can only be done within the extensions
field.

This commit simply adds the new interface types and plumbing. Future
commits will change the Interceptors to adopt the new Interface.

  1. Migrate CEL to new Interceptor Interface

This commit updates the CEL interceptor to use the new interface that supports
immutable input event bodies. This represents a BREAKING CHANGE for users using
overlays. Overlays will no longer modify the request body. Instead keys
from overlays will be added to a new top-level extensions field that is
accessible to TriggerBindings.

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

action required: If you are using `overlays` in the CEL Interceptor, please update your bindings to use $(extensions.<overlay-key>)  instead of $(body.<overlay-key>)

BREAKING CHANGE:
CEL overlays now add fields to a new top level `extensions` field instead of the modifying the incoming event body. TriggerBindings can access values within this new `extensions` field using `$(extensions.<key>)` syntax.

@tekton-robot tekton-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Nov 13, 2020
@tekton-robot tekton-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Nov 13, 2020
@dibyom dibyom force-pushed the tep-0022 branch 3 times, most recently from 71fba76 to 42173f5 Compare November 13, 2020 20:24
@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/interceptors/interceptors.go 82.4% 92.3% 10.0

@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/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 92.3% 10.0

@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/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 92.3% 10.0

@tekton-robot tekton-robot added release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. and removed release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Nov 13, 2020
@dibyom dibyom requested review from bigkevmcd, wlynch and khrm and removed request for bobcatfish and dlorenc November 13, 2020 20:57
@dibyom dibyom marked this pull request as ready for review November 13, 2020 20:57
@tekton-robot tekton-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 13, 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/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 92.3% 10.0

@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/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 94.7% 12.4

pkg/interceptors/cel/cel.go Outdated Show resolved Hide resolved
pkg/interceptors/cel/cel.go Outdated Show resolved Hide resolved
pkg/apis/triggers/v1alpha1/interceptor_types.go Outdated Show resolved Hide resolved
pkg/sink/sink.go Outdated Show resolved Hide resolved
@bigkevmcd
Copy link
Member

Looks good to me.

@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/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 94.7% 12.4

Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

Overall looking good!

pkg/apis/triggers/v1alpha1/interceptor_types.go Outdated Show resolved Hide resolved
pkg/apis/triggers/v1alpha1/interceptor_types.go Outdated Show resolved Hide resolved
pkg/interceptors/cel/cel.go Outdated Show resolved Hide resolved
pkg/interceptors/cel/cel.go Outdated Show resolved Hide resolved
pkg/sink/sink.go Outdated Show resolved Hide resolved
pkg/sink/sink.go Outdated Show resolved Hide resolved
if interceptorInterface, ok := interceptor.(triggersv1.InterceptorInterface); ok {
// Set per interceptor config params to the request
request.InterceptorParams = interceptors.GetInterceptorParams(i)
interceptorResponse = interceptorInterface.Process(context.Background(), &request)
Copy link
Member

Choose a reason for hiding this comment

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

We should add the context as a parameter so that we can accurately pass through timeouts and tracing information (if any).

Copy link
Member Author

Choose a reason for hiding this comment

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

ack. the only reason I did not do it here was because there was no existing context to plumb through. Was planning on adding it a follow up PR where we move the interceptors to run in a separate HTTP service. What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

sgtm

@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
cmd/triggerrun/cmd/root.go 45.5% 45.7% 0.2
pkg/apis/triggers/v1alpha1/interceptor_types.go Do not exist 100.0%
pkg/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 94.7% 12.4
pkg/sink/sink.go 83.3% 82.4% -0.9

This commit adds two new types for InterceptorRequest and
InterceptorResponse. Instead of just forwarding the incoming request,
EventListeners will use these types to send requests to interceptors.

This commit introduces an `extensions` field where Interceptors can add
additional data that is available to TriggerBindings. This replaces the
previous mechanism where Interceptors could freely modify the input
bodies. With this change, the input bodies are immutable, and any extra
fields added by Interceptors can only be done within the `extensions`
field.

This commit simply adds the new interface types and plumbing. Future
commits will change the Interceptors to adopt the new Interface.

Part of tektoncd#271 and tektoncd#778

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
@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
cmd/triggerrun/cmd/root.go 45.5% 45.7% 0.2
pkg/apis/triggers/v1alpha1/interceptor_types.go Do not exist 100.0%
pkg/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 94.7% 12.4
pkg/sink/sink.go 83.3% 83.1% -0.3

@dibyom dibyom force-pushed the tep-0022 branch 2 times, most recently from e96bacd to daacebf Compare November 18, 2020 01:32
@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
cmd/triggerrun/cmd/root.go 45.5% 45.7% 0.2
pkg/apis/triggers/v1alpha1/interceptor_types.go Do not exist 100.0%
pkg/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 94.7% 12.4
pkg/sink/sink.go 83.3% 83.9% 0.5

@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
cmd/triggerrun/cmd/root.go 45.5% 45.7% 0.2
pkg/apis/triggers/v1alpha1/interceptor_types.go Do not exist 100.0%
pkg/interceptors/cel/cel.go 89.2% 87.4% -1.8
pkg/interceptors/interceptors.go 82.4% 94.7% 12.4
pkg/sink/sink.go 83.3% 83.9% 0.5

This commit updates the CEL interceptor to use the new interface that supports
immutable input event bodies. This represents a BREAKING CHANGE for users using
`overlays`. Overlays will no longer modify the request body. Instead `keys`
from overlays will be added to a new top-level `extensions` field that is
accessible to TriggerBindings.

Part of tektoncd#271

Signed-off-by: Dibyo Mukherjee <dibyo@google.com>
@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
cmd/triggerrun/cmd/root.go 45.5% 45.7% 0.2
pkg/apis/triggers/v1alpha1/interceptor_types.go Do not exist 100.0%
pkg/interceptors/cel/cel.go 89.2% 88.5% -0.7
pkg/interceptors/interceptors.go 82.4% 94.7% 12.4
pkg/sink/sink.go 83.3% 83.9% 0.5

@dibyom dibyom requested a review from wlynch November 18, 2020 15:53
Copy link
Member

@wlynch wlynch left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 18, 2020
@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wlynch

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

The pull request process is described 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 18, 2020
@tekton-robot tekton-robot merged commit f1b26d3 into tektoncd:master Nov 18, 2020
@dibyom dibyom deleted the tep-0022 branch February 24, 2021 19:48
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. release-note-action-required Denotes a PR that introduces potentially breaking changes that require user action. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants