-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Elastic Agent non-fleet broken upgrade between 8.3.x releases (#701)
* Fix Elastic Agent non-fleet broken upgrade between 8.3.x releases * Migrates vault directory on linux and windows to the top directory of the agent, so it can be shared without needing the upgrade handler call, like for example with side-by-side install/upgrade from .rpm/.deb * Extended vault to allow read-only open, useful when the vault at particular location needs to be only read not created. * Correct the typo in the log messages * Update lint flagged function comment with 'unused', was flagged with 'deadcode' on the previous run * Address code review feedback * Add missing import for linux utz * Change vault path from Top() to Config(), this a better location, next to fleet.enc based on the install/upgrade testing with .rpm/.deb installs * Fix the missing state migration for .rpm/.deb upgrade. The post install script now performs the migration and creates the symlink after that. * Fix typo in the postinstall script * Update the vault migration code, add the agent configuration match check with the agent secret (cherry picked from commit 8ef98f1)
- Loading branch information
1 parent
fcee44f
commit b4d1389
Showing
15 changed files
with
772 additions
and
77 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
symlink="/usr/share/elastic-agent/bin/elastic-agent" | ||
old_agent_dir="$( dirname "$(readlink -f -- "$symlink")" )" | ||
|
||
commit_hash="{{ commit_short }}" | ||
|
||
yml_path="$old_agent_dir/state.yml" | ||
enc_path="$old_agent_dir/state.enc" | ||
|
||
new_agent_dir="$( dirname "$old_agent_dir")/elastic-agent-$commit_hash" | ||
|
||
if ! [[ "$old_agent_dir" -ef "$new_agent_dir" ]]; then | ||
echo "migrate state from $old_agent_dir to $new_agent_dir" | ||
|
||
if test -f "$yml_path"; then | ||
echo "found "$yml_path", copy to "$new_agent_dir"." | ||
cp "$yml_path" "$new_agent_dir" | ||
fi | ||
|
||
if test -f "$enc_path"; then | ||
echo "found "$enc_path", copy to "$new_agent_dir"." | ||
cp "$enc_path" "$new_agent_dir" | ||
fi | ||
|
||
if test -f "$symlink"; then | ||
echo "found symlink $symlink, unlink" | ||
unlink "$symlink" | ||
fi | ||
|
||
echo "create symlink "$symlink" to "$new_agent_dir/elastic-agent"" | ||
ln -s "$new_agent_dir/elastic-agent" "$symlink" | ||
fi | ||
|
||
systemctl daemon-reload 2> /dev/null | ||
exit 0 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.