mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[Fleet] Fail build on unable to retrieve agent versions list (#154110)
## Summary Resolves https://github.com/elastic/kibana/issues/153923 This PR: 1. [Fails **non-PR** builds](https://buildkite.com/elastic/kibana-pull-request/builds/116952#01873497-c5a2-4031-9f5b-84df00e8368b) if we are unable to retrieve the list of Elastic Agent versions from the website API. If a build ships without this list being retrieved, users will not have the correct version choices to upgrade their agents to (see above issue) 2. Updates the API endpoint used from `https://www.elastic.co/api/product_versions` to `https://www.elastic.co/content/product_versions`, which appears to be a more stable version. The `/api` one is currently down: https://github.com/elastic/website-development/issues/10820
This commit is contained in:
parent
4c8c13d2fc
commit
99f366a595
1 changed files with 17 additions and 10 deletions
|
@ -19,22 +19,29 @@ const getAvailableVersions = async (log: ToolingLog) => {
|
|||
};
|
||||
// Endpoint maintained by the web-team and hosted on the elastic website
|
||||
// See https://github.com/elastic/website-development/issues/9331
|
||||
const url = 'https://www.elastic.co/api/product_versions';
|
||||
try {
|
||||
log.info('Fetching Elastic Agent versions list');
|
||||
const results = await fetch(url, options);
|
||||
const url = 'https://www.elastic.co/content/product_versions';
|
||||
log.info('Fetching Elastic Agent versions list');
|
||||
const results = await fetch(url, options);
|
||||
const rawBody = await results.text();
|
||||
|
||||
const jsonBody = await results.json();
|
||||
try {
|
||||
const jsonBody = JSON.parse(rawBody);
|
||||
|
||||
const versions: string[] = (jsonBody.length ? jsonBody[0] : [])
|
||||
.filter((item: any) => item?.title?.includes('Elastic Agent'))
|
||||
.map((item: any) => item?.version_number);
|
||||
|
||||
log.info(`Retrieved available versions`);
|
||||
log.info(`Retrieved available Elastic Agent versions`);
|
||||
return versions;
|
||||
} catch (error) {
|
||||
log.warning(`Failed to fetch versions list`);
|
||||
log.warning(error);
|
||||
log.warning(`Failed to fetch Elastic Agent versions list`);
|
||||
log.info(`Status: ${results.status}`);
|
||||
log.info(rawBody);
|
||||
if (process.env.BUILDKITE_PULL_REQUEST === 'true') {
|
||||
log.warning(error);
|
||||
} else {
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
return [];
|
||||
};
|
||||
|
@ -47,8 +54,8 @@ export const FetchAgentVersionsList: Task = {
|
|||
const versionsList = await getAvailableVersions(log);
|
||||
const AGENT_VERSION_BUILD_FILE = 'x-pack/plugins/fleet/target/agent_versions_list.json';
|
||||
|
||||
if (versionsList !== []) {
|
||||
log.info(`Writing versions list to ${AGENT_VERSION_BUILD_FILE}`);
|
||||
if (versionsList.length !== 0) {
|
||||
log.info(`Writing Elastic Agent versions list to ${AGENT_VERSION_BUILD_FILE}`);
|
||||
await write(
|
||||
build.resolvePath(AGENT_VERSION_BUILD_FILE),
|
||||
JSON.stringify(versionsList, null, ' ')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue