Cherry-pick #24817 to 7.x: [Elastic Agent] Fix Docker container to allow state to properly be handled #24879
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_PATH
environment. Elastic Agent logs now default to output stderr so they can be collected by the container runtime. In the case thatLOGS_PATH
variable is set then the Elastic Agent will log to$LOGS_PATH/elastic-agent.log
instead of stderr.Other fixes include using the
$STATE_PATH/data/tmp
instead of/tmp
for 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.asciidoc
orCHANGELOG-developer.next.asciidoc
.Author's Checklist
/usr/share/elastic-agent/state
.STATE_PATH
.How to test this PR locally
Related issues
--path.home
#24801