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

There are times when our DRA artifact jobs bundle a previous version of
the dependencies (for example beats) even though a new one is already
available.

I'm not 100% this will fix the problem but I think we should try to use
no cache headers on the requests that get the manifest contents for the
latest versions.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tiago Costa 2023-05-18 17:08:37 +01:00 committed by GitHub
parent a9b13c0d96
commit 731aaa4045
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}.`);