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

Fix event dispatcher library data race #7280

Merged

Conversation

pierDipi
Copy link
Member

Clone the event since:

  • we mutate the event and the callers might not expect this
  • it might produce data races if the caller is trying to read the event in different go routines

Fixes #7193

Proposed Changes

  • Fix dispatcher data race

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: Pierangelo Di Pilato <[email protected]>
@knative-prow
Copy link

knative-prow bot commented Sep 22, 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

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 size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 22, 2023
@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

Patch coverage has no change and project coverage change: -0.03% ⚠️

Comparison is base (fa19118) 77.72% compared to head (3e9fc28) 77.70%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7280      +/-   ##
==========================================
- Coverage   77.72%   77.70%   -0.03%     
==========================================
  Files         247      247              
  Lines       13311    13315       +4     
==========================================
  Hits        10346    10346              
- Misses       2443     2447       +4     
  Partials      522      522              
Files Changed Coverage Δ
pkg/kncloudevents/event_dispatcher.go 62.23% <0.00%> (-0.89%) ⬇️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Sep 22, 2023
@knative-prow knative-prow bot merged commit 8447a36 into knative:main Sep 22, 2023
34 of 39 checks passed
pierDipi added a commit to pierDipi/eventing that referenced this pull request Jan 17, 2024
Fix dispatcher data race

Signed-off-by: Pierangelo Di Pilato <[email protected]>
openshift-merge-bot bot pushed a commit to openshift-knative/eventing that referenced this pull request Jan 17, 2024
* Remove deprecated httpclient msgsender (knative#7018)

## Proposed Changes
Removed the legacy http client go, message sender go and respective test
files, Since the functionality are handled in http client new and
message sender new go

Issue related : knative#6995
 
- 🗑️ Remove feature or internal logic

-
-
-

### Pre-review Checklist

- [x] **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**
 
```release-note

```


**Docs**
 
📖 knative#6995

---------

Co-authored-by: Christoph Stäbler <[email protected]>

* Refactor kncloudevents and add `SendEvent` function (knative#7092)

Adds a function (`SendEvent`) to the kncloudevents package to Send
events. This function:
* configures the client (e.g. for TLS)
* has option to send replies
* has option to send to a DLS
* has option to add additional transformers

This allows e.g. for use cases like the following:
```
kncloudevents.SendEvent(ctx, event, sub.Subscriber,
	kncloudevents.WithHeader(additionalHeaders),
	kncloudevents.WithReply(sub.Reply),
	kncloudevents.WithDeadLetterSink(sub.DeadLetter),
	kncloudevents.WithRetryConfig(sub.RetryConfig))
```

The `SendMessage` function is provided to make integration with existing
packages easier (e.g. in dependent projects).

Also migrated the usages of kncloudevents.NewCloudEventRequest() to the
new SendEvent() function (mt-broker-filter and mt-broker-ingress):
* 74c1552
* 9728713
* 958722d

* Remove deprecated kncloudevents.CloudEventsRequest (knative#7146)

* Remove kncloudevents.CloudEventsRequest

* Run hack/update-codegen.sh

* Add unit tests for generateBackoffFn()

* Fix event dispatcher library data race (knative#7280)

Fix dispatcher data race

Signed-off-by: Pierangelo Di Pilato <[email protected]>

---------

Signed-off-by: Pierangelo Di Pilato <[email protected]>
Co-authored-by: Jeevan <[email protected]>
Co-authored-by: Christoph Stäbler <[email protected]>
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. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pkg/inmemorychannel: TestDispatcher_dispatch data race
2 participants