Skip to content

feat!: Add tls support for ingress#6986

Merged
knative-prow[bot] merged 48 commits intoknative:mainfrom
vishal-chdhry:tls-mt-broker-ingress
Jul 7, 2023
Merged

feat!: Add tls support for ingress#6986
knative-prow[bot] merged 48 commits intoknative:mainfrom
vishal-chdhry:tls-mt-broker-ingress

Conversation

@vishal-chdhry
Copy link
Contributor

Fixes #6876

Proposed Changes

  • 🎁 Add new feature
  • Adds TLS support for mt-broker-filter

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

Release Note


Docs

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@knative-prow
Copy link

knative-prow bot commented May 28, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 28, 2023
@knative-prow knative-prow bot requested review from aslom and matzew May 28, 2023 15:37
@codecov
Copy link

codecov bot commented May 28, 2023

Codecov Report

Patch coverage: 37.64% and project coverage change: -0.30 ⚠️

Comparison is base (2fe1db6) 78.59% compared to head (0faea53) 78.29%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6986      +/-   ##
==========================================
- Coverage   78.59%   78.29%   -0.30%     
==========================================
  Files         249      250       +1     
  Lines       13228    13291      +63     
==========================================
+ Hits        10396    10406      +10     
- Misses       2304     2353      +49     
- Partials      528      532       +4     
Impacted Files Coverage Δ
pkg/broker/ingress/server_manager.go 0.00% <0.00%> (ø)
pkg/broker/ingress/ingress_handler.go 60.09% <47.76%> (-10.15%) ⬇️

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

@vishal-chdhry
Copy link
Contributor Author

@pierDipi sorry for the delay on this, I have exams right now, I will be free by Friday evening

@pierDipi
Copy link
Member

pierDipi commented Jun 7, 2023

@pierDipi sorry for the delay on this, I have exams right now, I will be free by Friday evening

Good luck!

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@vishal-chdhry vishal-chdhry marked this pull request as ready for review June 13, 2023 16:42
@knative-prow knative-prow bot requested a review from odacremolbap June 13, 2023 16:42
@vishal-chdhry
Copy link
Contributor Author

/cc @pierDipi

@knative-prow knative-prow bot requested a review from pierDipi June 13, 2023 16:43
@vishal-chdhry
Copy link
Contributor Author

/cc @creydr @gabo1208

@knative-prow knative-prow bot requested review from creydr and gabo1208 June 13, 2023 16:43
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@vishal-chdhry vishal-chdhry changed the title [WIP] Added tls support for ingress Added tls support for ingress Jun 13, 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 Jun 13, 2023
@Cali0707
Copy link
Member

@vishal-chdhry could you look into the failing tests? It looks like at least some of them are failing due to changes you made

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
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.

Hey @vishal-chdhry,
thanks for your PR. I left a few comments. In addition: could you fix the lint issues and add an e2e test to verify the TLS functionality?

vishal-chdhry and others added 5 commits June 15, 2023 23:19
Co-authored-by: Christoph Stäbler <cstabler@redhat.com>
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
knative-automation and others added 7 commits July 6, 2023 22:26
Fix typo knative/community#1389 -pierDipi

Produced by: knative-sandbox/knobots/actions/update-community

Details:
```

```

Signed-off-by: Knative Automation <automation@knative.team>
When running MT components [1] in mesh mode with Istio, 
we lose the ability to define fine grained policies since we
don't know the resource namespace that originated such
request, therefore, by having a `Kn-Namespace` header, 
in mesh mode, users case define fine-grained policies and
isolate namespaces.

[1] IMC, MTChannelBasedBroker, and PingSource

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
As per title

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Manual update since there are a few braking chanages with
knative-extensions/reconciler-test#526

first commit upgrade deps and vendor, the rest fixes the issues.

---------

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Fixes knative#7028 
Looking at the logs, it seems like this test fails because it cannot
bind to the required port:
```
 === FAIL: pkg/adapter/mtping TestSendEventsTLS/Valid_CA_certs (unknown)
panic: listen tcp :8334: bind: address already in use
goroutine 226 [running]:
knative.dev/eventing/pkg/eventingtls/eventingtlstesting.StartServer.func1()
	/home/prow/go/src/knative.dev/eventing/pkg/eventingtls/eventingtlstesting/eventingtlstesting.go:77 +0x88
created by knative.dev/eventing/pkg/eventingtls/eventingtlstesting.StartServer
	/home/prow/go/src/knative.dev/eventing/pkg/eventingtls/eventingtlstesting/eventingtlstesting.go:74 +0x7ea 
```

