Cherry-pick #24817 to 7.x: [Elastic Agent] Fix Docker container to allow state to properly be handled#24879
Merged
blakerouse merged 1 commit intoelastic:7.xfrom Mar 31, 2021
Merged
Conversation
…ndled (elastic#24817) * Adjust paths to allow setting data path when running in container mode. * Fix ability for elastic-agent to have proper state in Docker. * Add changelog entry. * Fix lint. * Fix issue with bootstrapping with Fleet Server. * Fix lint. * additional fixes * unify ENV for home, logs, config, data * add CONFIG_PATH * set paths and copy downloads before extracting APM Server * restrict path config to ENV * Cleanup some issues with cloud mode. * Fix issue with CONFIG_PATH when empty. Improve sub-process agent in enroll to exit when Elastic Agent crashes. * Cleanup the paths to be correct. * Update changelog. * Fix unit tests. Co-authored-by: simitt <silvia.mitter@elastic.co> (cherry picked from commit 1f1fae5)
Contributor
|
Pinging @elastic/agent (Team:Agent) |
Contributor
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cherry-pick of PR #24817 to 7.x branch. Original message:
What does this PR do?
This fixes the Elastic Agent Docker image to allow a proper state to be stored for the image. Previously this was not possible for the state to be placed into a volume which prevent restarts of the container to maintain its previous state.
This changes the Elastic Agent to not version its directory when running under Docker. This is key to allowing the state to be storable and being that an Elastic Agent container cannot be self-upgraded it is acceptable that it is not versioned.
Because of how the Elastic Agent ships with the builds in the download directory the state could not mount over that directory of Elastic Agent would need to re-download those files. This changes the container sub-command to rsync the builds download directory into the state directory before actually running. This allows new downloads to stay in the state directory and allows the running Elastic Agent to use the binaries that shipped with the image.
By default the state of the Docker container goes to
/usr/share/elastic-agent/state. This can changed withSTATE_PATHenvironment. Elastic Agent logs now default to output stderr so they can be collected by the container runtime. In the case thatLOGS_PATHvariable is set then the Elastic Agent will log to$LOGS_PATH/elastic-agent.loginstead of stderr.Other fixes include using the
$STATE_PATH/data/tmpinstead of/tmpfor the unix sockets as the container cannot write to/tmp.Why is it important?
Critical to allow the state of the Elastic Agent to persist restarts of the Elastic Agent Docker image.
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidocorCHANGELOG-developer.next.asciidoc.Author's Checklist
/usr/share/elastic-agent/state.STATE_PATH.How to test this PR locally
Related issues
--path.home#24801