Skip to content

Support both take over configurations#45222

Merged
belimawr merged 14 commits intoelastic:mainfrom
belimawr:45221-fix-take-over-config
Jul 10, 2025
Merged

Support both take over configurations#45222
belimawr merged 14 commits intoelastic:mainfrom
belimawr:45221-fix-take-over-config

Conversation

@belimawr
Copy link
Copy Markdown
Member

@belimawr belimawr commented Jul 7, 2025

Proposed commit message

The take over mode configuration changed format when its functionality was expanded. It changed
from a single boolean

take_over: true

To an object:

take_over:
  enabled: true
  from_ids: ["foo", "bar"]

This commit makes both formats accepted with no change on how the feature works.

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

Run the tests

cd filebeat

# Unit Tests
go test -run="TestTakeOverCfg|TestGetTakeOver" -count=1 -v ./input/filestream/...

# Integration tests
mage buildSystemTestBinary
go test -tags=integration -run=TestFilestreamTakeOver -v -count=1 ./tests/integration

For manual testing, follow the procedures from #42624 and use both configuration formats.

Related issues

## Use cases
## Screenshots
## Logs

The take over mode configuration changed format, this commit makes
both formats accepted with no change on how the feature works.
@botelastic botelastic Bot added the needs_team Indicates that the issue/PR needs a Team:* label label Jul 7, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 7, 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
Copy Markdown
Contributor

mergify Bot commented Jul 7, 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 Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team backport-9.1 Automated backport to the 9.1 branch labels Jul 7, 2025
@botelastic botelastic Bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Jul 7, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jul 7, 2025

🔍 Preview links for changed docs

Comment thread filebeat/input/v2/compat/compat_test.go
@belimawr belimawr marked this pull request as ready for review July 7, 2025 22:15
@belimawr belimawr requested review from a team as code owners July 7, 2025 22:15
@belimawr belimawr requested review from AndersonQ and faec July 7, 2025 22:15
@elasticmachine
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member

@AndersonQ AndersonQ left a comment

Choose a reason for hiding this comment

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

No blocker, but I left a few suggestions

Comment thread filebeat/input/filestream/config_test.go Outdated
Comment thread filebeat/input/filestream/config_test.go Outdated
Comment thread filebeat/input/filestream/config_test.go Outdated
Comment thread filebeat/input/filestream/config_test.go Outdated
Comment thread filebeat/input/filestream/internal/input-logfile/manager.go Outdated
Comment thread filebeat/input/filestream/internal/input-logfile/manager.go Outdated
@belimawr belimawr changed the title Support both take over configuration Support both take over configurations Jul 8, 2025
Co-authored-by: Anderson Queiroz <me@andersonq.me>
@belimawr belimawr requested a review from AndersonQ July 8, 2025 12:02
Comment thread docs/reference/filebeat/filebeat-input-filestream.md
Comment thread filebeat/input/filestream/internal/input-logfile/manager.go Outdated
Copy link
Copy Markdown
Member

@mauri870 mauri870 left a comment

Choose a reason for hiding this comment

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

I left a few minor comments, but the functionality looks good to me.

@belimawr belimawr requested a review from mauri870 July 8, 2025 14:26
Copy link
Copy Markdown
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

I believe this is possible directly with go-ucfg and doesn't require you to write a custom function to determine if its enabled or not. You could do something like this below and I think it would work.

func (t *takeOverConfig) Unpack(value interface{}) error {
   // handle boolean value

   // handle object value
}

Then in the configuration you just use TakeOver takeOverConfig config:"take_over". When reading the configuration is done, it will call Unpack and you can handle both cases.

Comment thread filebeat/input/filestream/internal/input-logfile/manager.go Outdated
Copy link
Copy Markdown
Contributor

@colleenmcginnis colleenmcginnis left a comment

Choose a reason for hiding this comment

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

Some thoughts and suggestions below. Let me know if you have questions about the versioning piece.

Comment thread CHANGELOG.next.asciidoc Outdated
Comment thread docs/reference/filebeat/filebeat-input-filestream.md
Comment thread docs/reference/filebeat/filebeat-input-filestream.md Outdated
Co-authored-by: Craig MacKenzie <craig.mackenzie@elastic.co>
@belimawr belimawr requested a review from cmacknz July 10, 2025 11:33
Copy link
Copy Markdown
Contributor

@blakerouse blakerouse left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you for switching to using the Unpack interface. Nice idea with the LogWarnings.

Copy link
Copy Markdown
Contributor

@karenzone karenzone left a comment

Choose a reason for hiding this comment

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

LGTM

@belimawr belimawr merged commit f72b33d into elastic:main Jul 10, 2025
47 of 50 checks passed
mergify Bot pushed a commit that referenced this pull request Jul 10, 2025
The take over mode configuration changed format, this commit makes
both formats accepted with no change on how the feature works.

---------

Co-authored-by: Anderson Queiroz <me@andersonq.me>
Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com>
Co-authored-by: Craig MacKenzie <craig.mackenzie@elastic.co>
(cherry picked from commit f72b33d)
belimawr added a commit that referenced this pull request Jul 10, 2025
The take over mode configuration changed format, this commit makes
both formats accepted with no change on how the feature works.

---------




(cherry picked from commit f72b33d)

Co-authored-by: Tiago Queiroz <tiago.queiroz@elastic.co>
Co-authored-by: Anderson Queiroz <me@andersonq.me>
Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com>
Co-authored-by: Craig MacKenzie <craig.mackenzie@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-9.1 Automated backport to the 9.1 branch 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.

Update take_over configuration to keep compatibility with the previous version

9 participants