Skip to content

Support TLS in Trigger and Channel reconciler#6988

Merged
knative-prow[bot] merged 17 commits intoknative:mainfrom
pierDipi:mt-broker-trigger-tls
Jun 5, 2023
Merged

Support TLS in Trigger and Channel reconciler#6988
knative-prow[bot] merged 17 commits intoknative:mainfrom
pierDipi:mt-broker-trigger-tls

Conversation

@pierDipi
Copy link
Member

@pierDipi pierDipi commented May 29, 2023

This is looking at making the control plane wiring and resolving for the
triggers Eventing TLS aware.

To support Eventing TLS in trigger reconciler, we need to make sure that
the underlying channel is properly propagating the Status and that the
subscription URI is set to the https endpoint when the TLS feature is
enabled (permissive or strict)

Individual commits might contain more details on the why of certain
changes.

Proposed Changes

  • Support TLS in Trigger reconciler
  • Set CA certs fields for channel, subscription, broker and trigger resources related to subscriber, reply and dead letter sink

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

pierDipi added 9 commits May 29, 2023 12:05
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
This will reduce and, at the same time, fix the direct access
to DeadLetterSinkURI field which is not correct in the TLS case.

Such wrong direct access assumes a certain structure of the DeliveryStatus
type increasing coupling between components.

Moving forward we can use:
- NewDeliveryStatusFromAddressable
- NewDestinationFromDeliveryStatus

that encapsulate the common pattern of:
- creating DeliveryStatus from an Addressable returned by the Resolver
- creating a Destination from a DeliveryStatus
  (for reconcilers that wiring other resources)

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 29, 2023
@knative-prow
Copy link

knative-prow bot commented May 29, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pierDipi

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

The pull request process is described here

Details 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

@knative-prow knative-prow bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 29, 2023
@knative-prow knative-prow bot requested review from aslom and evankanderson May 29, 2023 11:27
@knative-prow knative-prow bot added the area/test-and-release Test infrastructure, tests or release label May 29, 2023
pierDipi added 3 commits May 29, 2023 13:45
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Patch coverage: 77.67% and project coverage change: -0.11 ⚠️

Comparison is base (59118a0) 79.61% compared to head (e68bcaf) 79.51%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6988      +/-   ##
==========================================
- Coverage   79.61%   79.51%   -0.11%     
==========================================
  Files         246      246              
  Lines       12991    13070      +79     
==========================================
+ Hits        10343    10392      +49     
- Misses       2131     2159      +28     
- Partials      517      519       +2     
Impacted Files Coverage Δ
pkg/apis/duck/v1/delivery_types.go 73.07% <0.00%> (-21.93%) ⬇️
pkg/reconciler/channel/channel.go 70.00% <0.00%> (ø)
pkg/apis/messaging/v1/channel_lifecycle.go 81.03% <75.00%> (ø)
pkg/reconciler/broker/trigger/trigger.go 82.71% <79.06%> (-2.22%) ⬇️
...g/apis/messaging/v1/in_memory_channel_lifecycle.go 74.60% <87.50%> (ø)
pkg/apis/eventing/v1/broker_lifecycle.go 100.00% <100.00%> (ø)
pkg/apis/eventing/v1/test_helper.go 92.30% <100.00%> (ø)
pkg/reconciler/broker/broker.go 77.35% <100.00%> (-0.32%) ⬇️
pkg/reconciler/broker/controller.go 87.83% <100.00%> (+1.47%) ⬆️
pkg/reconciler/broker/resources/subscription.go 100.00% <100.00%> (ø)
... and 3 more

... and 16 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@pierDipi pierDipi self-assigned this May 29, 2023
@pierDipi pierDipi changed the title [WIP] Support TLS in Trigger reconciler Support TLS in Trigger reconciler May 31, 2023
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 31, 2023
@pierDipi pierDipi changed the title Support TLS in Trigger reconciler [WIP] Support TLS in Trigger reconciler May 31, 2023
@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 31, 2023
@pierDipi pierDipi changed the title [WIP] Support TLS in Trigger reconciler [WIP] Support TLS in Trigger and Channel reconciler May 31, 2023
pierDipi added 2 commits May 31, 2023 11:36
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@knative-prow knative-prow bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 31, 2023
@pierDipi
Copy link
Member Author

/test upgrade-tests

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi pierDipi changed the title [WIP] Support TLS in Trigger and Channel reconciler Support TLS in Trigger and Channel reconciler May 31, 2023
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 31, 2023
@pierDipi
Copy link
Member Author

/cc @creydr @vishal-chdhry

@knative-prow knative-prow bot requested review from creydr and vishal-chdhry May 31, 2023 12:38
@pierDipi
Copy link
Member Author

/test unit-tests

