Skip to content

Commit

Permalink
[Profiling] Fix set up process 8.10 (#167068)
Browse files Browse the repository at this point in the history
So clients reported that they got stuck in the set up screen In the
Universal Profling UI. And when the set up button was clicked an error
happened:

```
An integration policy with the name elastic-universal-profiling-collector already exists. Please rename it or choose a different name.
```

This happens because when we were checking if the Collector and
Symbolizer integrations were installed we weren't taking into
consideration that the Fleet API is paginated. So if neither integration
was available on the first page we just assumed the Profiling wasn't set
up.

This PR fixes it by adding a kuery filter in the Fleet API call to only
look for out integrations. So we don't need to worry about paginating.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
cauemarcondes and kibanamachine committed Sep 25, 2023
1 parent cc6d78f commit cb646e0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions x-pack/plugins/profiling/server/lib/setup/fleet_policies.ts
Expand Up @@ -9,6 +9,7 @@ import { SavedObjectsClientContract } from '@kbn/core/server';
import { PackagePolicyClient } from '@kbn/fleet-plugin/server';
import { fetchFindLatestPackageOrThrow } from '@kbn/fleet-plugin/server/services/epm/registry';
import { omit } from 'lodash';
import { PACKAGE_POLICY_SAVED_OBJECT_TYPE } from '@kbn/fleet-plugin/common';
import { PackageInputType } from '../..';
import { PartialSetupState } from '../../../common/setup';
import { ELASTIC_CLOUD_APM_POLICY, getApmPolicy } from './get_apm_policy';
Expand All @@ -27,8 +28,10 @@ async function getPackagePolicy({
soClient: SavedObjectsClientContract;
packageName: string;
}) {
const packagePolicies = await packagePolicyClient.list(soClient, {});
return packagePolicies.items.find((pkg) => pkg.name === packageName);
const packagePolicies = await packagePolicyClient.list(soClient, {
kuery: `${PACKAGE_POLICY_SAVED_OBJECT_TYPE}.name:${packageName}`,
});
return packagePolicies.items[0];
}

export async function getCollectorPolicy({
Expand Down

0 comments on commit cb646e0

Please sign in to comment.