Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Profiling] fix bug when APM integration is no available #165809

Merged

Conversation

cauemarcondes
Copy link
Contributor

@cauemarcondes cauemarcondes commented Sep 6, 2023

We've identified a buggy scenario when a user has a cluster prior 8.5 and wants to upgrade to >8.9. In this case, Profiling looks after the elastic-cloud-apm integration to see if Profiling had been enabled previously. But for the versions before 8.5 this integration did not exist under this name causing the set up to crash.

I fixed the issue by catching the exception and returning that profiling is not enabled on the apm server, as it's not installed.

Before:

Error: Saved object [ingest-package-policies/elastic-cloud-apm] not found
    at Function.createGenericNotFoundError (saved_objects_error_helpers.ts:258:28)
    at performGet (get.ts:80:36)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at SavedObjectsRepository.get (repository.ts:370:12)
    at SavedObjectsClient.get (saved_objects_client.ts:119:12)
    at PackagePolicyClientImpl.get (package_policy.ts:495:29)
    at validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)
    at async Promise.all (index 5)
    at setup.ts:99:31
    at Router.handle (router.ts:212:30)
    at handler (router.ts:162:13)
    at exports.Manager.execute (/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib

After:

{
  "has_setup": false,
  "has_data": false,
  "pre_8_9_1_data": false
}

@cauemarcondes cauemarcondes added release_note:skip Skip the PR/issue when compiling release notes v8.10.0 labels Sep 6, 2023
@cauemarcondes cauemarcondes requested a review from a team as a code owner September 6, 2023 08:56
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@cauemarcondes cauemarcondes changed the title [Profiling] fix bug when APM server is no available [Profiling] fix bug when APM integration is no available Sep 6, 2023
@cauemarcondes
Copy link
Contributor Author

/oblt-deploy

@inge4pres inge4pres added v8.9.3 and removed v8.9.2 labels Sep 6, 2023
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] Serverless Security Explore Cypress Tests #2 / Cases connectors "before each" hook for "Configures a new connector" "before each" hook for "Configures a new connector"

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@cauemarcondes cauemarcondes enabled auto-merge (squash) September 6, 2023 11:22
@cauemarcondes cauemarcondes merged commit a00e5e3 into elastic:main Sep 6, 2023
@cauemarcondes cauemarcondes deleted the profiling-fix-apm-server-bug branch September 6, 2023 11:31
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 6, 2023
)

We've identified a buggy scenario when a user has a cluster prior 8.5
and wants to upgrade to >8.9. In this case, Profiling looks after the
`elastic-cloud-apm` integration to see if Profiling had been enabled
previously. But for the versions before 8.5 this integration did not
exist under this name causing the set up to crash.

I fixed the issue by catching the exception and returning that profiling
is not enabled on the apm server, as it's not installed.

Before:
```
Error: Saved object [ingest-package-policies/elastic-cloud-apm] not found
    at Function.createGenericNotFoundError (saved_objects_error_helpers.ts:258:28)
    at performGet (get.ts:80:36)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at SavedObjectsRepository.get (repository.ts:370:12)
    at SavedObjectsClient.get (saved_objects_client.ts:119:12)
    at PackagePolicyClientImpl.get (package_policy.ts:495:29)
    at validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)
    at async Promise.all (index 5)
    at setup.ts:99:31
    at Router.handle (router.ts:212:30)
    at handler (router.ts:162:13)
    at exports.Manager.execute (/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib
```

After:
```
{
  "has_setup": false,
  "has_data": false,
  "pre_8_9_1_data": false
}
```

---------

Co-authored-by: Francesco Gualazzi <[email protected]>
(cherry picked from commit a00e5e3)
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 6, 2023
)

We've identified a buggy scenario when a user has a cluster prior 8.5
and wants to upgrade to >8.9. In this case, Profiling looks after the
`elastic-cloud-apm` integration to see if Profiling had been enabled
previously. But for the versions before 8.5 this integration did not
exist under this name causing the set up to crash.

I fixed the issue by catching the exception and returning that profiling
is not enabled on the apm server, as it's not installed.

Before:
```
Error: Saved object [ingest-package-policies/elastic-cloud-apm] not found
    at Function.createGenericNotFoundError (saved_objects_error_helpers.ts:258:28)
    at performGet (get.ts:80:36)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at SavedObjectsRepository.get (repository.ts:370:12)
    at SavedObjectsClient.get (saved_objects_client.ts:119:12)
    at PackagePolicyClientImpl.get (package_policy.ts:495:29)
    at validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)
    at async Promise.all (index 5)
    at setup.ts:99:31
    at Router.handle (router.ts:212:30)
    at handler (router.ts:162:13)
    at exports.Manager.execute (/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib
```

After:
```
{
  "has_setup": false,
  "has_data": false,
  "pre_8_9_1_data": false
}
```

---------

Co-authored-by: Francesco Gualazzi <[email protected]>
(cherry picked from commit a00e5e3)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.10
8.9

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Sep 6, 2023
…) (#165835)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Profiling] fix bug when APM integration is no available
(#165809)](#165809)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cauê
Marcondes","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-09-06T11:29:42Z","message":"[Profiling]
fix bug when APM integration is no available (#165809)\n\nWe've
identified a buggy scenario when a user has a cluster prior 8.5\r\nand
wants to upgrade to >8.9. In this case, Profiling looks after
the\r\n`elastic-cloud-apm` integration to see if Profiling had been
enabled\r\npreviously. But for the versions before 8.5 this integration
did not\r\nexist under this name causing the set up to crash.\r\n\r\nI
fixed the issue by catching the exception and returning that
profiling\r\nis not enabled on the apm server, as it's not
installed.\r\n\r\nBefore:\r\n```\r\nError: Saved object
[ingest-package-policies/elastic-cloud-apm] not found\r\n at
Function.createGenericNotFoundError
(saved_objects_error_helpers.ts:258:28)\r\n at performGet
(get.ts:80:36)\r\n at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at
SavedObjectsRepository.get (repository.ts:370:12)\r\n at
SavedObjectsClient.get (saved_objects_client.ts:119:12)\r\n at
PackagePolicyClientImpl.get (package_policy.ts:495:29)\r\n at
validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)\r\n at
async Promise.all (index 5)\r\n at setup.ts:99:31\r\n at Router.handle
(router.ts:212:30)\r\n at handler (router.ts:162:13)\r\n at
exports.Manager.execute
(/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib\r\n```\r\n\r\nAfter:\r\n```\r\n{\r\n
\"has_setup\": false,\r\n \"has_data\": false,\r\n \"pre_8_9_1_data\":
false\r\n}\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco
Gualazzi
<[email protected]>","sha":"a00e5e378800d0eda047b59228a48b816541e132","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:skip","ci:build-cloud-image","v8.10.0","v8.11.0","v8.9.3"],"number":165809,"url":"https://github.com/elastic/kibana/pull/165809","mergeCommit":{"message":"[Profiling]
fix bug when APM integration is no available (#165809)\n\nWe've
identified a buggy scenario when a user has a cluster prior 8.5\r\nand
wants to upgrade to >8.9. In this case, Profiling looks after
the\r\n`elastic-cloud-apm` integration to see if Profiling had been
enabled\r\npreviously. But for the versions before 8.5 this integration
did not\r\nexist under this name causing the set up to crash.\r\n\r\nI
fixed the issue by catching the exception and returning that
profiling\r\nis not enabled on the apm server, as it's not
installed.\r\n\r\nBefore:\r\n```\r\nError: Saved object
[ingest-package-policies/elastic-cloud-apm] not found\r\n at
Function.createGenericNotFoundError
(saved_objects_error_helpers.ts:258:28)\r\n at performGet
(get.ts:80:36)\r\n at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at
SavedObjectsRepository.get (repository.ts:370:12)\r\n at
SavedObjectsClient.get (saved_objects_client.ts:119:12)\r\n at
PackagePolicyClientImpl.get (package_policy.ts:495:29)\r\n at
validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)\r\n at
async Promise.all (index 5)\r\n at setup.ts:99:31\r\n at Router.handle
(router.ts:212:30)\r\n at handler (router.ts:162:13)\r\n at
exports.Manager.execute
(/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib\r\n```\r\n\r\nAfter:\r\n```\r\n{\r\n
\"has_setup\": false,\r\n \"has_data\": false,\r\n \"pre_8_9_1_data\":
false\r\n}\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco
Gualazzi
<[email protected]>","sha":"a00e5e378800d0eda047b59228a48b816541e132"}},"sourceBranch":"main","suggestedTargetBranches":["8.10","8.9"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/165809","number":165809,"mergeCommit":{"message":"[Profiling]
fix bug when APM integration is no available (#165809)\n\nWe've
identified a buggy scenario when a user has a cluster prior 8.5\r\nand
wants to upgrade to >8.9. In this case, Profiling looks after
the\r\n`elastic-cloud-apm` integration to see if Profiling had been
enabled\r\npreviously. But for the versions before 8.5 this integration
did not\r\nexist under this name causing the set up to crash.\r\n\r\nI
fixed the issue by catching the exception and returning that
profiling\r\nis not enabled on the apm server, as it's not
installed.\r\n\r\nBefore:\r\n```\r\nError: Saved object
[ingest-package-policies/elastic-cloud-apm] not found\r\n at
Function.createGenericNotFoundError
(saved_objects_error_helpers.ts:258:28)\r\n at performGet
(get.ts:80:36)\r\n at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at
SavedObjectsRepository.get (repository.ts:370:12)\r\n at
SavedObjectsClient.get (saved_objects_client.ts:119:12)\r\n at
PackagePolicyClientImpl.get (package_policy.ts:495:29)\r\n at
validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)\r\n at
async Promise.all (index 5)\r\n at setup.ts:99:31\r\n at Router.handle
(router.ts:212:30)\r\n at handler (router.ts:162:13)\r\n at
exports.Manager.execute
(/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib\r\n```\r\n\r\nAfter:\r\n```\r\n{\r\n
\"has_setup\": false,\r\n \"has_data\": false,\r\n \"pre_8_9_1_data\":
false\r\n}\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco
Gualazzi
<[email protected]>","sha":"a00e5e378800d0eda047b59228a48b816541e132"}},{"branch":"8.9","label":"v8.9.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cauê Marcondes <[email protected]>
kibanamachine added a commit that referenced this pull request Sep 6, 2023
) (#165833)

# Backport

This will backport the following commits from `main` to `8.10`:
- [[Profiling] fix bug when APM integration is no available
(#165809)](#165809)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cauê
Marcondes","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-09-06T11:29:42Z","message":"[Profiling]
fix bug when APM integration is no available (#165809)\n\nWe've
identified a buggy scenario when a user has a cluster prior 8.5\r\nand
wants to upgrade to >8.9. In this case, Profiling looks after
the\r\n`elastic-cloud-apm` integration to see if Profiling had been
enabled\r\npreviously. But for the versions before 8.5 this integration
did not\r\nexist under this name causing the set up to crash.\r\n\r\nI
fixed the issue by catching the exception and returning that
profiling\r\nis not enabled on the apm server, as it's not
installed.\r\n\r\nBefore:\r\n```\r\nError: Saved object
[ingest-package-policies/elastic-cloud-apm] not found\r\n at
Function.createGenericNotFoundError
(saved_objects_error_helpers.ts:258:28)\r\n at performGet
(get.ts:80:36)\r\n at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at
SavedObjectsRepository.get (repository.ts:370:12)\r\n at
SavedObjectsClient.get (saved_objects_client.ts:119:12)\r\n at
PackagePolicyClientImpl.get (package_policy.ts:495:29)\r\n at
validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)\r\n at
async Promise.all (index 5)\r\n at setup.ts:99:31\r\n at Router.handle
(router.ts:212:30)\r\n at handler (router.ts:162:13)\r\n at
exports.Manager.execute
(/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib\r\n```\r\n\r\nAfter:\r\n```\r\n{\r\n
\"has_setup\": false,\r\n \"has_data\": false,\r\n \"pre_8_9_1_data\":
false\r\n}\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco
Gualazzi
<[email protected]>","sha":"a00e5e378800d0eda047b59228a48b816541e132","branchLabelMapping":{"^v8.11.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["backport","release_note:skip","ci:build-cloud-image","v8.10.0","v8.11.0","v8.9.3"],"number":165809,"url":"https://github.com/elastic/kibana/pull/165809","mergeCommit":{"message":"[Profiling]
fix bug when APM integration is no available (#165809)\n\nWe've
identified a buggy scenario when a user has a cluster prior 8.5\r\nand
wants to upgrade to >8.9. In this case, Profiling looks after
the\r\n`elastic-cloud-apm` integration to see if Profiling had been
enabled\r\npreviously. But for the versions before 8.5 this integration
did not\r\nexist under this name causing the set up to crash.\r\n\r\nI
fixed the issue by catching the exception and returning that
profiling\r\nis not enabled on the apm server, as it's not
installed.\r\n\r\nBefore:\r\n```\r\nError: Saved object
[ingest-package-policies/elastic-cloud-apm] not found\r\n at
Function.createGenericNotFoundError
(saved_objects_error_helpers.ts:258:28)\r\n at performGet
(get.ts:80:36)\r\n at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at
SavedObjectsRepository.get (repository.ts:370:12)\r\n at
SavedObjectsClient.get (saved_objects_client.ts:119:12)\r\n at
PackagePolicyClientImpl.get (package_policy.ts:495:29)\r\n at
validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)\r\n at
async Promise.all (index 5)\r\n at setup.ts:99:31\r\n at Router.handle
(router.ts:212:30)\r\n at handler (router.ts:162:13)\r\n at
exports.Manager.execute
(/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib\r\n```\r\n\r\nAfter:\r\n```\r\n{\r\n
\"has_setup\": false,\r\n \"has_data\": false,\r\n \"pre_8_9_1_data\":
false\r\n}\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco
Gualazzi
<[email protected]>","sha":"a00e5e378800d0eda047b59228a48b816541e132"}},"sourceBranch":"main","suggestedTargetBranches":["8.10","8.9"],"targetPullRequestStates":[{"branch":"8.10","label":"v8.10.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.11.0","labelRegex":"^v8.11.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/165809","number":165809,"mergeCommit":{"message":"[Profiling]
fix bug when APM integration is no available (#165809)\n\nWe've
identified a buggy scenario when a user has a cluster prior 8.5\r\nand
wants to upgrade to >8.9. In this case, Profiling looks after
the\r\n`elastic-cloud-apm` integration to see if Profiling had been
enabled\r\npreviously. But for the versions before 8.5 this integration
did not\r\nexist under this name causing the set up to crash.\r\n\r\nI
fixed the issue by catching the exception and returning that
profiling\r\nis not enabled on the apm server, as it's not
installed.\r\n\r\nBefore:\r\n```\r\nError: Saved object
[ingest-package-policies/elastic-cloud-apm] not found\r\n at
Function.createGenericNotFoundError
(saved_objects_error_helpers.ts:258:28)\r\n at performGet
(get.ts:80:36)\r\n at processTicksAndRejections
(node:internal/process/task_queues:95:5)\r\n at
SavedObjectsRepository.get (repository.ts:370:12)\r\n at
SavedObjectsClient.get (saved_objects_client.ts:119:12)\r\n at
PackagePolicyClientImpl.get (package_policy.ts:495:29)\r\n at
validateProfilingInApmPackagePolicy (fleet_policies.ts:193:23)\r\n at
async Promise.all (index 5)\r\n at setup.ts:99:31\r\n at Router.handle
(router.ts:212:30)\r\n at handler (router.ts:162:13)\r\n at
exports.Manager.execute
(/Users/caue.marcondes/elastic/other_kibana/node_modules/@hapi/hapi/lib\r\n```\r\n\r\nAfter:\r\n```\r\n{\r\n
\"has_setup\": false,\r\n \"has_data\": false,\r\n \"pre_8_9_1_data\":
false\r\n}\r\n```\r\n\r\n---------\r\n\r\nCo-authored-by: Francesco
Gualazzi
<[email protected]>","sha":"a00e5e378800d0eda047b59228a48b816541e132"}},{"branch":"8.9","label":"v8.9.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cauê Marcondes <[email protected]>
@mistic mistic removed the v8.9.2 label Sep 7, 2023
@mistic
Copy link
Member

mistic commented Sep 7, 2023

This PR didn't make it into the latest BC for 8.8.2 Updating the labels

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants