[8.8] chore(NA): add no cache headers for axios requests when downloading cloud dependencies (#158032) (#158090)

# Backport

This will backport the following commits from `main` to `8.8`:
- [chore(NA): add no cache headers for axios requests when downloading
cloud dependencies
(#158032)](https://github.com/elastic/kibana/pull/158032)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Tiago
Costa","email":"tiago.costa@elastic.co"},"sourceCommit":{"committedDate":"2023-05-18T16:08:37Z","message":"chore(NA):
add no cache headers for axios requests when downloading cloud
dependencies (#158032)\n\nThere are times when our DRA artifact jobs
bundle a previous version of\r\nthe dependencies (for example beats)
even though a new one is already\r\navailable.\r\n\r\nI'm not 100% this
will fix the problem but I think we should try to use\r\nno cache
headers on the requests that get the manifest contents for the\r\nlatest
versions.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"731aaa404523edb4268c4c540a54da06b6f13543","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["chore","Team:Operations","release_note:skip","backport:all-open","v8.9.0"],"number":158032,"url":"https://github.com/elastic/kibana/pull/158032","mergeCommit":{"message":"chore(NA):
add no cache headers for axios requests when downloading cloud
dependencies (#158032)\n\nThere are times when our DRA artifact jobs
bundle a previous version of\r\nthe dependencies (for example beats)
even though a new one is already\r\navailable.\r\n\r\nI'm not 100% this
will fix the problem but I think we should try to use\r\nno cache
headers on the requests that get the manifest contents for the\r\nlatest
versions.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"731aaa404523edb4268c4c540a54da06b6f13543"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/158032","number":158032,"mergeCommit":{"message":"chore(NA):
add no cache headers for axios requests when downloading cloud
dependencies (#158032)\n\nThere are times when our DRA artifact jobs
bundle a previous version of\r\nthe dependencies (for example beats)
even though a new one is already\r\navailable.\r\n\r\nI'm not 100% this
will fix the problem but I think we should try to use\r\nno cache
headers on the requests that get the manifest contents for the\r\nlatest
versions.\r\n\r\n---------\r\n\r\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"731aaa404523edb4268c4c540a54da06b6f13543"}}]}]
BACKPORT-->

Co-authored-by: Tiago Costa <tiago.costa@elastic.co>
This commit is contained in:
Kibana Machine 2023-05-18 13:29:05 -04:00 committed by GitHub
parent 29ea0e3fda
commit 961fc971fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -58,11 +58,18 @@ export const DownloadCloudDependencies: Task = {
let manifestUrl = '';
let manifestJSON = null;
const buildUrl = `https://${subdomain}.elastic.co/beats/latest/${config.getBuildVersion()}.json`;
const axiosConfigWithNoCacheHeaders = {
headers: {
'Cache-Control': 'no-cache',
Pragma: 'no-cache',
Expires: '0',
},
};
try {
const latest = await Axios.get(buildUrl);
const latest = await Axios.get(buildUrl, axiosConfigWithNoCacheHeaders);
buildId = latest.data.build_id;
manifestUrl = latest.data.manifest_url;
manifestJSON = (await Axios.get(manifestUrl)).data;
manifestJSON = (await Axios.get(manifestUrl, axiosConfigWithNoCacheHeaders)).data;
if (!(manifestUrl && manifestJSON)) throw new Error('Missing manifest.');
} catch (e) {
log.error(`Unable to find Beats artifacts for ${config.getBuildVersion()} at ${buildUrl}.`);