-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Filestream returns error when an input with duplicated ID is created #41954
Filestream returns error when an input with duplicated ID is created #41954
Conversation
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
@belimawr assigning this to you as discussed over slack. |
d15f99f
to
510f68a
Compare
@@ -0,0 +1,123 @@ | |||
// Licensed to Elasticsearch B.V. under one or more contributor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file was actually renamed from reload_test.go
. However because a test is added to reload_test.go
, Git got confused and thinks this file is new and the other has been edited.
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane) |
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
|
…-do-not-run-duplicated-id
…-do-not-run-duplicated-id
This pull request is now in conflicts. Could you fix it? 🙏
|
…-do-not-run-duplicated-id
…m:AndersonQ/beats into 41938-filestream-do-not-run-duplicated-id
…-do-not-run-duplicated-id
144e61a
to
e5d6bdf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I tested the first two cases manually (input reload and autodiscover) and confirmed the log messages appear in the output.
…-do-not-run-duplicated-id
For some reason this test became flaky, the root of the flakiness is not on the test, it is on how a rename operation is detected. Even though this test uses `os.Rename`, it does not seem to be an atomic operation. https://www.man7.org/linux/man-pages/man2/rename.2.html does not make it clear whether 'renameat' (used by `os.Rename`) is atomic. On a flaky execution, the file is actually perceived as removed and then a new file is created, both with the same inode. This happens on a system that does not reuse inodes as soon they're freed. Because the file is detected as removed, it's state is also removed. Then when more data is added, only the offset of the new data is tracked by the registry, causing the test to fail. A workaround for this is to not remove the state when the file is removed, hence `clean_removed: false` is set in the test config.
The failing tests seem to be unrelated, I created a standalone PR (#42213) to fix them, however I also included the fix commit on this PR to unblock it. |
Proposed commit message
The Filestream input now enforces uniqueness of it ID when starting. When the manager is creating an input it checks whether another input with the same ID has already been created, if this is true, then it will log the duplicated input configuration and return an error.
An empty Filestream input ID is a valid ID and treated as any other, so if there are two or more Filestream inputs without an ID, only the first one to be created will run and the others will error.
Filestream inputs now accept
allow_deprecated_id_duplication: true
to keep the previous behaviour of running multiple inputs with the same ID.Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.Disruptive User Impact
This is a breaking change, if there are two or more Filestream inputs with the same ID, only the first to be created will run, all others will error on creation.
Author's Checklist
allow_deprecated_id_duplication
and tests for it.How to test this PR locally
Testing input reload
Create the following
filebeat.yml
andinputs.d/filestream.yml
filebeat.yml
inputs.d/filestream.yml
Build filebeat from this PR
Start Filebeat
Look the logs, you should see the following errors
error logs
You can also check the IDs and number of running inputs with:
Testing Autodiscover
Any autodiscover will do, so we'll use docker on this example for the sake of simplicity
Start Filebeat with the following configuration
filebeat.yml
Make sure you have at least two docker container running
Look at the logs and make sure the following entry appear
autodiscover log error
Testing
allow_deprecated_id_duplication
Follow any of the above testing procedures, but add
allow_deprecated_id_duplication: true
to the filestream configurationLook at the logs and make sure the following entry appear
running duplicated ID error
Related issues
## Use cases## ScreenshotsLogs
Warning logged during config validation when 'allow_deprecated_id_duplication' is enabled
Error logged by Filestream's input manager when an input has got a duplicated ID and 'allow_deprecated_id_duplication' is enabled
Error logged by input reloader (inputs.d directory) when a Filestream input has got duplicated IDs
Error logged by Filestream's input manager when an input has got a duplicated ID
Error logged by autodiscover when Filestream inputs with duplicated IDs cannot be created