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

Upgrade azure-eventhub to input v2 API #39511

Merged
merged 19 commits into from
Jun 28, 2024

Conversation

zmoog
Copy link
Contributor

@zmoog zmoog commented May 10, 2024

Proposed commit message

Upgrade azure-eventhub to input v2 API.

The input v2 API provides better health status reporting and control. This is a preliminary step in introducing support for the modern Azure Event Hub SDK for Go.

Notes for reviewers

This PR aims to update the azure-eventhub input to the input v2 API without introducing behavior change. The PR is a stepping stone to #33815 (the PR is coming)

Here is a list of changes to keep in mind during the review.

The PR:

  • Renames the azureInput to eventHubInputV1 because I want to continue offering the legacy SDK while we introduce an eventHubInputV2 with the modern event hub SDK in the next PR. The eventHubInputManager will select the input version depending on the configuration.
  • Switches the pipeline publishing process from Outlet (input v1) to PipelineClient (input v2).
  • Starts the EPH and stops it when the input context is "done".
  • Rename parseMultipleMessages() to unpackRecords() because seems to better represent the behavior.

Keep existing behavior: Beats pipeline acks

It's important to note that the original input version did not handle publishing ACKs to the Beats pipeline. This was primarily because (AFAIK) the input API v1 did not provide this functionality.

With the transition to the input API v2, we have acks management. However, the legacy event hub SDK internally updates the checkpoint info after a successful handler call and does not seem to offer hooks to plug proper ACK management.

Since the new modern SDK offers better checkpoint management, in this PR, we keep the current behavior intact, and we'll implement ACKs in the event hub input v2.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Disruptive User Impact

Author's Checklist

  • Test reload configuration

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label May 10, 2024
@mergify mergify bot assigned zmoog May 10, 2024
Copy link
Contributor

mergify bot commented May 10, 2024

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @zmoog? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@zmoog zmoog changed the title Upgrade azure-eventhub to input v2 API [WIP] Upgrade azure-eventhub to input v2 API May 10, 2024
@zmoog zmoog added the Team:obs-ds-hosted-services Label for the Observability Hosted Services team label May 10, 2024
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label May 10, 2024
@zmoog zmoog force-pushed the zmoog/azure-eventhub-to-input-api-v2 branch 2 times, most recently from 025e137 to 62b90b3 Compare May 20, 2024 08:39
@zmoog zmoog changed the title [WIP] Upgrade azure-eventhub to input v2 API Upgrade azure-eventhub to input v2 API May 20, 2024
@zmoog zmoog marked this pull request as ready for review May 22, 2024 08:29
@zmoog zmoog requested review from a team as code owners May 22, 2024 08:29
@zmoog zmoog requested review from belimawr and leehinman May 22, 2024 08:29
@elasticmachine
Copy link
Collaborator

Pinging @elastic/obs-ds-hosted-services (Team:obs-ds-hosted-services)

@zmoog zmoog requested a review from faec May 22, 2024 09:39
Copy link
Contributor

@belimawr belimawr left a comment

Choose a reason for hiding this comment

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

I took a quick look at the InputV2 API part of the PR and it looks good. I just have a question about an empty file.

x-pack/filebeat/input/azureeventhub/v1_input_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

mergify bot commented May 24, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b zmoog/azure-eventhub-to-input-api-v2 upstream/zmoog/azure-eventhub-to-input-api-v2
git merge upstream/main
git push upstream zmoog/azure-eventhub-to-input-api-v2

@constanca-m
Copy link
Contributor

I cannot comment the lines you did not change, but is there reason to leave this?

https://github.com/zmoog/beats/blob/cc1d24512dad1a0d8f09055c12cb6e4d49c18ced/x-pack/filebeat/input/azureeventhub/metrics.go#L34

And again in the test:

https://github.com/zmoog/beats/blob/cc1d24512dad1a0d8f09055c12cb6e4d49c18ced/x-pack/filebeat/input/azureeventhub/metrics_test.go#L146

Is it even possible this condition to be true at all?

