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

Setting different HTTP clients rountrippers leads to use the last set roundripper for every client #923

Open
pierDipi opened this issue Jul 18, 2023 · 1 comment

Comments

@pierDipi
Copy link
Member

pierDipi commented Jul 18, 2023

rt1 := // ... create rountripper 
p1 := http.New(http.WithRoundTripper(rt1))

rt2 := // ... create rountripper 
p2 := http.New(http.WithRoundTripper(rt2))

// unexpected:
// p1 has the same roundtripper rt2 as p2

This is caused by the use of the same underlying DefaultClient

if p.Client == nil {
p.Client = http.DefaultClient
}
if p.roundTripper != nil {
p.Client.Transport = p.roundTripper
}

This can also technically cause data races.

Workaround

Specify a different client for each Protocol using WithClient:

rt1 := // ... create rountripper 
p1 := http.New(http.WithClient(nethttp.Client{Transport: rt1}))

rt2 := // ... create rountripper 
p2 := http.New(http.WithClient(nethttp.Client{Transport: rt2}))
knative-prow bot pushed a commit to knative/eventing that referenced this issue Jul 20, 2023
Fixes #7021

This is the root cause: cloudevents/sdk-go#923

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

- Re-enable PingSource TLS E2E test
- Remove hacky client injection for PingSource

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

**Release Note**

<!--
📄 If this change has user-visible impact, write a release
note in the block
below. Include the string "action required" if additional action is
required of
users switching to the new release, for example in case of a breaking
change.

Write as if you are speaking to users, not other Knative contributors.
If this
change has no user-visible impact, no release note is needed.
-->

```release-note

```


**Docs**

<!--
📖 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>
pierDipi added a commit to pierDipi/eventing that referenced this issue Jul 25, 2023
Fixes knative#7021

This is the root cause: cloudevents/sdk-go#923

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

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

- Re-enable PingSource TLS E2E test
- Remove hacky client injection for PingSource

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

**Release Note**

<!--
📄 If this change has user-visible impact, write a release
note in the block
below. Include the string "action required" if additional action is
required of
users switching to the new release, for example in case of a breaking
change.

Write as if you are speaking to users, not other Knative contributors.
If this
change has no user-visible impact, no release note is needed.
-->

```release-note

```

**Docs**

<!--
📖 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>
openshift-merge-robot pushed a commit to openshift-knative/eventing that referenced this issue Jul 27, 2023
Fixes knative#7021

This is the root cause: cloudevents/sdk-go#923

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

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

- Re-enable PingSource TLS E2E test
- Remove hacky client injection for PingSource

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

**Release Note**

<!--
📄 If this change has user-visible impact, write a release
note in the block
below. Include the string "action required" if additional action is
required of
users switching to the new release, for example in case of a breaking
change.

Write as if you are speaking to users, not other Knative contributors.
If this
change has no user-visible impact, no release note is needed.
-->

```release-note

```

**Docs**

<!--
📖 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>
@embano1
Copy link
Member

embano1 commented Jul 28, 2023

@pierDipi thx for flagging this. Wondering if we can close this issue since you document a workaround?

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

No branches or pull requests

2 participants