got := ets.GetTopLevelCondition().Status
if test.wantConditionStatus != got {
t.Errorf("unexpected readiness: want %v, got %v", test.wantConditionStatus, got)
t.Errorf("unexpected readiness: want %v, got %v\n%+v", test.wantConditionStatus, got, ets)
Copy link
Member

Choose a reason for hiding this comment

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

wanna apply to v1b2 as well?

Comment on lines +171 to +172
func (imcs *InMemoryChannelStatus) MarkDeadLetterSinkResolvedSucceeded(deadLetterSinkURI eventingduck.DeliveryStatus) {
imcs.DeliveryStatus = deadLetterSinkURI
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func (imcs *InMemoryChannelStatus) MarkDeadLetterSinkResolvedSucceeded(deadLetterSinkURI eventingduck.DeliveryStatus) {
imcs.DeliveryStatus = deadLetterSinkURI
func (imcs *InMemoryChannelStatus) MarkDeadLetterSinkResolvedSucceeded(deadLetterSink eventingduck.DeliveryStatus) {
imcs.DeliveryStatus = deadLetterSink


logging.FromContext(ctx).Debugw("Resolved deadLetterSink", zap.String("deadLetterSinkURI", deadLetterSinkURI.String()))
subscription.Status.PhysicalSubscription.DeadLetterSinkURI = deadLetterSinkURI
logging.FromContext(ctx).Debugw("Resolved deadLetterSink", zap.String("deadLetterSinkURI", deadLetterSinkAddr.URL.String()))
Copy link
Member

Choose a reason for hiding this comment

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

nit: WDYT about logging the whole DLS object (including the ca certs)? Just to have this information and it's on debug level anyhow...

Comment on lines 150 to 152
func WithChannelStatusDLSURI(dlsURI eventingduckv1.DeliveryStatus) ChannelOption {
return func(c *eventingv1.Channel) {
c.Status.MarkDeadLetterSinkResolvedSucceeded(dlsURI)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func WithChannelStatusDLSURI(dlsURI eventingduckv1.DeliveryStatus) ChannelOption {
return func(c *eventingv1.Channel) {
c.Status.MarkDeadLetterSinkResolvedSucceeded(dlsURI)
func WithChannelStatusDLSURI(dls eventingduckv1.DeliveryStatus) ChannelOption {
return func(c *eventingv1.Channel) {
c.Status.MarkDeadLetterSinkResolvedSucceeded(dls)

}

func WithInMemoryChannelStatusDLSURI(dlsURI *apis.URL) InMemoryChannelOption {
func WithInMemoryChannelStatusDLS(dlsURI *duckv1.Addressable) InMemoryChannelOption {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func WithInMemoryChannelStatusDLS(dlsURI *duckv1.Addressable) InMemoryChannelOption {
func WithInMemoryChannelStatusDLS(dls *duckv1.Addressable) InMemoryChannelOption {

Comment on lines +215 to +219
if dlsURI == nil {
imc.Status.MarkDeadLetterSinkNotConfigured()
return
}
imc.Status.MarkDeadLetterSinkResolvedSucceeded(eventingv1.NewDeliveryStatusFromAddressable(dlsURI))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if dlsURI == nil {
imc.Status.MarkDeadLetterSinkNotConfigured()
return
}
imc.Status.MarkDeadLetterSinkResolvedSucceeded(eventingv1.NewDeliveryStatusFromAddressable(dlsURI))
if dls == nil {
imc.Status.MarkDeadLetterSinkNotConfigured()
return
}
imc.Status.MarkDeadLetterSinkResolvedSucceeded(eventingv1.NewDeliveryStatusFromAddressable(dls))

}

func WithSubscriptionDeadLetterSinkURI(uri *apis.URL) SubscriptionOption {
func WithSubscriptionDeadLetterSinkURI(uri *duckv1.Addressable) SubscriptionOption {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we rename the function (and its parameters), as we don't take an URI anymore?

@creydr creydr mentioned this pull request May 31, 2023
5 tasks
pierDipi added 2 commits June 1, 2023 12:02
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
@pierDipi
Copy link
Member Author

pierDipi commented Jun 1, 2023

@matzew @creydr I think I covered your comments, PTAL

@pierDipi
Copy link
Member Author

pierDipi commented Jun 1, 2023

/test unit-tests

Copy link
Member

@creydr creydr left a comment

Choose a reason for hiding this comment

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

Looks good so far.

/lgtm

Putting it on hold, to give others a bit time to review too. Feel free to unhold when you're fine
/hold

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 1, 2023
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2023
@vishal-chdhry
Copy link
Contributor

/lgtm

@pierDipi
Copy link
Member Author

pierDipi commented Jun 5, 2023

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 5, 2023
@knative-prow knative-prow bot merged commit dfb2243 into knative:main Jun 5, 2023
vishal-chdhry pushed a commit to vishal-chdhry/eventing that referenced this pull request Jul 6, 2023
This is looking at making the control plane wiring and resolving for the
triggers Eventing TLS aware.

To support Eventing TLS in trigger reconciler, we need to make sure that
the underlying channel is properly propagating the Status and that the
subscription URI is set to the https endpoint when the TLS feature is
enabled (permissive or strict)

Individual commits might contain more details on the why of certain
changes.

<!-- Please include the 'why' behind your changes if no issue exists -->

## Proposed Changes

<!-- Please categorize your changes:
- 🎁 Add new feature
- 🐛 Fix bug
- 🧹 Update or clean up current behavior
- 🗑️ Remove feature or internal logic
-->

- Support TLS in Trigger reconciler
- Set CA certs fields for channel, subscription, broker and trigger
resources related to subscriber, reply and dead letter sink

### Pre-review Checklist

<!-- If these boxes are not checked, you will be asked to complete these
requirements or explain why they do not apply to your PR. -->

- [ ] **At least 80% unit test coverage**
- [ ] **E2E tests** for any new behavior
- [ ] **Docs PR** for any user-facing impact
- [ ] **Spec PR** for any new API feature
- [ ] **Conformance test** for any change to the spec
<!--
📖 If this change has user-visible impact, link to an issue or PR in
https://github.com/knative/docs.
-->

---------

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
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. area/test-and-release Test infrastructure, tests or release lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

No open projects
Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

4 participants