@@ -31,6 +32,7 @@ import (
func xpackInputs(info beat.Info, log *logp.Logger, store beater.StateStore) []v2.Plugin {
return []v2.Plugin{
azureblobstorage.Plugin(log, store),
azureeventhub.Plugin(log),
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit confused, what's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This registers azureeventhub (using the input plugin v2 API) and makes it available to Filebeat. Previous, the registration was happening using the old API:

func init() {
err := input.Register(inputName, NewInput)
if err != nil {
panic(fmt.Errorf("failed to register %v input: %w", inputName, err))
}
}

Without registration, the plugin is unknown to Filebeat.

Copy link
Contributor

mergify bot commented Jun 10, 2024

This pull request is now in conflicts. Could you fix it? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b zmoog/azure-eventhub-to-input-api-v2 upstream/zmoog/azure-eventhub-to-input-api-v2
git merge upstream/main
git push upstream zmoog/azure-eventhub-to-input-api-v2

@zmoog
Copy link
Contributor Author

zmoog commented Jun 10, 2024

I cannot comment the lines you did not change, but is there reason to leave this?

https://github.com/zmoog/beats/blob/cc1d24512dad1a0d8f09055c12cb6e4d49c18ced/x-pack/filebeat/input/azureeventhub/metrics.go#L34

And again in the test:

https://github.com/zmoog/beats/blob/cc1d24512dad1a0d8f09055c12cb6e4d49c18ced/x-pack/filebeat/input/azureeventhub/metrics_test.go#L146

Is it even possible this condition to be true at all?

Your question makes me think I don't fully understand how metrics.NewUniformSample(1024) works! 😄

Can you elaborate on this? Thanks!

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jun 11, 2024
@elasticmachine
Copy link
Collaborator

Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)

@constanca-m
Copy link
Contributor

Your question makes me think I don't fully understand how metrics.NewUniformSample(1024) works! 😄

Indeed, I went to have a look and I think I was confused when I wrote that comment.

I was reading the unit tests to understand the code at first and the TODO there got me a bit confused. From input.processEvents(&ev) I don't know if the condition can ever be untrue, but this is minor anyway.

Copy link
Member

@cmacknz cmacknz left a comment

Choose a reason for hiding this comment

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

Approving the go.mod changes

zmoog and others added 19 commits June 27, 2024 07:57
Switch from the v1 Outlet to the v2 PipelineClient
It seems we only need to wait for the context to be done here.
The existing input version does not handle publishing acks from the
Beats pipeline. The input API v1 does not seem to offer this feature.

With the transition to the input API v2, we have acks management.
However, the legacy event hub SDK internally updates the checkpoint
info after a successful handler call, and does not seem to offer hooks
for acks management.

Since the new modern SDK offers better checkpoint management, we keep
the current behavior intact, and we'll implement ACKs in the
event hub input v2.
@zmoog zmoog force-pushed the zmoog/azure-eventhub-to-input-api-v2 branch from cc1d245 to b0b04ee Compare June 27, 2024 15:07
@zmoog zmoog merged commit 68e2b8b into elastic:main Jun 28, 2024
121 checks passed
@zmoog zmoog deleted the zmoog/azure-eventhub-to-input-api-v2 branch June 28, 2024 05:12
zmoog added a commit that referenced this pull request Aug 26, 2024
Registers the `azure-eventhub` input on the Windows platform.

During the recent [upgrade](#39511) 
of the input from the Filebeat input API v1 to input API v2, I missed 
registering the input for the Windows platform in the 
`x-pack/filebeat/input/default-inputs/inputs_windows.go` file.
mergify bot pushed a commit that referenced this pull request Aug 26, 2024
Registers the `azure-eventhub` input on the Windows platform.

During the recent [upgrade](#39511)
of the input from the Filebeat input API v1 to input API v2, I missed
registering the input for the Windows platform in the
`x-pack/filebeat/input/default-inputs/inputs_windows.go` file.

(cherry picked from commit cc561ff)
zmoog added a commit that referenced this pull request Aug 26, 2024
Registers the `azure-eventhub` input on the Windows platform.

During the recent [upgrade](#39511)
of the input from the Filebeat input API v1 to input API v2, I missed
registering the input for the Windows platform in the
`x-pack/filebeat/input/default-inputs/inputs_windows.go` file.

(cherry picked from commit cc561ff)

Co-authored-by: Maurizio Branca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input:azure-eventhub Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team Team:obs-ds-hosted-services Label for the Observability Hosted Services team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Azure] Upgrade azure-eventhub to Input API v2
8 participants