[deb/rpm] copy run folder from old agent installation#7999
Merged
pkoutsovasilis merged 6 commits intoelastic:mainfrom May 2, 2025
Merged
[deb/rpm] copy run folder from old agent installation#7999pkoutsovasilis merged 6 commits intoelastic:mainfrom
pkoutsovasilis merged 6 commits intoelastic:mainfrom
Conversation
7598b06 to
abac95d
Compare
abac95d to
7272d04
Compare
7272d04 to
9d04234
Compare
Contributor
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
ycombinator
reviewed
Apr 29, 2025
ycombinator
reviewed
Apr 29, 2025
ycombinator
reviewed
Apr 29, 2025
ycombinator
requested changes
Apr 29, 2025
Contributor
ycombinator
left a comment
There was a problem hiding this comment.
Tested this PR locally and it works as expected:
$ dpkg -i elastic-agent-9.0.0-arm64.deb
Selecting previously unselected package elastic-agent.
...
systemd enable/restart elastic-agent
$ touch /var/lib/elastic-agent/data/elastic-agent-9.0.0-9786ac/run/panos_was_here
$ ls -l /var/lib/elastic-agent/data/elastic-agent-9.0.0-9786ac/run/
total 4
drwxr-x--- 1 root root 36 Apr 29 13:56 beat
drwxrwx--- 1 root root 34 Apr 29 13:56 filestream-monitoring
drwxr-x--- 1 root root 36 Apr 29 13:56 http
-rw-r--r-- 1 root root 0 Apr 29 13:56 panos_was_here
drwxr-x--- 1 root root 30 Apr 29 13:56 system
$ dpkg -i elastic-agent-9.1.0-SNAPSHOT-arm64.deb
(Reading database ... 32803 files and directories currently installed.)
...
found /var/lib/elastic-agent/data/elastic-agent-9.0.0-9786ac/run, copy to /var/lib/elastic-agent/data/elastic-agent-9.1.0-SNAPSHOT-5a8714
...
systemd enable/restart elastic-agent
$ ls -l /var/lib/elastic-agent/data/elastic-agent-9.1.0-SNAPSHOT-5a8714/run/
total 0
drwxr-x--- 1 root root 36 Apr 29 13:57 beat
drwxrwx--- 1 root root 34 Apr 29 13:57 filestream-monitoring
drwxr-x--- 1 root root 36 Apr 29 13:57 http
-rw-r--r-- 1 root root 0 Apr 29 13:57 panos_was_here
drwxr-x--- 1 root root 30 Apr 29 13:57 systemLeft some minor comments on the code.
|
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsHistory
|
ycombinator
approved these changes
Apr 30, 2025
kaanyalti
approved these changes
Apr 30, 2025
Contributor
|
@Mergifyio backport 8.17 8.18 8.19 9.0 |
Contributor
✅ Backports have been createdDetails
|
mergify bot
pushed a commit
that referenced
this pull request
May 2, 2025
* fix: copy run folder from old agent installation * fix: add debian OS support in deb related integration tests * doc: add changelog fragment * fix: deduplicate similar code and improve code readability * fix: typo * fix: preserve mode,ownership,timestamps during cp (cherry picked from commit 815c264) # Conflicts: # dev-tools/packaging/templates/linux/preinstall.sh.tmpl # pkg/testing/fixture.go # testing/integration/linux_deb_test.go # testing/integration/restrict_upgrade_deb_test.go
8 tasks
mergify bot
pushed a commit
that referenced
this pull request
May 2, 2025
* fix: copy run folder from old agent installation * fix: add debian OS support in deb related integration tests * doc: add changelog fragment * fix: deduplicate similar code and improve code readability * fix: typo * fix: preserve mode,ownership,timestamps during cp (cherry picked from commit 815c264) # Conflicts: # dev-tools/packaging/templates/linux/preinstall.sh.tmpl # pkg/testing/fixture.go # testing/integration/linux_deb_test.go
8 tasks
mergify bot
pushed a commit
that referenced
this pull request
May 2, 2025
* fix: copy run folder from old agent installation * fix: add debian OS support in deb related integration tests * doc: add changelog fragment * fix: deduplicate similar code and improve code readability * fix: typo * fix: preserve mode,ownership,timestamps during cp (cherry picked from commit 815c264) # Conflicts: # dev-tools/packaging/templates/linux/preinstall.sh.tmpl # pkg/testing/fixture.go # testing/integration/linux_deb_test.go
8 tasks
mergify bot
pushed a commit
that referenced
this pull request
May 2, 2025
* fix: copy run folder from old agent installation * fix: add debian OS support in deb related integration tests * doc: add changelog fragment * fix: deduplicate similar code and improve code readability * fix: typo * fix: preserve mode,ownership,timestamps during cp (cherry picked from commit 815c264)
8 tasks
pkoutsovasilis
added a commit
that referenced
this pull request
May 5, 2025
* fix: copy run folder from old agent installation * fix: add debian OS support in deb related integration tests * doc: add changelog fragment * fix: deduplicate similar code and improve code readability * fix: typo * fix: preserve mode,ownership,timestamps during cp (cherry picked from commit 815c264) Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
pkoutsovasilis
added a commit
that referenced
this pull request
May 5, 2025
…allation (#8060) * [deb/rpm] copy run folder from old agent installation (#7999) * fix: copy run folder from old agent installation * fix: add debian OS support in deb related integration tests * doc: add changelog fragment * fix: deduplicate similar code and improve code readability * fix: typo * fix: preserve mode,ownership,timestamps during cp (cherry picked from commit 815c264) # Conflicts: # dev-tools/packaging/templates/linux/preinstall.sh.tmpl # pkg/testing/fixture.go # testing/integration/linux_deb_test.go * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
pkoutsovasilis
added a commit
that referenced
this pull request
May 5, 2025
…allation (#8059) * [deb/rpm] copy run folder from old agent installation (#7999) * fix: copy run folder from old agent installation * fix: add debian OS support in deb related integration tests * doc: add changelog fragment * fix: deduplicate similar code and improve code readability * fix: typo * fix: preserve mode,ownership,timestamps during cp (cherry picked from commit 815c264) # Conflicts: # dev-tools/packaging/templates/linux/preinstall.sh.tmpl # pkg/testing/fixture.go # testing/integration/linux_deb_test.go * fix: resolve conflicts * fix: resolve conflicts --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
pkoutsovasilis
added a commit
that referenced
this pull request
May 5, 2025
…allation (#8058) * [deb/rpm] copy run folder from old agent installation (#7999) * fix: copy run folder from old agent installation * fix: add debian OS support in deb related integration tests * doc: add changelog fragment * fix: deduplicate similar code and improve code readability * fix: typo * fix: preserve mode,ownership,timestamps during cp (cherry picked from commit 815c264) # Conflicts: # dev-tools/packaging/templates/linux/preinstall.sh.tmpl # pkg/testing/fixture.go # testing/integration/linux_deb_test.go # testing/integration/restrict_upgrade_deb_test.go * fix: resolve conflicts * fix: linter issues --------- Co-authored-by: Panos Koutsovasilis <panos.koutsovasilis@elastic.co>
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.





What does this PR do?
This PR improves the upgrade experience of Elastic Agent installed via DEB and RPM packages. It updates the pre-installation script (
preinstall.sh.tmpl) to copy therundirectory from the previous agent installation into the new version's folder during an upgrade, preserving agent state that would otherwise be lost.Additionally, it extends integration tests to:
rundirectory and migration marker are properly copied across an upgrade.A new helper function
FindRunDiris also introduced in the testing framework to locate the agent'srundirectory based on versioned data paths.Based on my investigation:
/etc/elastic-agent/fleet.encwhich is preserved across upgrades/etc/elastic-agent/elastic-agent.ymlwhich is preserved across upgradesstate.ymlandstate.encare getting copied during upgradesrunfolder which contains components registry is also copied during ugpradesWhy is it important?
Currently, when an Elastic Agent installed via a DEB or RPM package is upgraded using a package manager (
apt/rpm), it does not preserve the previous state saved underrunfolder resulting in a poor upgrade experience. This PR ensures that therundirectory is correctly migrated, matching the behaviour expected during upgrades.Checklist
./changelog/fragmentsusing the changelog toolDisruptive User Impact
No disruptive impact expected. This change improves the upgrade process without altering current workflows for users. Upgrades will now correctly migrate the agent’s runtime state.
How to test this PR locally
rundirectory.apt installordpkg -i.rundirectory after upgrade.testing/integration/.Related issues