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 #41277) refactor beats argument parsing #41373

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Oct 22, 2024

Proposed commit message

Change beats argument parsing behavior.

Beats currently sets some command line flags in an init function, this means that any other project that imports beats will have conflicts if it uses the same options. This change moves this out of init.

Beats currently modifies the Argument list to offer backwards compatibility for flags in an init function. This would convert flags like -e to --e. This means if any other project imports beats, it's argument parsing would be changed. This change adds an allowed list of arguments that can be changed and moves it out of init.

Beats currently detects if it is fleet managed by looking at the command line flags. This change keeps that behavior, but adds the ability to set this directly. This allows setting the flag without the command line option.

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

The goal is none, however if any flags are missed, then the user would have to call them as --flag instead of -flag.

Author's Checklist

  • Must be tested with these changes running under elastic-agent (main elastic agent, beats built from this PR, policy had auditd and system metrics)
  • Must be tested with beats imported into elastic-agent (main elastic-agent, importing beats and implementing filebeat receiver, beats builts from this PR, policy had auditd and system metrics). Verified filebeatreceiver worked, normal agentbeat worked and that -1s could be passed as an argument to --fleet-server-timeout
  • Must be tested with apm-server. Built apm-server using this PR, had to make changes to internal/beatcmd/beat.go and internal/beatcmd/reloader.go. This was expected for change to uuidv5 and storage of the reload registry. Also had to upgrade to badgerv4, also expected, but may be a breaking change. Tested that apm-server -E management.enabled=true -E logging.to_stderr=true still worked as expected. No changes were required to apm-server argument parsing.

How to test this PR locally

Related issues

Use cases

Screenshots

Logs


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

* modify beats argument parsing to not happen during init
* allowlist for backwards compatible args, to conver -arg to --arg

Co-authored-by: Tiago Queiroz <me@tiago.life>

(cherry picked from commit 15eae5f)
@mergify mergify bot added the backport label Oct 22, 2024
@mergify mergify bot requested review from a team as code owners October 22, 2024 15:31
@mergify mergify bot requested review from belimawr and khushijain21 and removed request for a team October 22, 2024 15:31
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Oct 22, 2024
@botelastic
Copy link

botelastic bot commented Oct 22, 2024

This pull request doesn't have a Team:<team> label.

@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Data-Plane Label for the Agent Data Plane team label Oct 22, 2024
@elasticmachine
Copy link
Collaborator

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

@jlind23
Copy link
Collaborator

jlind23 commented Oct 23, 2024

run docs-build

@jlind23 jlind23 merged commit 8931af7 into 8.x Oct 23, 2024
142 checks passed
@jlind23 jlind23 deleted the mergify/bp/8.x/pr-41277 branch October 23, 2024 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport needs_team Indicates that the issue/PR needs a Team:* label 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.

4 participants