Skip to content

Refactor binary downloads in agent packaging targets#9218

Merged
swiatekm merged 4 commits intomainfrom
chore/refactor-binary-download
Sep 9, 2025
Merged

Refactor binary downloads in agent packaging targets#9218
swiatekm merged 4 commits intomainfrom
chore/refactor-binary-download

Conversation

@swiatekm
Copy link
Copy Markdown
Member

@swiatekm swiatekm commented Jul 31, 2025

What does this PR do?

Refactors how the agent packaging target downloads binaries. The intent is to make it possible to cache the binaries locally and avoid having to redownload them. See #9133 for the full context.

The PR consists of the following changes:

  • The download function now always gets a target path as an input, so it doesn't need to create it on its own conditionally.
  • We use standard library functions for the download, so we don't need to pass the content as a string, and can instead write it directly to the target file, saving memory.
  • Remove some unused functions.

Why is it important?

This makes the download code more maintainable and more performant. It also unlocks further packaging improvements.

Checklist

  • I have read and understood the pull request guidelines of this project.
  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] I have added an entry in ./changelog/fragments using the changelog tool
  • [ ] I have added an integration test or an E2E test

How to test this PR locally

Related issues

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jul 31, 2025

This pull request does not have a backport label. Could you fix it @swiatekm? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-./d./d is the label that automatically backports to the 8./d branch. /d is the digit
  • backport-active-all is the label that automatically backports to all active branches.
  • backport-active-8 is the label that automatically backports to all active minor branches for the 8 major.
  • backport-active-9 is the label that automatically backports to all active minor branches for the 9 major.

@swiatekm swiatekm added skip-changelog backport-active-all Automated backport with mergify to all the active branches labels Jul 31, 2025
@swiatekm swiatekm marked this pull request as ready for review August 1, 2025 11:20
@swiatekm swiatekm requested a review from a team as a code owner August 1, 2025 11:20
@pierrehilbert pierrehilbert added the Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team label Aug 5, 2025
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

Copy link
Copy Markdown
Contributor

@pkoutsovasilis pkoutsovasilis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me only one comment about closing the resp.body

Comment thread dev-tools/mage/downloads/utils.go Outdated
@swiatekm swiatekm force-pushed the chore/refactor-binary-download branch from 56c547c to eec74ca Compare August 25, 2025 12:16
@elastic-sonarqube
Copy link
Copy Markdown

@elasticmachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

History

cc @swiatekm

@swiatekm swiatekm merged commit 05f62c2 into main Sep 9, 2025
19 checks passed
@swiatekm swiatekm deleted the chore/refactor-binary-download branch September 9, 2025 12:37
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 9, 2025

@Mergifyio backport 8.18 8.19 9.0 9.1

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Sep 9, 2025

mergify bot pushed a commit that referenced this pull request Sep 9, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function

(cherry picked from commit 05f62c2)
mergify bot pushed a commit that referenced this pull request Sep 9, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function

(cherry picked from commit 05f62c2)
mergify bot pushed a commit that referenced this pull request Sep 9, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function

(cherry picked from commit 05f62c2)
mergify bot pushed a commit that referenced this pull request Sep 9, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function

(cherry picked from commit 05f62c2)
swiatekm added a commit that referenced this pull request Sep 9, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function

(cherry picked from commit 05f62c2)

Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>
swiatekm added a commit that referenced this pull request Sep 9, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function

(cherry picked from commit 05f62c2)

Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>
swiatekm added a commit that referenced this pull request Sep 9, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function

(cherry picked from commit 05f62c2)

Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>
swiatekm added a commit that referenced this pull request Sep 9, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function

(cherry picked from commit 05f62c2)

Co-authored-by: Mikołaj Świątek <mail@mikolajswiatek.com>
intxgo pushed a commit to intxgo/elastic-agent that referenced this pull request Sep 24, 2025
* Clean up artifact download code in packaging

* Drop some unused functions

* Fix linter warnings

* Move http body closing to the inner download function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants