Skip to content

[9.3] [profiling] fix failing profiling tests due to [fleet-agent-policies/policy-elastic-agent-on-cloud] not found (#268428)#268450

Merged
kibanamachine merged 1 commit into
elastic:9.3from
kibanamachine:backport/9.3/pr-268428
May 8, 2026
Merged

[9.3] [profiling] fix failing profiling tests due to [fleet-agent-policies/policy-elastic-agent-on-cloud] not found (#268428)#268450
kibanamachine merged 1 commit into
elastic:9.3from
kibanamachine:backport/9.3/pr-268428

Conversation

@kibanamachine
Copy link
Copy Markdown
Contributor

Backport

This will backport the following commits from main to 9.3:

Questions ?

Please refer to the Backport tool documentation

…policy-elastic-agent-on-cloud] not found (elastic#268428)

## Summary

Closes elastic#268400
Closes elastic#268399

Profiling's `setupResources` POST takes the cloud branch (Scout's
stateful Kibana runs with `xpack.cloud.id` set), so it tries to create
the `profiler_collector` and `profiler_symbolizer` Fleet package
policies on the `policy-elastic-agent-on-cloud` agent policy, which only
`has_no_setup.spec.ts` provisions via
`profilingHelper.installPolicies()`.

When the UX Scout tests ran first, the worker order/state shifted just
enough that `has_setup_apm_not_installed.spec.ts`'s `beforeAll` reached
`setupResources` before `has_no_setup.spec.ts` had created the agent
policy, so Fleet's `packagePolicyClient.create` blew up with `Saved
object [fleet-agent-policies/policy-elastic-agent-on-cloud] not found`,
which the route surfaced as the opaque 500.

The fix makes each spec self-provision the agent policy instead of
relying on test ordering.

Tested locally:

```
# start servers
node scripts/scout start-server --arch stateful --domain classic

# run ux tests first
npx playwright test --project local --grep @local-stateful-classic --config x-pack/solutions/observability/plugins/ux/test/scout/ui/playwright.config.ts

# run profiling tests
npx playwright test --project local --grep @local-stateful-classic --config x-pack/solutions/observability/plugins/profiling/test/scout/api/playwright.config.ts
```

Before the fix the following error occured:

```
 proc [kibana] [2026-05-08T14:05:35.889+02:00][ERROR][plugins.profiling] Error: Saved object [fleet-agent-policies/policy-elastic-agent-on-cloud] not found
 proc [kibana]     at SavedObjectsErrorHelpers.createGenericNotFoundError (saved_objects_error_helpers.ts:284:28)
 proc [kibana]     at agent_policy.ts:752:40
 proc [kibana]     at processTicksAndRejections (node:internal/process/task_queues:104:5)
 proc [kibana]     at AgentPolicyService.get (agent_policy.ts:747:27)
 proc [kibana]     at PackagePolicyClientImpl.create (package_policy.ts:547:27)
 proc [kibana]     at createCollectorPackagePolicy (fleet_policies.ts:89:3)
 proc [kibana]     at async Promise.all (index 0)
 proc [kibana]     at setupCloud (setup_cloud.ts:36:3)
 proc [kibana]     at route.ts:139:11
 proc [kibana]     at handle (route.ts:161:26)
 proc [kibana]     at handler (route.ts:78:14)
 proc [kibana]     at Router.handle (router.ts:209:30)
 proc [kibana]     at exports.Manager.execute (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/toolkit.js:60:28)
 proc [kibana]     at Object.internals.handler (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/handler.js:46:20)
 proc [kibana]     at exports.execute (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/handler.js:31:20)
 proc [kibana]     at Request._lifecycle (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/request.js:384:32)
 proc [kibana]     at Request._execute (/Users/dmle/elastic/github/kibana/node_modules/@hapi/hapi/lib/request.js:294:9) {"service":{"version":"9.5.0","type":"kibana","state":"available","node":{"roles":["background_tasks","ui"]},"id":"_jN54-qzRc2aypW_5PVHdw"}}
```

(cherry picked from commit 40f2b94)
@kibanamachine kibanamachine added the backport This PR is a backport of another PR label May 8, 2026
@kibanamachine kibanamachine enabled auto-merge (squash) May 8, 2026 14:01
@kibanamachine
Copy link
Copy Markdown
Contributor Author

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

cc @dmlemeshko

@kibanamachine kibanamachine merged commit 46aa16e into elastic:9.3 May 8, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants