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

[Fleet] Fix exception in agents list when units field is missing from components #161360

Merged
merged 4 commits into from
Jul 7, 2023

Conversation

criamico
Copy link
Contributor

@criamico criamico commented Jul 6, 2023

Summary

Fix an issue found in 8.8.2 with 8.7.1 inactive agents. The agents list endpoint was returning an exception, after some investigation it was found that the issue was a missing units property in the components field of the agents.

This was a very specific edge case and in fact I could not reproduce locally, but it still happened in a minority of cases after upgrading to 8.8.2.

The agents in this case have components that look like this:

 "components": [
            {
              "id": "http/metrics-monitoring",
              "type": "http/metrics",
              "message": "Starting",
              "status": "STARTING"
            },
  ...
]

But this property was typed as mandatory so we didn't check for undefined. The actual bug was tracked here:

units: component.units.map((unit) => ({

and was causing this error:

20230706-0815-53.7265166.mp4

I also updated the type to have units as optional and fixed a couple of other places where this could cause issues.

Checklist

@criamico criamico self-assigned this Jul 6, 2023
@criamico criamico added the Team:Fleet Team label for Observability Data Collection Fleet team label Jul 6, 2023
@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.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@criamico criamico added backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) v8.10.0 v8.9.0 v8.8.3 labels Jul 6, 2023
@criamico criamico marked this pull request as ready for review July 6, 2023 14:42
@criamico criamico requested a review from a team as a code owner July 6, 2023 14:42
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@criamico
Copy link
Contributor Author

criamico commented Jul 6, 2023

@elasticmachine merge upstream

@criamico criamico added the release_note:skip Skip the PR/issue when compiling release notes label Jul 6, 2023
Copy link
Member

@nchaulet nchaulet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing that one LGTM 🚀

@criamico
Copy link
Contributor Author

criamico commented Jul 7, 2023

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
fleet 976.7KB 976.8KB +26.0B
Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
securitySolution 408 412 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
securitySolution 487 491 +4
total +6

History

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

cc @criamico

@criamico criamico merged commit 36e7d60 into elastic:main Jul 7, 2023
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jul 7, 2023
… components (elastic#161360)

## Summary
Fix an issue found in 8.8.2 with `8.7.1` inactive agents. The agents
list endpoint was returning an exception, after some investigation it
was found that the issue was a missing `units` property in the
components field of the agents.

This was a very specific edge case and in fact I could not reproduce
locally, but it still happened in a minority of cases after upgrading to
8.8.2.

The agents in this case have components that look like this:
```
 "components": [
            {
              "id": "http/metrics-monitoring",
              "type": "http/metrics",
              "message": "Starting",
              "status": "STARTING"
            },
  ...
]
```
But this property was typed as mandatory so we didn't check for
undefined. The actual bug was tracked here:

https://github.com/elastic/kibana/blob/2070836060046aaec0ff28ddfcce91356cf98930/x-pack/plugins/fleet/server/services/agents/helpers.ts#L50

and was causing this error:

https://github.com/elastic/kibana/assets/16084106/607b5aed-155b-4509-896a-ada7507e4dc3

I also updated the type to have `units` as optional and fixed a couple
of other places where this could cause issues.

### Checklist
- [ ] [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

---------

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 36e7d60)
@kibanamachine
Copy link
Contributor

💔 Some backports could not be created

Status Branch Result
8.8 Backport failed because of merge conflicts

You might need to backport the following PRs to 8.8:
- Clarify documentation for the observability:enableComparisonByDefault setting (#161372)
8.9

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

Manual backport

To create the backport manually run:

node scripts/backport --pr 161360

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jul 7, 2023
…g from components (#161360) (#161442)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Fleet] Fix exception in agents list when units field is missing from
components (#161360)](#161360)

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

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

<!--BACKPORT [{"author":{"name":"Cristina
Amico","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-07-07T10:13:37Z","message":"[Fleet]
Fix exception in agents list when units field is missing from components
(#161360)\n\n## Summary\r\nFix an issue found in 8.8.2 with `8.7.1`
inactive agents. The agents\r\nlist endpoint was returning an exception,
after some investigation it\r\nwas found that the issue was a missing
`units` property in the\r\ncomponents field of the agents.\r\n\r\nThis
was a very specific edge case and in fact I could not
reproduce\r\nlocally, but it still happened in a minority of cases after
upgrading to\r\n8.8.2.\r\n\r\nThe agents in this case have components
that look like this:\r\n```\r\n \"components\": [\r\n {\r\n \"id\":
\"http/metrics-monitoring\",\r\n \"type\": \"http/metrics\",\r\n
\"message\": \"Starting\",\r\n \"status\": \"STARTING\"\r\n },\r\n
...\r\n]\r\n```\r\nBut this property was typed as mandatory so we didn't
check for\r\nundefined. The actual bug was tracked
here:\r\n\r\nhttps://github.com/elastic/kibana/blob/2070836060046aaec0ff28ddfcce91356cf98930/x-pack/plugins/fleet/server/services/agents/helpers.ts#L50\r\n\r\nand
was causing this
error:\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/16084106/607b5aed-155b-4509-896a-ada7507e4dc3\r\n\r\nI
also updated the type to have `units` as optional and fixed a
couple\r\nof other places where this could cause issues.\r\n\r\n###
Checklist\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"36e7d600ce9cbc39b7a0e55165a65a4634b30b6c","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","backport:prev-minor","v8.9.0","v8.10.0","v8.8.3"],"number":161360,"url":"https://github.com/elastic/kibana/pull/161360","mergeCommit":{"message":"[Fleet]
Fix exception in agents list when units field is missing from components
(#161360)\n\n## Summary\r\nFix an issue found in 8.8.2 with `8.7.1`
inactive agents. The agents\r\nlist endpoint was returning an exception,
after some investigation it\r\nwas found that the issue was a missing
`units` property in the\r\ncomponents field of the agents.\r\n\r\nThis
was a very specific edge case and in fact I could not
reproduce\r\nlocally, but it still happened in a minority of cases after
upgrading to\r\n8.8.2.\r\n\r\nThe agents in this case have components
that look like this:\r\n```\r\n \"components\": [\r\n {\r\n \"id\":
\"http/metrics-monitoring\",\r\n \"type\": \"http/metrics\",\r\n
\"message\": \"Starting\",\r\n \"status\": \"STARTING\"\r\n },\r\n
...\r\n]\r\n```\r\nBut this property was typed as mandatory so we didn't
check for\r\nundefined. The actual bug was tracked
here:\r\n\r\nhttps://github.com/elastic/kibana/blob/2070836060046aaec0ff28ddfcce91356cf98930/x-pack/plugins/fleet/server/services/agents/helpers.ts#L50\r\n\r\nand
was causing this
error:\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/16084106/607b5aed-155b-4509-896a-ada7507e4dc3\r\n\r\nI
also updated the type to have `units` as optional and fixed a
couple\r\nof other places where this could cause issues.\r\n\r\n###
Checklist\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"36e7d600ce9cbc39b7a0e55165a65a4634b30b6c"}},"sourceBranch":"main","suggestedTargetBranches":["8.9","8.8"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/161360","number":161360,"mergeCommit":{"message":"[Fleet]
Fix exception in agents list when units field is missing from components
(#161360)\n\n## Summary\r\nFix an issue found in 8.8.2 with `8.7.1`
inactive agents. The agents\r\nlist endpoint was returning an exception,
after some investigation it\r\nwas found that the issue was a missing
`units` property in the\r\ncomponents field of the agents.\r\n\r\nThis
was a very specific edge case and in fact I could not
reproduce\r\nlocally, but it still happened in a minority of cases after
upgrading to\r\n8.8.2.\r\n\r\nThe agents in this case have components
that look like this:\r\n```\r\n \"components\": [\r\n {\r\n \"id\":
\"http/metrics-monitoring\",\r\n \"type\": \"http/metrics\",\r\n
\"message\": \"Starting\",\r\n \"status\": \"STARTING\"\r\n },\r\n
...\r\n]\r\n```\r\nBut this property was typed as mandatory so we didn't
check for\r\nundefined. The actual bug was tracked
here:\r\n\r\nhttps://github.com/elastic/kibana/blob/2070836060046aaec0ff28ddfcce91356cf98930/x-pack/plugins/fleet/server/services/agents/helpers.ts#L50\r\n\r\nand
was causing this
error:\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/16084106/607b5aed-155b-4509-896a-ada7507e4dc3\r\n\r\nI
also updated the type to have `units` as optional and fixed a
couple\r\nof other places where this could cause issues.\r\n\r\n###
Checklist\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine
<[email protected]>","sha":"36e7d600ce9cbc39b7a0e55165a65a4634b30b6c"}},{"branch":"8.8","label":"v8.8.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cristina Amico <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.8.3 v8.9.0 v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants