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

Log redacted config on config changes #1671

Merged
merged 9 commits into from
Aug 12, 2022

Conversation

michel-laterman
Copy link
Contributor

@michel-laterman michel-laterman commented Jul 18, 2022

What is the problem this PR solves?

Debugging the fleet-server can be difficult as it is not clear what config it is running.

How does this PR solve the problem?

Output redacted configuration when an updated config is received.

How to test this PR locally

  1. Compile a snapshot version of elastic-agent and fleet-server.
  2. unzip elastic-agent snapshot.
  3. Copy the fleet-server artifact and sha files to the elastic-agent downloads dir.
  4. Install elastic-agent with a policy that only contains the fleet-server integration
  5. Review logs to see redacted log config.

Checklist

  • [] 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.

Related issues

@mergify
Copy link
Contributor

mergify bot commented Jul 18, 2022

This pull request is now in conflicts. Could you fix it @michel-laterman? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b redact-config-log upstream/redact-config-log
git merge upstream/main
git push upstream redact-config-log

@elasticmachine
Copy link
Contributor

elasticmachine commented Jul 18, 2022

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2022-08-11T20:36:26.227+0000

  • Duration: 12 min 33 sec

Test stats 🧪

Test Results
Failed 0
Passed 304
Skipped 1
Total 305

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

@michel-laterman michel-laterman added enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team labels Jul 19, 2022
@mergify
Copy link
Contributor

mergify bot commented Jul 25, 2022

This pull request is now in conflicts. Could you fix it @michel-laterman? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b redact-config-log upstream/redact-config-log
git merge upstream/main
git push upstream redact-config-log

@joshdover
Copy link
Contributor

@michel-laterman Friendly bump on this one. @pierrehilbert should we be tracking this for 8.5?

redacted := &config.Config{
Fleet: cfg.Fleet,
Output: cfg.Output,
Inputs: make([]config.Input, 1),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

having this as cfg.Inputs causes one of the integration tests to fail.

@michel-laterman michel-laterman marked this pull request as ready for review August 9, 2022 23:42
@michel-laterman michel-laterman requested a review from a team as a code owner August 9, 2022 23:42
@@ -538,7 +538,7 @@ LOOP:

select {
case newCfg = <-f.cfgCh:
log.Info().Msg("Server configuration update")
log.Info().Interface("cfg", redactConfig(curCfg)).Msg("Server configuration update")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

alternatively we can use the redactConfig call instead of redactServerCfg on lines 643 & 659 in configChangedServer (where it logs old/new config)

Copy link
Contributor

@ph ph left a comment

Choose a reason for hiding this comment

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

LGTM for more debug options.

@michel-laterman michel-laterman merged commit 7f4576c into elastic:main Aug 12, 2022
@michel-laterman michel-laterman deleted the redact-config-log branch August 12, 2022 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log all of fleet server configuration at startup
4 participants