Skip to content

Update Azure Service Bus components to track2 SDK#1702

Merged
berndverst merged 26 commits into
dapr:masterfrom
ItalyPaleAle:service-bus-track2
May 13, 2022
Merged

Update Azure Service Bus components to track2 SDK#1702
berndverst merged 26 commits into
dapr:masterfrom
ItalyPaleAle:service-bus-track2

Conversation

@ItalyPaleAle

@ItalyPaleAle ItalyPaleAle commented May 4, 2022

Copy link
Copy Markdown
Contributor

Description

Move the Azure Service Bus components (binding and pubsub) to the new "track2" SDKs. Thanks a lot to @halspang for the initial work in #1648!

Thanks to the update and some refactoring work, two metadata keys for Azure Service Bus Pub/Sub are not needed anymore:

  • prefetchCount
  • maxActiveMessagesRecoveryInSec

Notes:

  1. Because the Service Bus SDKs depended on the newer version of azcore and azidentity, I had to update the other Azure SDKs that were already in "track2". Some of the updates contained breaking changes in the APIs, which I've fixed.
  2. This requires Go 1.18 so it depends on Updated to Go 1.18 #1697 (which depends on Use revive instead of golint #1685 itself)

Issue reference

Please reference the issue this PR will:
closes #1532
closes #1531
closes #1701

@ItalyPaleAle
ItalyPaleAle requested review from a team as code owners May 4, 2022 04:38
@ItalyPaleAle
ItalyPaleAle force-pushed the service-bus-track2 branch from cadd5ab to bbb776e Compare May 4, 2022 04:44
@@ -489,7 +487,6 @@ func (a *azureServiceBus) Subscribe(req pubsub.SubscribeRequest, handler pubsub.
attempts := readAttemptsStale()
if attempts == 0 {
a.logger.Errorf("Subscription to topic %s lost connection, unable to recover after %d attempts", sub.topic, a.metadata.MaxReconnectionAttempts)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is unchanged, but wondering if we should make the app crash here (Fatalf)? Otherwise, the error would get logged and the app continues to work but without a connection to Service Bus.

@ItalyPaleAle
ItalyPaleAle marked this pull request as draft May 4, 2022 05:52
@ItalyPaleAle ItalyPaleAle changed the title WIP: Update Azure Service Bus components to track2 SDK Update Azure Service Bus components to track2 SDK May 4, 2022
@ItalyPaleAle
ItalyPaleAle marked this pull request as ready for review May 6, 2022 20:51
}
}

func TestNewPubsubMessageFromAzServiceBusMessage(t *testing.T) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This test can't be implemented with track2 SDKs. The method to create these objects is un-exported.

Can be re-added if Azure/azure-sdk-for-go#17848 is merged

@ItalyPaleAle
ItalyPaleAle force-pushed the service-bus-track2 branch from fba3884 to 8d97718 Compare May 7, 2022 23:15
ItalyPaleAle and others added 9 commits May 7, 2022 16:16
Signed-off-by: Alessandro (Ale) Segala <[email protected]>
Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
Includes some minor refactoring of auth code

Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
Co-authored-by: halspang <[email protected]>
Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
)

* certification test for eventhubs binding

Signed-off-by: tanvigour <[email protected]>

* modified go.mod and go.sum

Signed-off-by: tanvigour <[email protected]>

* Add connection string testing

Signed-off-by: tanvigour <[email protected]>

* iothub testing

Signed-off-by: tanvigour <[email protected]>

* address feedback and run test

Signed-off-by: tanvigour <[email protected]>

* Install Azure CLI IOT hub extension

Signed-off-by: Bernd Verst <[email protected]>

* make modtidy-all

Signed-off-by: Bernd Verst <[email protected]>

* covering all eventhubs test cases

Signed-off-by: tanvigour <[email protected]>

* dependency changes after go modtidy-all

Signed-off-by: tanvigour <[email protected]>

Co-authored-by: Bernd Verst <[email protected]>
Co-authored-by: Yaron Schneider <[email protected]>
Co-authored-by: Looong Dai <[email protected]>
Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
Signed-off-by: pigletfly <[email protected]>

Co-authored-by: Yaron Schneider <[email protected]>
Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
* Updated to Go 1.18

Signed-off-by: Alessandro (Ale) Segala <[email protected]>

* Added go.work file
With Go 1.18, this allows gopls (the Go language server used for example in VS Code) to work inside test apps too.
See: https://go.dev/doc/tutorial/workspaces

Signed-off-by: ItalyPaleAle <[email protected]>

Signed-off-by: ItalyPaleAle <[email protected]>

* Removed go.work

Signed-off-by: ItalyPaleAle <[email protected]>

* 💄

Signed-off-by: ItalyPaleAle <[email protected]>

Co-authored-by: Bernd Verst <[email protected]>
Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
Signed-off-by: ItalyPaleAle <[email protected]>
Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
* Add metadata property to configure BatchingMaxSize&batchingMaxMessages in Pulsar
Signed-off-by: saberwang <[email protected]>

* sort field
Signed-off-by: saberwang <[email protected]>

* [pubsub]fix unit test bug
Signed-off-by: saberwang <[email protected]>

* remove unrelated changes
Signed-off-by: saberwang <[email protected]>

* Delete hard coded Metadata
Signed-off-by: saberwang <[email protected]>

* remove  .history

Signed-off-by: saberwang <[email protected]>

* restore .gitignore

Signed-off-by: saberwang <[email protected]>

* Hard coding default values and adding 'BatchingMaxPublishDelay' metadata

Signed-off-by: saberwang <[email protected]>

* fix code format

Signed-off-by: saberwang <[email protected]>

* formatting code

Signed-off-by: saberwang <[email protected]>

