Skip to content

Fix error handling from BeatV2Manager reload#45733

Merged
belimawr merged 10 commits intoelastic:mainfrom
belimawr:43118-fix-starting-input-error
Aug 6, 2025
Merged

Fix error handling from BeatV2Manager reload#45733
belimawr merged 10 commits intoelastic:mainfrom
belimawr:43118-fix-starting-input-error

Conversation

@belimawr
Copy link
Contributor

@belimawr belimawr commented Aug 4, 2025

Proposed commit message

BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and `reload` now handles any unexpected error case/type.

Multiple lint warnings are fixed, including:
 - An unused wait group is removed
 - The parameters order in a `errors.Is` call is fixed

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

Related issues

## Use cases
## Screenshots
## Logs

BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.
@belimawr belimawr self-assigned this Aug 4, 2025
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Aug 4, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Aug 4, 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!)

@belimawr belimawr added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Aug 4, 2025
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Aug 4, 2025
@belimawr belimawr added backport-active-all Automated backport with mergify to all the active branches bugfix labels Aug 4, 2025
@mergify
Copy link
Contributor

mergify bot commented Aug 4, 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 requested a review from Copilot August 5, 2025 12:42

This comment was marked as outdated.

@belimawr belimawr requested a review from Copilot August 5, 2025 12:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes error handling in the BeatV2Manager's reload functionality by improving how errors from the reloadInputs method are processed and reported. The fix ensures that unit-specific errors are properly wrapped using cfgfile.UnitError and that unexpected error types are handled gracefully.

  • Enhanced error handling in the reload method to properly categorize and handle different error types
  • Modified reloadInputs to return cfgfile.UnitError for unit-specific failures instead of generic errors
  • Added comprehensive test coverage for error handling scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
x-pack/libbeat/management/managerV2.go Core error handling improvements with proper error categorization and unit-specific error wrapping
x-pack/filebeat/tests/integration/managerV2_test.go New integration test for reload error handling scenarios and type updates
x-pack/libbeat/management/simple_input_config_test.go Type updates from interface{} to any and minor formatting changes
@belimawr belimawr marked this pull request as ready for review August 5, 2025 18:39
@belimawr belimawr requested a review from a team as a code owner August 5, 2025 18:39
@belimawr belimawr requested review from leehinman and mauri870 August 5, 2025 18:39
@elasticmachine
Copy link
Contributor

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

@belimawr belimawr merged commit d8b1f1a into elastic:main Aug 6, 2025
93 of 96 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Aug 6, 2025

@Mergifyio backport 8.17 8.18 8.19 9.0 9.1

@mergify
Copy link
Contributor

mergify bot commented Aug 6, 2025

backport 8.17 8.18 8.19 9.0 9.1

✅ Backports have been created

Details
mergify bot pushed a commit that referenced this pull request Aug 6, 2025
BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.

(cherry picked from commit d8b1f1a)

# Conflicts:
#	x-pack/filebeat/tests/integration/managerV2_test.go
#	x-pack/libbeat/management/managerV2.go
mergify bot pushed a commit that referenced this pull request Aug 6, 2025
BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.

(cherry picked from commit d8b1f1a)

# Conflicts:
#	x-pack/libbeat/management/managerV2.go
mergify bot pushed a commit that referenced this pull request Aug 6, 2025
BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.

(cherry picked from commit d8b1f1a)

# Conflicts:
#	x-pack/libbeat/management/managerV2.go
mergify bot pushed a commit that referenced this pull request Aug 6, 2025
BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.

(cherry picked from commit d8b1f1a)
mergify bot pushed a commit that referenced this pull request Aug 6, 2025
BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.

(cherry picked from commit d8b1f1a)
kruskall pushed a commit to kruskall/beats that referenced this pull request Aug 7, 2025
BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.
belimawr added a commit that referenced this pull request Aug 25, 2025
…45759)

BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.

(cherry picked from commit d8b1f1a)

---------

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
belimawr added a commit that referenced this pull request Aug 25, 2025
…45760)

BeatV2Manager `reload` method calls `reloadInputs`, however it did not
handle the errors returned correctly. This commit fixes it by making
`reloadInputs`, whenever possible, use a cfgfile.UnitError to indicate
the failed unit and handling any unexpected error case/type.

(cherry picked from commit d8b1f1a)

* Fix merge conflicts

* Fix merge conflict

---------

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-all Automated backport with mergify to all the active branches bugfix Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team

4 participants