From 45f5f3d14c414d7873475e0e49b74919c62c64c3 Mon Sep 17 00:00:00 2001
From: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
Date: Mon, 13 Feb 2023 12:58:04 +0100
Subject: [PATCH] [Fleet] fixed bug where installed beta integration was
visible multiple times (#150979)
## Summary
Fixes https://github.com/elastic/kibana/issues/150969
Filtering for only uploaded packages that are not in registry.
This fixes of bug of linux integration showing up multiple times when
the `/packages` call with `prerelease:false` and `prerelease:true`
options are quickly following each other.
To verify:
- Navigate to Integrations, search `linux`.
- Add linux integration to agent policy.
- Repeat the same process again.
- Navigate back to Integrations and search `linux`.
- Only one Linux metrics integration card should be visible.
Uploaded integrations are still visible:
### 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
---
.../fleet/server/services/epm/packages/get.test.ts | 6 +++---
x-pack/plugins/fleet/server/services/epm/packages/get.ts | 8 +++++---
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/x-pack/plugins/fleet/server/services/epm/packages/get.test.ts b/x-pack/plugins/fleet/server/services/epm/packages/get.test.ts
index 52170f6c302fd..661784a99ced5 100644
--- a/x-pack/plugins/fleet/server/services/epm/packages/get.test.ts
+++ b/x-pack/plugins/fleet/server/services/epm/packages/get.test.ts
@@ -209,7 +209,7 @@ describe('When using EPM `get` services', () => {
attributes: {
name: 'elasticsearch',
version: '0.0.1',
- install_status: 'upload',
+ install_source: 'upload',
},
},
],
@@ -221,16 +221,16 @@ describe('When using EPM `get` services', () => {
})
).resolves.toMatchObject([
{
+ id: 'elasticsearch',
name: 'elasticsearch',
version: '0.0.1',
title: 'Elasticsearch',
- status: 'upload',
savedObject: {
id: 'elasticsearch',
attributes: {
name: 'elasticsearch',
version: '0.0.1',
- install_status: 'upload',
+ install_source: 'upload',
},
},
},
diff --git a/x-pack/plugins/fleet/server/services/epm/packages/get.ts b/x-pack/plugins/fleet/server/services/epm/packages/get.ts
index 83db878ef5b83..7baddd428076b 100644
--- a/x-pack/plugins/fleet/server/services/epm/packages/get.ts
+++ b/x-pack/plugins/fleet/server/services/epm/packages/get.ts
@@ -74,9 +74,11 @@ export async function getPackages(
// get the installed packages
const packageSavedObjects = await getPackageSavedObjects(savedObjectsClient);
- const packagesNotInRegistry = packageSavedObjects.saved_objects
+ const uploadedPackagesNotInRegistry = packageSavedObjects.saved_objects
.filter((pkg) => !registryItems.some((item) => item.name === pkg.id))
- .map((pkg) => createInstallableFrom({ ...pkg.attributes, title: nameAsTitle(pkg.id) }, pkg));
+ .map((pkg) =>
+ createInstallableFrom({ ...pkg.attributes, title: nameAsTitle(pkg.id), id: pkg.id }, pkg)
+ );
const packageList = registryItems
.map((item) =>
@@ -85,7 +87,7 @@ export async function getPackages(
packageSavedObjects.saved_objects.find(({ id }) => id === item.name)
)
)
- .concat(packagesNotInRegistry as Installable)
+ .concat(uploadedPackagesNotInRegistry as Installable)
.sort(sortByName);
if (!excludeInstallStatus) {