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

[8.x](backport #40794) Add test for elasticsearch re-connection after network error & allow graceful shutdown #41454

Merged
merged 1 commit into from
Oct 25, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Oct 25, 2024

Proposed commit message

This commit reworks the eslegclient.Connection to accept a context in its Connect method, this allows the caller to cancel any in flight requests made by the connection by cancelling the context.

The libbeat outputs.Connectable interface (used by outputs.NetworkClient) had to be updated to accept the context, which required refactoring in most of the outputs to also accept a context on connect.

The worker from libbeat/publisher/pipeline/client_worker.go now uses a context for it's cancellation instead of a channel,
this context is also used when creating a connection to Elasticsearch.

An integration test is added to ensure the
ES output can always recover from network errors.

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

It's a bug fix, there is no disruptive user impact

## Author's Checklist

How to test this PR locally

  1. Build Filebeat
  2. Get it sending data to ES
  3. Disconnect from the network, stop ES, do anything that will prevent Filebeat from reaching ES
  4. Wait for network error logs
  5. Re-start ES/reconnect to the network
  6. Filebeat should recover and start sending data again.

Related issues

## Use cases
## Screenshots
## Logs


This is an automatic backport of pull request #40794 done by [Mergify](https://mergify.com).

…graceful shutdown (#40794)

This commit reworks the `eslegclient.Connection` to accept a context in its `Connect` method, this allows the caller to cancel any in flight requests made by the connection by cancelling the context.

The libbeat `outputs.Connectable` interface (used by `outputs.NetworkClient`) had to be updated to accept the context, which required refactoring in most of the outputs to also accept a context on connect.

The worker from libbeat/publisher/pipeline/client_worker.go now uses a context for it's cancellation instead of a channel,
this context is also used when creating a connection to Elasticsearch.

An integration test is added to ensure the
ES output can always recover from network errors.

(cherry picked from commit 4dfef8b)
@mergify mergify bot requested review from a team as code owners October 25, 2024 14:52
@mergify mergify bot requested review from faec and VihasMakwana and removed request for a team October 25, 2024 14:52
@mergify mergify bot added the backport label Oct 25, 2024
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 25, 2024
@pierrehilbert pierrehilbert enabled auto-merge (squash) October 25, 2024 15:34
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Oct 25, 2024
@elasticmachine
Copy link
Collaborator

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

@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Oct 25, 2024
@pierrehilbert pierrehilbert merged commit e29444d into 8.x Oct 25, 2024
139 of 142 checks passed
@pierrehilbert pierrehilbert deleted the mergify/bp/8.x/pr-40794 branch October 25, 2024 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants