Skip to content

Remove ID from list when Filestream inputs fail to be created#44697

Merged
belimawr merged 6 commits intoelastic:mainfrom
belimawr:fix-filestream-creation-issue
Jun 10, 2025
Merged

Remove ID from list when Filestream inputs fail to be created#44697
belimawr merged 6 commits intoelastic:mainfrom
belimawr:fix-filestream-creation-issue

Conversation

@belimawr
Copy link
Contributor

@belimawr belimawr commented Jun 6, 2025

Proposed commit message

Filestream was not removing the ID from inputs that failed to start, that made re-starting the same input with a valid configuration to fail with a duplicated ID error. This affects any configuration mode that can be reloaded, Elastic-Agent being the main use case.

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

How to test this PR locally

1. Create the following files

filebeat.yml

filebeat.config:
  inputs:
    enabled: true
    path: inputs.d/*.yml
    reload.enabled: true
    reload.period: 2s

queue.mem:
  flush:
    timeout: 0s

output.console:
  pretty: true

inputs.d/filestream.yml

- type: filestream
  id: t-wing
  paths:
    - /**/**/log.log
    # - /tmp/flog.log

/tmp/flog.log

<90>2 2025-06-09T12:31:10.044Z internalworld-class.net sed 3808 ID961 - We need to connect the primary THX protocol!
<62>2 2025-06-09T12:31:10.044Z investorfunctionalities.name velit 2310 ID769 - The SSL monitor is down, hack the open-source capacitor so we can quantify the PCI system!
<49>1 2025-06-09T12:31:10.044Z nationalmatrix.net rerum 798 ID992 - We need to compress the back-end TCP interface!
<187>1 2025-06-09T12:31:10.044Z humanmesh.org dolores 2059 ID720 - Use the multi-byte TCP protocol, then you can program the wireless array!
<188>2 2025-06-09T12:31:10.044Z districtsolutions.net in 333 ID581 - Use the haptic PNG pixel, then you can input the redundant transmitter!
<17>1 2025-06-09T12:31:10.044Z legacycross-media.net sunt 1957 ID621 - Try to quantify the SDD system, maybe it will quantify the solid state capacitor!
<54>1 2025-06-09T12:31:10.044Z internalmesh.io et 9739 ID142 - Hacking the system won't do anything, we need to parse the primary RAM hard drive!
<161>2 2025-06-09T12:31:10.044Z regionalsexy.net assumenda 9612 ID649 - You can't bypass the firewall without bypassing the back-end AI sensor!
<131>2 2025-06-09T12:31:10.044Z futureembrace.info labore 900 ID122 - I'Ll generate the virtual XSS circuit, that should array the USB sensor!
<6>2 2025-06-09T12:31:10.044Z principalrepurpose.net provident 8513 ID99 - Try to hack the SMS interface, maybe it will back up the bluetooth program!

2. Build and Start Filebeat

go build .
./filebeat

Wait for the log error:

Error creating runner from config: cannot create prospector: error while creating filewatcher multiple ** in \"/**/**/log.log\"

3. Edit inputs.d/filestream.yml so it is valid

Remove the first, invalid, path and uncomment the second one. paths section so it looks like this:

  paths:
    #- /**/**/log.log
    - /tmp/flog.log

Save the file and wait to see the ingested events in the console.

## Related issues
## Use cases
## Screenshots
## Logs

Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jun 6, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Jun 6, 2025

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

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

@mergify
Copy link
Contributor

mergify bot commented Jun 6, 2025

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @belimawr? 🙏.
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-8./d is the label to automatically backport to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.
@belimawr belimawr added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Jun 9, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 9, 2025
@belimawr belimawr added needs_team Indicates that the issue/PR needs a Team:* label backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches labels Jun 9, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 9, 2025
@belimawr belimawr added needs_team Indicates that the issue/PR needs a Team:* label bugfix labels Jun 9, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jun 9, 2025
@belimawr belimawr marked this pull request as ready for review June 9, 2025 16:45
@belimawr belimawr requested a review from a team as a code owner June 9, 2025 16:45
@belimawr belimawr requested review from AndersonQ and mauri870 June 9, 2025 16:45
@elasticmachine
Copy link
Contributor

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

belimawr added 2 commits June 9, 2025 14:45
While duplicated IDs should never happen, we need to allow it for
legacy reasons, so when handling a failed input we need to consider
that there might be another input with the same ID running.

When we check if the ID is already in use we set flag,
`idAlreadyInUse` and we only remove the ID in a failure scenario if
the flag is false.
@belimawr belimawr requested a review from leehinman June 9, 2025 19:14
Co-authored-by: Anderson Queiroz <me@andersonq.me>
@belimawr belimawr enabled auto-merge (squash) June 10, 2025 12:13
@belimawr
Copy link
Contributor Author

I've enabled auto-merge.

Thanks for the quick review folks!

@belimawr belimawr disabled auto-merge June 10, 2025 18:45
@belimawr belimawr merged commit 017cc4f into elastic:main Jun 10, 2025
46 of 50 checks passed
@github-actions
Copy link
Contributor

@Mergifyio backport 8.17 8.18 8.19 9.0

@belimawr belimawr deleted the fix-filestream-creation-issue branch June 10, 2025 18:47
@mergify
Copy link
Contributor

mergify bot commented Jun 10, 2025

backport 8.17 8.18 8.19 9.0

✅ Backports have been created

Details
mergify bot pushed a commit that referenced this pull request Jun 10, 2025
Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.

This commit fixes it by removing the ID from a failed input.
---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
(cherry picked from commit 017cc4f)

# Conflicts:
#	filebeat/input/filestream/internal/input-logfile/manager.go
#	filebeat/input/filestream/internal/input-logfile/manager_test.go
mergify bot pushed a commit that referenced this pull request Jun 10, 2025
Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.

This commit fixes it by removing the ID from a failed input.
---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
(cherry picked from commit 017cc4f)

# Conflicts:
#	filebeat/input/filestream/internal/input-logfile/manager.go
#	filebeat/input/filestream/internal/input-logfile/manager_test.go
mergify bot pushed a commit that referenced this pull request Jun 10, 2025
Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.

This commit fixes it by removing the ID from a failed input.
---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
(cherry picked from commit 017cc4f)

# Conflicts:
#	filebeat/input/filestream/internal/input-logfile/manager.go
#	filebeat/input/filestream/internal/input-logfile/manager_test.go
mergify bot pushed a commit that referenced this pull request Jun 10, 2025
Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.

This commit fixes it by removing the ID from a failed input.
---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
(cherry picked from commit 017cc4f)

# Conflicts:
#	filebeat/input/filestream/internal/input-logfile/manager.go
belimawr added a commit that referenced this pull request Jun 10, 2025
…l to be created (#44740)

Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.

This commit fixes it by removing the ID from a failed input.
---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
(cherry picked from commit 017cc4f)

# Conflicts:
#	filebeat/input/filestream/internal/input-logfile/manager.go

* fix merge conflicts

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
belimawr added a commit that referenced this pull request Jun 10, 2025
…il to be created (#44738)

Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.

This commit fixes it by removing the ID from a failed input.
---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
(cherry picked from commit 017cc4f)

# Conflicts:
#	filebeat/input/filestream/internal/input-logfile/manager.go
#	filebeat/input/filestream/internal/input-logfile/manager_test.go

* Fix merge conflicts

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
belimawr added a commit that referenced this pull request Jun 10, 2025
…il to be created (#44737)

Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.

This commit fixes it by removing the ID from a failed input.
---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
(cherry picked from commit 017cc4f)

# Conflicts:
#	filebeat/input/filestream/internal/input-logfile/manager.go
#	filebeat/input/filestream/internal/input-logfile/manager_test.go

* Fix merge conflicts

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
belimawr added a commit that referenced this pull request Jun 10, 2025
…il to be created (#44739)

Filestream was not removing the ID from inputs that failed to start,
that made re-starting the same input with a valid configuration to
fail with a duplicated ID error. This affects any configuration mode
that can be reloaded, Elastic-Agent being the main use case.

This commit fixes it by removing the ID from a failed input.
---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
(cherry picked from commit 017cc4f)

# Conflicts:
#	filebeat/input/filestream/internal/input-logfile/manager.go
#	filebeat/input/filestream/internal/input-logfile/manager_test.go

* Fix merge conflicts

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-8 Automated backport with mergify to all the active 8.[0-9]+ branches backport-active-9 Automated backport with mergify to all the active 9.[0-9]+ branches bugfix Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

5 participants