[8.19] (backport #9386) Enhancement/5235 upgrade cleans up downloads and extracted agent#10037
[8.19] (backport #9386) Enhancement/5235 upgrade cleans up downloads and extracted agent#10037
Conversation
* enhancement(5235): added comments describing updates in error handling. returning path in error cases if the download is completed * enhancement(5235): added wrapper var for verifier constructor in download step to improve testability * enhancement(5235): added test for downloadArtifact verifier errors * enhancement(5235): addded cleanupPaths slice. added deferred call to remove paths in the cleanupPaths slice * enhancement(5235): add archive and hash path to cleanup paths after artifact download * enhancement(5235): update error handling after unpack. add new versioned home to cleanup paths enhancement(5235): move newHome declaration * enhancement(5235): added upgrade cleanup test * enhancement(5235): added changelog fragment enhancement(5235): updated changelog fragment * enhancement(5235): fix errors in step_download after rebase * enhancement(5235): fix error in step_download_test after rebase * enhancement(5235): refactor disk space error check and path cleanup into one deferred call * enhancement(5235): refactored verifier factory and updated relevant download tests * enhancement(5235): removed separate test for cleanup, added cleanup checks in error handling test * enhancement(5235): changed function name in verifier * enhancement(5235): using AddHashExtension instead of hard coded hash extension string in upgrader (cherry picked from commit ab23962) # Conflicts: # internal/pkg/agent/application/upgrade/upgrade.go # internal/pkg/agent/application/upgrade/upgrade_test.go
|
Cherry-pick of ab23962 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
|
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
|
This pull request has not been merged yet. Could you please review and merge it @kaanyalti? 🙏 |
|
@kaanyalti can you take a look at this backport? |
|
|
Hi @kaanyalti, nice to e-meet you :) The way I read this GitHub PR, agents of version 8.19 should now be able to clean downloaded files if the agent update fails for some reason (e.g. insufficient disk space). I just tested this on Rocky 8.8. I tried to update a 8.19.11 Elastic Agent to 8.19.12.
I filled up the installation directory except for +- 300 MB and started the Elastic Agent upgrade process via Fleet. As excepted, the upgrade eventually failed with error_msg: insufficient disk space However, the downloaded files remain on the host and /opt/ remains at 100% disk usage. Do I misunderstand what you tried to achieve here or is your enhancement not working correctly? I'm happy to provide more details if needed, as this is a feature that we would really like to have. |





PR 5/6
What does this PR do?
Why is it important?
Checklist
[ ] I have made corresponding changes to the documentation[ ] I have made corresponding change to the default configuration files[ ] I have added an entry in./changelog/fragmentsusing the changelog tool[ ] I have added an integration test or an E2E testDisruptive User Impact
none
How to test this PR locally
Related issues
This is an automatic backport of pull request #9386 done by [Mergify](https://mergify.com).