Co-authored-by: Looong Dai <[email protected]>
Co-authored-by: Bernd Verst <[email protected]>
Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
The methods to create a message with a body are not exported

Signed-off-by: Alessandro Segala (ItalyPaleAle) <[email protected]>
@ItalyPaleAle
ItalyPaleAle force-pushed the service-bus-track2 branch from 8d97718 to 957bb8d Compare May 7, 2022 23:16
@berndverst

Copy link
Copy Markdown
Member

/ok-to-test

@berndverst

Copy link
Copy Markdown
Member

@ItalyPaleAle please fix linter issues. Also use /ok-to-test to trigger actions for conformance and certification tests (separately from this PR) to run the Service Bus Queues binding certification test.

This greatly simplifies certain parts of the code, reducing the number of goroutines and likely improving performance.
Performance for end-users improves too as there's no need anymore to pause for 2 seconds every time that we reach `maxActiveMessages`.
Additionally, with this change the config options `prefetchCount` and `maxActiveMessagesRecoveryInSec` are removed as unnecessary anymore.

Signed-off-by: ItalyPaleAle <[email protected]>
@berndverst

Copy link
Copy Markdown
Member

At the moment this breaks EventHubs Binding, PubSub and Service Bus Queues Binding.

Please take a look by running the certification and conformance tests via /ok-to-test

@ItalyPaleAle

Copy link
Copy Markdown
Contributor Author

/ok-to-test

@ItalyPaleAle

ItalyPaleAle commented May 13, 2022

Copy link
Copy Markdown
Contributor Author

@berndverst This is ready for review IMHO.

  • All tests are passing (waiting for the conformance tests to complete)
  • I have confirmed that both the binding and pubsub are able to recover successfully in case of failures (both pubsub and input/output bindings)

Once this is merged, I'll need to update the docs because of metadata changes, as well as our E2E tests if needed.

@berndverst

Copy link
Copy Markdown
Member

Eventhubs Binding conformance test is failing
Eventhubs Binding certification test is failing
Service Bus Queues Binding certification test is failing

(you can see in the results of your /ok-to-test run)

@berndverst berndverst added the do-not-merge PR is not ready for merging label May 13, 2022
Signed-off-by: ItalyPaleAle <[email protected]>
@ItalyPaleAle

Copy link
Copy Markdown
Contributor Author

/ok-to-test

@ItalyPaleAle

Copy link
Copy Markdown
Contributor Author

I'll look into the Service Bus binding failure tomorrow.

For Event Hubs, that's very odd because I did not touch that module besides for a minimal change that was required. However, it looked like the SDK got upgraded (which was un-intentional). I've reverted the change to the SDK and let's see if that fixes the tests.

In case of a failure in the handler (ie. users' code), the message should be correctly re-enqueued, which means that messages will be re-delivered later and won't be in order.

Signed-off-by: ItalyPaleAle <[email protected]>
@ItalyPaleAle

ItalyPaleAle commented May 13, 2022

Copy link
Copy Markdown
Contributor Author

@berndverst I have fixed all tests that were failing because of changes in my code.

After fixing dependencies, there were 2 tests that fail.

  • Service Bus Queue binding: when a message fails to be processed by a handler, it's inserted back into the queue. This means that it's re-delivered later, so it may not come in order. However the conf tests were expecting messages to be in order. I think this was a problem with the tests as the re-enqueueing of the message is arguably the desired behavior
  • Event Hubs binding: this is still failing and it looks like it was failing before 100% of the times when running on master. See: https://github.com/dapr/components-contrib/actions/workflows/certification.yml The error in this PR is the same. The test is broken and needs to be fixed, but it should not block this PR.

(On why the Event Hubs test is failing: the test TestAzureServiceBusQueueRetriesOnError is creating 2 Event Hubs listeners with the same consumer group, which seems to be disallowed)

Test runs:
https://github.com/dapr/components-contrib/actions/runs/2321897134
https://github.com/dapr/components-contrib/actions/runs/2321897110

@codecov

codecov Bot commented May 13, 2022

Copy link
Copy Markdown

Codecov Report

Merging #1702 (c8c39e7) into master (bfd87eb) will decrease coverage by 0.12%.
The diff coverage is 28.57%.

@@            Coverage Diff             @@
##           master    #1702      +/-   ##
==========================================
- Coverage   36.37%   36.24%   -0.13%     
==========================================
  Files         166      173       +7     
  Lines       15488    15557      +69     
==========================================
+ Hits         5633     5639       +6     
- Misses       9228     9287      +59     
- Partials      627      631       +4     
Impacted Files Coverage Δ
authentication/azure/auth.go 38.12% <0.00%> (-1.77%) ⬇️
authentication/azure/auth_amqp.go 0.00% <0.00%> (ø)
bindings/azure/cosmosdb/cosmosdb.go 18.00% <ø> (ø)
bindings/azure/eventhubs/eventhubs.go 14.79% <0.00%> (ø)
bindings/cron/cron.go 87.23% <ø> (ø)
bindings/http/http.go 87.87% <ø> (ø)
bindings/kubernetes/kubernetes.go 17.14% <ø> (ø)
bindings/localstorage/localstorage.go 4.95% <0.00%> (-0.17%) ⬇️
internal/component/kafka/consumer.go 0.00% <0.00%> (ø)
internal/component/kafka/kafka.go 0.00% <0.00%> (ø)
... and 28 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 785ed60...c8c39e7. Read the comment docs.

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

Successfully merging this pull request may close these issues.

[Azure][Track 2 SDK] Migrate Azure Service Bus PubSub [Azure][Track 2 SDK] Migrate Azure Service Bus Queues Binding

5 participants