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

[azure-eventhub input] Switch the run EPH run mode to non-blocking #34075

Merged

Conversation

zmoog
Copy link
Contributor

@zmoog zmoog commented Dec 19, 2022

What does this PR do?

Update the azure-eventhub input to switch the run mode of the Event Processor Host (EPH) from blocking to non-blocking.

With the changes in the PR, the first call to the input Start() method will set up and start the EPH worker in a non-blocking fashion. The EPH worker will continue until the Filebeat calls the Stop() method to tear it down for live reloading.

Why is it important?

Since 8.3.3, the input Runner changed its behavior during the live reload:

  • < 8.3.3: the input Runner stops the old input and starts a new input without waiting for the stop to complete.
  • >= 8.3.3: the input Runner stops the old input and waits for the Stop() method to complete before starting a new one.

Unfortunately, if we run Start() with EPH in a blocking mode, the method will not return because it will continue waiting for an os.Signal that will never come.

If the EPH's Start() method does not end, the EPH sync.WaitGroup will continue waiting forever.

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.

How to test this PR locally

1. Enable live reload

Edit the filebeat.yml file and update the "Filebeat modules" like this one:

# ============================== Filebeat modules ==============================

filebeat.config.modules:
  # Glob pattern for configuration loading
  path: ${path.config}/modules.d/*.yml

  # Set to true to enable config reloading
  # reload.enabled: false
  reload.enabled: true

  # Period on which files under path should be checked for changes
  #reload.period: 10s
  reload.period: 10s

# ======================= Elasticsearch template setting =======================

2. Enable the azure module

Copy the azure.yml.disabled file into azure.yml and set up one of the existing inputs.

For example:

  platformlogs:
    enabled: true
    var:
      # adding a new line
      eventhub: "platformlogs"
      consumer_group: "$Default"
      connection_string: "Endpoint=sb://....="
      storage_account: ""
      storage_account_key: ""
      tags:
        - "azure"
        - "whatever4"

3. Testing

Start Filebeat and make sure the platform logs are created in Elasticsearch.

Make some changes to the azure.yml. For example, try to add/remove/change the tags and within 10 seconds Filebeat will trigger a configuration reload.

Related issues

@zmoog zmoog added bug Team:Cloud-Monitoring Label for the Cloud Monitoring team labels Dec 19, 2022
@zmoog zmoog self-assigned this Dec 19, 2022
@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Dec 19, 2022
@mergify
Copy link
Contributor

mergify bot commented Dec 19, 2022

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 added backport-v8.4.0 Automated backport with mergify backport-v8.5.0 Automated backport with mergify backport-v8.6.0 Automated backport with mergify labels Dec 19, 2022
@zmoog zmoog changed the title [Azure] Swich azureeventhub input to non blocking [Azure] Switch the run EPH run mode to non-blocking Dec 19, 2022
@zmoog zmoog changed the title [Azure] Switch the run EPH run mode to non-blocking [azure-eventhub input] Switch the run EPH run mode to non-blocking Dec 19, 2022
@zmoog zmoog force-pushed the zmoog/swich-azureeventhub-input-to-non-blocking branch from 7bbe6a3 to 668edc5 Compare December 19, 2022 17:18
@elasticmachine
Copy link
Collaborator

elasticmachine commented Dec 19, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-12-21T10:25:38.835+0000

  • Duration: 79 min 27 sec

Test stats 🧪

Test Results
Failed 0
Passed 7384
Skipped 338
Total 7722

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@zmoog zmoog requested a review from a team December 19, 2022 19:02
@zmoog zmoog marked this pull request as ready for review December 20, 2022 09:46
@zmoog zmoog requested a review from a team as a code owner December 20, 2022 09:46
@zmoog zmoog requested review from belimawr and leehinman and removed request for a team December 20, 2022 09:46
@zmoog zmoog force-pushed the zmoog/swich-azureeventhub-input-to-non-blocking branch from 021502b to 02ea2b1 Compare December 20, 2022 09:51
@zmoog
Copy link
Contributor Author

zmoog commented Dec 21, 2022

/test

@zmoog zmoog force-pushed the zmoog/swich-azureeventhub-input-to-non-blocking branch from 02ea2b1 to 510eae6 Compare December 21, 2022 07:38
SonarQube thinks fixing this duplicated code it’s on me, even if I did
not change this file in the PR ¯\_(ツ)_/¯
@zmoog zmoog force-pushed the zmoog/swich-azureeventhub-input-to-non-blocking branch from a4a972c to cbfe35c Compare December 21, 2022 10:25
Copy link
Member

@endorama endorama left a comment

Choose a reason for hiding this comment

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

I did not test data forwarding to Elasticsearch but I tested autoreloading configuration (played with platformlogs configs).

At each save the new content was picked up and used to configure the input, with restarts in appropriate cases. I can confirm the stop/start sequence is run:

[...] Starting reload procedure, current runners: 1 [...]
[...] Start list: 1, Stop list: 1 [...]
[...] Stopping runner: azure (platformlogs) [...]
[...] azure-eventhub input worker has started. [...]

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.0% 0.0% Duplication

@ruflin
Copy link
Contributor

ruflin commented Dec 21, 2022

@belimawr Can you please have a look at this as the change in 8.3.3 was made by you: #32309

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.

LGTM.

That's my first contact with azure-eventhub, but looks good.

@zmoog zmoog merged commit 8f0db84 into elastic:main Dec 22, 2022
@zmoog zmoog deleted the zmoog/swich-azureeventhub-input-to-non-blocking branch December 22, 2022 14:27
mergify bot pushed a commit that referenced this pull request Dec 22, 2022
…34075)

* Start EPH as non-blocking

With this change, the first call to the input Start() method will set up and start the EPH worker in a non-blocking fashion. The EPH worker will continue until the Filebeat calls the Stop() method to tear it down for live reloading.

(cherry picked from commit 8f0db84)

# Conflicts:
#	x-pack/libbeat/management/generate_test.go
mergify bot pushed a commit that referenced this pull request Dec 22, 2022
…34075)

* Start EPH as non-blocking

With this change, the first call to the input Start() method will set up and start the EPH worker in a non-blocking fashion. The EPH worker will continue until the Filebeat calls the Stop() method to tear it down for live reloading.

(cherry picked from commit 8f0db84)

# Conflicts:
#	x-pack/libbeat/management/generate_test.go
mergify bot pushed a commit that referenced this pull request Dec 22, 2022
…34075)

* Start EPH as non-blocking

With this change, the first call to the input Start() method will set up and start the EPH worker in a non-blocking fashion. The EPH worker will continue until the Filebeat calls the Stop() method to tear it down for live reloading.

(cherry picked from commit 8f0db84)
zmoog added a commit that referenced this pull request Dec 23, 2022
…34075) (#34101)

* Start EPH as non-blocking

With this change, the first call to the input Start() method will set up and start the EPH worker in a non-blocking fashion. The EPH worker will continue until the Filebeat calls the Stop() method to tear it down for live reloading.

(cherry picked from commit 8f0db84)

Co-authored-by: Maurizio Branca <[email protected]>
zmoog added a commit that referenced this pull request Dec 23, 2022
…mode to non-blocking (#34100)

* [azure-eventhub input] Switch the run EPH run mode to non-blocking (#34075)

* Start EPH as non-blocking

With this change, the first call to the input Start() method will set up and start the EPH worker in a non-blocking fashion. The EPH worker will continue until the Filebeat calls the Stop() method to tear it down for live reloading.

(cherry picked from commit 8f0db84)

Co-authored-by: Maurizio Branca <[email protected]>
zmoog pushed a commit that referenced this pull request Dec 29, 2022
…mode to non-blocking (#34099)

* [azure-eventhub input] Switch the run EPH run mode to non-blocking (#34075)

* Start EPH as non-blocking

With this change, the first call to the input Start() method will set up and start the EPH worker in a non-blocking fashion. The EPH worker will continue until the Filebeat calls the Stop() method to tear it down for live reloading.
chrisberkhout pushed a commit that referenced this pull request Jun 1, 2023
…34075)

* Start EPH as non-blocking

With this change, the first call to the input Start() method will set up and start the EPH worker in a non-blocking fashion. The EPH worker will continue until the Filebeat calls the Stop() method to tear it down for live reloading.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-v8.4.0 Automated backport with mergify backport-v8.5.0 Automated backport with mergify backport-v8.6.0 Automated backport with mergify bug Team:Cloud-Monitoring Label for the Cloud Monitoring team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Azure Logs integration stops collecting logs after a configuration change
5 participants