<!-- 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
-->

- Update the test to bind to a free address, using port 0
(https://www.lifewire.com/port-0-in-tcp-and-udp-818145)


### 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

---------

Signed-off-by: Calum Murray <cmurray@redhat.com>
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@knative-prow knative-prow bot added area/test-and-release Test infrastructure, tests or release size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 6, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 6, 2023
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 6, 2023
Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@vishal-chdhry
Copy link
Contributor Author

@pierDipi Done!

}

return h.send(ctx, headers, event, channelAddress)
return h.send(ctx, headers, event, *channelAddress)
Copy link
Member

Choose a reason for hiding this comment

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

@vishal-chdhry could you take a look at the failing unit test?

=== FAIL: pkg/broker/ingress TestHandler_ServeHTTP/no_broker_annotations (0.00s)
=== FAIL: pkg/broker/ingress TestHandler_ServeHTTP (0.08s) panic: runtime error: invalid memory address or nil pointer dereference [recovered]

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x273574b]
goroutine 77 [running]:
testing.tRunner.func1.2({0x2959a80, 0x3f81f90})
/root/.gvm/gos/go1.20.4/src/testing/testing.go:1526 +0x372
testing.tRunner.func1()
/root/.gvm/gos/go1.20.4/src/testing/testing.go:1529 +0x650
panic({0x2959a80, 0x3f81f90})
/root/.gvm/gos/go1.20.4/src/runtime/panic.go:890 +0x263
knative.dev/eventing/pkg/broker/ingress.(*Handler).receive(0xc00058e8c0, {0x2fdf750, 0xc0006adb90}, 0xc000228e82?, 0xc00058e900, {0xc000154876, 0x2}, {0xc000154879, 0x4})
/home/prow/go/src/knative.dev/eventing/pkg/broker/ingress/ingress_handler.go:279 +0x8eb

It seems like the problem is on this line, and is probably from deferencing a nil channelAddress when there are no broker annotations. WDYT?

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 think this is because of the fact that we are not guessing the channel address anymore. I have updated the function to return an status code 400 with noDuration in this case: 0faea53 (#6986)

After guess channel address is removed, there is a case where no broker is found at all, updated test cases to account for that

Signed-off-by: Vishal Choudhary <sendtovishalchoudhary@gmail.com>
@vishal-chdhry vishal-chdhry requested a review from Cali0707 July 6, 2023 18:11
func getServerTLSConfig(ctx context.Context) (*tls.Config, error) {
secret := types.NamespacedName{
Namespace: "knative-eventing",
Name: "mt-broker-ingress-server-tls",
Copy link
Member

Choose a reason for hiding this comment

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

Nit: can we introduce a constant somewhere for this secret name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Cali0707 There are other secrets as well, such as the one for the filter.
Should we add constants for them in eventing-tls?

Maybe we should make a separate PR as I would like this PR to only contain ingress changes

Copy link
Member

Choose a reason for hiding this comment

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

Let's record an issue for this improvement

@vishal-chdhry vishal-chdhry changed the title Added tls support for ingress feat!: Add tls support for ingress Jul 7, 2023
Copy link
Member

@pierDipi pierDipi left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

func getServerTLSConfig(ctx context.Context) (*tls.Config, error) {
secret := types.NamespacedName{
Namespace: "knative-eventing",
Name: "mt-broker-ingress-server-tls",
Copy link
Member

Choose a reason for hiding this comment

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

Let's record an issue for this improvement

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jul 7, 2023
@knative-prow knative-prow bot merged commit 1e96c78 into knative:main Jul 7, 2023
@pierDipi
Copy link
Member

pierDipi commented Jul 7, 2023

Thanks!

@knative-prow
Copy link

knative-prow bot commented Jul 7, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pierDipi, Vishal-Chdhry

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:
  • OWNERS [Vishal-Chdhry,pierDipi]

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

knative-prow bot pushed a commit that referenced this pull request Jul 7, 2023
Follow up on
#6986 (comment):

Moved the tls secret names for mt-broker-ingress & mt-broker-filter into
constants
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/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eventing TLS: support creating TLS server for mt-broker-ingress