mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[Fleet] add kibana version if air gapped or product versions doesn't return (#174324)
## Summary Closes https://github.com/elastic/ingest-dev/issues/2779 Adding the kibana version to the list of available agent versions if the product versions api doesn't return any versions (not accessible or airgapped environment). This is a best effort fix to add the missing latest released version if the build version list is outdated. To verify: 1. test with internet connection - enroll an agent with the latest version 8.11.3 locally or in a VM (not container) - check that the upgrade available badge is not showing up and the add agent instructions have 8.11.3 version <img width="1324" alt="image" src="b833c92e
-3864-4a0b-a26b-0cf927b95a80"> <img width="814" alt="image" src="bb21a63a
-dbd5-4557-b81d-93391bbc51a9"> Restart kibana or wait 10m for the cache to expire before testing with air gapped. 2. test air-gapped by adding `xpack.fleet.isAirGapped: true` in kibana.yml - test that the agent shows up with the badge upgrade available, and the upgrade agent modal has 8.13 version locally - check that the add agent instructions have the 8.13 version (current kibana version) <img width="1294" alt="image" src="81df38c4
-cc35-466b-9d41-c226b8b29563"> <img width="818" alt="image" src="0a1b72d8
-be3c-4cbf-9f44-30a7f7aef02a"> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
This commit is contained in:
parent
898723384c
commit
f8408eeb7a
2 changed files with 10 additions and 9 deletions
|
@ -137,7 +137,7 @@ describe('getAvailableVersions', () => {
|
|||
});
|
||||
|
||||
it('should cache results', async () => {
|
||||
mockKibanaVersion = '300.0.0';
|
||||
mockKibanaVersion = '9.0.0';
|
||||
mockedReadFile.mockResolvedValue(`["8.1.0", "8.0.0", "7.17.0", "7.16.0"]`);
|
||||
mockedFetch.mockResolvedValueOnce({
|
||||
status: 200,
|
||||
|
@ -195,7 +195,7 @@ describe('getAvailableVersions', () => {
|
|||
const res = await getAvailableVersions({ ignoreCache: true });
|
||||
|
||||
// Should sort, uniquify and filter out versions < 7.17
|
||||
expect(res).toEqual(['8.1.0', '8.0.0', '7.17.0']);
|
||||
expect(res).toEqual(['300.0.0', '8.1.0', '8.0.0', '7.17.0']);
|
||||
});
|
||||
|
||||
it('should gracefully handle network errors when fetching from product versions API', async () => {
|
||||
|
@ -206,7 +206,7 @@ describe('getAvailableVersions', () => {
|
|||
const res = await getAvailableVersions({ ignoreCache: true });
|
||||
|
||||
// Should sort, uniquify and filter out versions < 7.17
|
||||
expect(res).toEqual(['8.1.0', '8.0.0', '7.17.0']);
|
||||
expect(res).toEqual(['300.0.0', '8.1.0', '8.0.0', '7.17.0']);
|
||||
});
|
||||
|
||||
it('should not fetch from product versions API when air-gapped config is set', async () => {
|
||||
|
@ -216,7 +216,7 @@ describe('getAvailableVersions', () => {
|
|||
mockConfig = { isAirGapped: true };
|
||||
const res = await getAvailableVersions({ ignoreCache: true });
|
||||
|
||||
expect(res).toEqual(['8.1.0', '8.0.0', '7.17.0']);
|
||||
expect(res).toEqual(['300.0.0', '8.1.0', '8.0.0', '7.17.0']);
|
||||
expect(mockedFetch).not.toBeCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -88,11 +88,12 @@ export const getAvailableVersions = async ({
|
|||
.filter((v: any) => semverGte(v, MINIMUM_SUPPORTED_VERSION))
|
||||
.sort((a: any, b: any) => (semverGt(a, b) ? -1 : 1));
|
||||
|
||||
// If the current stack version isn't included in the list of available versions, add it
|
||||
// at the front of the array
|
||||
const hasCurrentVersion = availableVersions.some((v) => v === kibanaVersion);
|
||||
if (includeCurrentVersion && !hasCurrentVersion) {
|
||||
availableVersions = [kibanaVersion, ...availableVersions];
|
||||
// if api versions are empty (air gapped or API not available), we add current kibana version, as the build file might not contain the latest released version
|
||||
if (
|
||||
includeCurrentVersion ||
|
||||
(apiVersions.length === 0 && !config?.internal?.onlyAllowAgentUpgradeToKnownVersions)
|
||||
) {
|
||||
availableVersions = uniq([kibanaVersion, ...availableVersions]);
|
||||
}
|
||||
|
||||
// Allow upgrading to the current stack version if this override flag is provided via `kibana.yml`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue