-
Notifications
You must be signed in to change notification settings - Fork 193
Cache binaries downloaded for packaging locally #9133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane) |
be4df5e
to
fecc75c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did look at the code and the endgoal makes total sense to me and it is welcome improvement. There is only this part that we rely on the server telling us if something has changed or not (by using "If-Modified-Since" http header) that I am not sure how I feel about it. By leveraging the latter we kinda "expose" our packaging to any bugs of the artifacts server (has caused us issues in the past). Maybe a more controlled by us solution would be to download first the sha512 file compare it with what we have locally and if different download. wdyt?
For what it's worth, I think our artifacts API just passes that header to the underlying object storage, which should have a correct implementation. I originally thought we always check the downloaded file against the hash, but it seems like we might not? If we did, that would solve the problem, because even if the artifacts api was wrong, we'd get a hash mismatch and at least see the problem. For the record, I think actual packaging steps in the CI should always redownload the artifacts, ideally by calling |
and for this exact reason of having to speculate when we rely on an external server, I would prefer utilising the |
I would consider In the meantime, how about I submit a PR with just the download refactor? It has benefits on its own, like not passing the content of downloaded files as strings. 😅 |
|
i suspect this is primarily for local usage. |
Isn't |
1dfd0c7
to
f0263b6
Compare
I've rebased this change on #9218, making it much simpler. With #9226, we always verify checksums, so we'll immediately know if the artifacts API served us a stale download, or if the file is corrupted for whatever reason. So this change should be quite safe now. It's only really intended for local use, although we can later look into keeping the downloaded binaries on CI runners, if we want. @pkoutsovasilis @michalpristas can you review again? 🙏 |
4680a90
to
9a9e956
Compare
@swiatekm please merge the latest main in here; the failure you see is because I merged this one #9832 and I managed to hit your CI run just right in the middle; so the clean up step run with the latest code in main but the pipeline was loaded before the merge so any changes are lost. PS: we are working on a solution to get away from such failures |
9a9e956
to
cb04629
Compare
|
💛 Build succeeded, but was flaky
Failed CI StepsHistory
cc @swiatekm |
@Mergifyio backport 8.18 8.19 9.0 9.1 |
✅ Backports have been created
|
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md Co-authored-by: Panos Koutsovasilis <[email protected]> * fixup! Only download artifacts which aren't present --------- Co-authored-by: Panos Koutsovasilis <[email protected]> (cherry picked from commit 6aed8b1)
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md Co-authored-by: Panos Koutsovasilis <[email protected]> * fixup! Only download artifacts which aren't present --------- Co-authored-by: Panos Koutsovasilis <[email protected]> (cherry picked from commit 6aed8b1)
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md Co-authored-by: Panos Koutsovasilis <[email protected]> * fixup! Only download artifacts which aren't present --------- Co-authored-by: Panos Koutsovasilis <[email protected]> (cherry picked from commit 6aed8b1)
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md Co-authored-by: Panos Koutsovasilis <[email protected]> * fixup! Only download artifacts which aren't present --------- Co-authored-by: Panos Koutsovasilis <[email protected]> (cherry picked from commit 6aed8b1)
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md * fixup! Only download artifacts which aren't present --------- (cherry picked from commit 6aed8b1) Co-authored-by: Mikołaj Świątek <[email protected]> Co-authored-by: Panos Koutsovasilis <[email protected]>
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md * fixup! Only download artifacts which aren't present --------- (cherry picked from commit 6aed8b1) Co-authored-by: Mikołaj Świątek <[email protected]> Co-authored-by: Panos Koutsovasilis <[email protected]>
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md * fixup! Only download artifacts which aren't present --------- (cherry picked from commit 6aed8b1) Co-authored-by: Mikołaj Świątek <[email protected]> Co-authored-by: Panos Koutsovasilis <[email protected]>
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md * fixup! Only download artifacts which aren't present --------- (cherry picked from commit 6aed8b1) Co-authored-by: Mikołaj Świątek <[email protected]> Co-authored-by: Panos Koutsovasilis <[email protected]>
* upstream: (26 commits) fix: ensure EDOT subprocess shuts down gracefully on agent termination (#9886) [main][Automation] Update versions (#9976) Add Collector reference docs and automation (#9953) [beatreceivers] Integrate beatsauthextension (#9257) [main][Automation] Update versions (#9941) Update OTel components to v0.132.0/v1.38.0 (#9954) Enhancement/5235 wrap errors when marking upgrade (#9366) Mount Go build cache into crossbuild container (#9094) Liveness agent state (#9673) [main][Automation] Bump VM Image version to 1757725254 (#9942) Enhancement/5235 correctly wrap errors from copyActionDir and copyRunDirectory (#9349) [main][Automation] Update elastic/beats to afc53c0479ac (#9874) Add -coverpkg option when running unit test to calculate coverage across packages (#9913) Cache binaries downloaded for packaging locally (#9133) [main][Automation] Update versions (#9897) Disable flaky test TestBeatsReceiverLogs (#9891) Allow overriding AGENT_PACKAGE_VERSION and MANIFEST_URL when USE_PACKAGE_VERSION=true (#9864) add ingest-docs team as CODEOWNERS for release notes and docset.yml (#9865) fix: correct spelling of 'output' in various templates and monitoring code (#9827) k8s: Add comment around hostUsers for Universal Profiling deployments (#9847) ...
* Add an env variable to keep the download archive * Only download artifacts which aren't present * Document the KEEP_ARCHIVE env variable * Update README.md Co-authored-by: Panos Koutsovasilis <[email protected]> * fixup! Only download artifacts which aren't present --------- Co-authored-by: Panos Koutsovasilis <[email protected]>
What does this PR do?
It makes it possible to avoid re-downloading binaries on each
mage package
invocation. It does this by:KEEP_ARCHIVE
environment variable, which, when set, prevents deletion of the binary archive in the drop path: 0e63536If-Modified-Since
header based on the modification time of the existing file. If this returns a Not Modified code, we skip the download: a7ec517The environment variable is introduced to avoid potentially breaking the CI and unified builds. We need to more carefully verify that it won't before enabling it by default.
Why is it important?
Redownloading binaries wastes time and makes agent difficult to work with on slow internet connections.
Checklist
[ ] 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 testHow to test this PR locally
Run
EXTERNAL=true SNAPSHOT=true DEV=true KEEP_ARCHIVE=true mage package
twice. The second time should be faster.Related issues