mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
# Backport This will backport the following commits from `main` to `8.16`: - [[EDR Workflows] Download multiple agent versions (#197469)](https://github.com/elastic/kibana/pull/197469) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Tomasz Ciecierski","email":"tomasz.ciecierski@elastic.co"},"sourceCommit":{"committedDate":"2024-10-24T15:10:19Z","message":"[EDR Workflows] Download multiple agent versions (#197469)","sha":"f3c29f82d6bb2fa2c823ae44ad980f4242da65ec","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Defend Workflows","v8.16.0","backport:version","v8.17.0"],"title":"[EDR Workflows] Download multiple agent versions","number":197469,"url":"https://github.com/elastic/kibana/pull/197469","mergeCommit":{"message":"[EDR Workflows] Download multiple agent versions (#197469)","sha":"f3c29f82d6bb2fa2c823ae44ad980f4242da65ec"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197469","number":197469,"mergeCommit":{"message":"[EDR Workflows] Download multiple agent versions (#197469)","sha":"f3c29f82d6bb2fa2c823ae44ad980f4242da65ec"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Tomasz Ciecierski <tomasz.ciecierski@elastic.co>
This commit is contained in:
parent
4f10541259
commit
bd6f22b96c
2 changed files with 9 additions and 6 deletions
|
@ -45,7 +45,7 @@ const downloadAndStoreElasticAgent = async (
|
|||
): Promise<void> => {
|
||||
const versionsToDownload = getVersionsToDownload(version);
|
||||
|
||||
// Although we have a list of versions to try downloading, we only need to download one, and will return as soon as it succeeds.
|
||||
// Download all the versions in the list
|
||||
for (const versionToDownload of versionsToDownload) {
|
||||
try {
|
||||
const { url } = await getAgentDownloadUrl(versionToDownload, closestMatch, log);
|
||||
|
@ -53,13 +53,10 @@ const downloadAndStoreElasticAgent = async (
|
|||
|
||||
await downloadAndStoreAgent(url, fileName);
|
||||
log.info(`Successfully downloaded and stored version ${versionToDownload}`);
|
||||
return; // Exit once successful
|
||||
} catch (error) {
|
||||
log.error(`Failed to download or store version ${versionToDownload}: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
log.error(`Failed to download agent for any available version: ${versionsToDownload.join(', ')}`);
|
||||
};
|
||||
|
||||
export const agentDownloaderRunner: RunFn = async (cliContext) => {
|
||||
|
|
|
@ -113,8 +113,14 @@ class AgentDownloadStorage extends SettingsStorage<AgentDownloadStorageSettings>
|
|||
|
||||
await handleProcessInterruptions(
|
||||
async () => {
|
||||
const { body } = await nodeFetch(agentDownloadUrl);
|
||||
await finished(body.pipe(outputStream));
|
||||
try {
|
||||
const { body } = await nodeFetch(agentDownloadUrl);
|
||||
await finished(body.pipe(outputStream));
|
||||
} catch (error) {
|
||||
this.log.error(`Error during download attempt ${attempt}: ${error.message}`);
|
||||
// Ensure any errors here propagate and trigger retry
|
||||
throw error;
|
||||
}
|
||||
},
|
||||
() => fs.unlinkSync(newDownloadInfo.fullFilePath) // Clean up on interruption
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue