mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Synthtrace] Improve error message when APM package version is invalid (#138616)
This commit is contained in:
parent
f2da8548a9
commit
554e83be14
1 changed files with 11 additions and 13 deletions
|
@ -53,22 +53,20 @@ export class ApmSynthtraceKibanaClient {
|
|||
return kibanaUrl;
|
||||
});
|
||||
}
|
||||
async fetchLatestApmPackageVersion(version: string) {
|
||||
async fetchLatestApmPackageVersion(currentKibanaVersion: string) {
|
||||
const url =
|
||||
'https://epr-snapshot.elastic.co/search?package=apm&prerelease=true&all=true&kibana.version=';
|
||||
const response = await fetch(url + version, { method: 'GET' });
|
||||
const json = await response.json();
|
||||
if (!Array.isArray(json)) {
|
||||
throw new Error('Could not locate apm package compatible with the current kibana version');
|
||||
const response = await fetch(url + currentKibanaVersion, { method: 'GET' });
|
||||
const json = (await response.json()) as Array<{ version: string }>;
|
||||
const packageVersions = (json ?? []).map((item) => item.version).sort(Semver.rcompare);
|
||||
const validPackageVersions = packageVersions.filter((v) => Semver.valid(v));
|
||||
const bestMatch = validPackageVersions[0];
|
||||
if (!bestMatch) {
|
||||
throw new Error(
|
||||
`None of the available APM package versions matches the current Kibana version (${currentKibanaVersion}). The latest available version is ${packageVersions[0]}. This can happen if the Kibana version was recently bumped, and no matching APM package was released. Reach out to the fleet team if this persists.`
|
||||
);
|
||||
}
|
||||
const versions = json
|
||||
.map<string>((item) => item.version)
|
||||
.filter((v) => Semver.valid(v))
|
||||
.sort(Semver.rcompare);
|
||||
if (versions.length === 0) {
|
||||
throw new Error('Could not locate apm package compatible with the current kibana version');
|
||||
}
|
||||
return versions[0];
|
||||
return bestMatch;
|
||||
}
|
||||
|
||||
async installApmPackage(kibanaUrl: string, version: string, username: string, password: string) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue