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 UI error when agent goes to orphaned state #207746

Merged
merged 1 commit into from
Jan 22, 2025

Conversation

juliaElastic
Copy link
Contributor

@juliaElastic juliaElastic commented Jan 22, 2025

Summary

Closes elastic/elastic-agent#6572

It seems that when the orphaned agent service is restarted, it briefly has a component state string, instead of array, that's why the error. The fix checks that the components is an array before calling map.

To verify:

  1. Enroll an agent to an agent policy with endpoint integration.
  2. Stop agent service so that agent gets into orphaned state.
  3. Now restart the service and observe that the error _hit$_source4.components.map is not a function no longer appears.
image image

@juliaElastic juliaElastic added release_note:fix backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) labels Jan 22, 2025
@juliaElastic juliaElastic self-assigned this Jan 22, 2025
@juliaElastic juliaElastic requested a review from a team as a code owner January 22, 2025 12:03
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Jan 22, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

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.

Code LGTM 🚀

I am wondering why components is a string here? should we update our type accordingly or try to fix the underlying issue?

@juliaElastic juliaElastic merged commit 9800147 into elastic:main Jan 22, 2025
15 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.x

https://github.com/elastic/kibana/actions/runs/12910191518

@juliaElastic
Copy link
Contributor Author

I am wondering why components is a string here? should we update our type accordingly or try to fix the underlying issue?

It shouldn't be a string, maybe it's a bug in agent. I'll send it to the agent team to investigate.

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Jan 22, 2025
## Summary

Closes https://github.com/elastic/kibana/issues/207017

It seems that when the orphaned agent service is restarted, it briefly
has a component state string, instead of array, that's why the error.
The fix checks that the components is an array before calling map.

To verify:
1. Enroll an agent to an agent policy with endpoint integration.
2. Stop agent service so that agent gets into orphaned state.
3. Now restart the service and observe that the error
`_hit$_source4.components.map is not a function` no longer appears.

<img width="1531" alt="image"
src="https://github.com/user-attachments/assets/c9a957d7-a0d3-4831-90f9-a57479193ee0"
/>
<img width="1530" alt="image"
src="https://github.com/user-attachments/assets/c0aa62f0-708b-463e-9184-01d8641c8f21"
/>

(cherry picked from commit 9800147)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

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 Jan 22, 2025
#207836)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Fleet] Fix UI error when agent goes to orphaned state
(#207746)](#207746)

<!--- Backport version: 9.4.3 -->

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

<!--BACKPORT [{"author":{"name":"Julia
Bardi","email":"90178898+juliaElastic@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-01-22T14:20:03Z","message":"[Fleet]
Fix UI error when agent goes to orphaned state (#207746)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/207017\r\n\r\nIt seems that
when the orphaned agent service is restarted, it briefly\r\nhas a
component state string, instead of array, that's why the error.\r\nThe
fix checks that the components is an array before calling map.\r\n\r\nTo
verify:\r\n1. Enroll an agent to an agent policy with endpoint
integration.\r\n2. Stop agent service so that agent gets into orphaned
state.\r\n3. Now restart the service and observe that the
error\r\n`_hit$_source4.components.map is not a function` no longer
appears.\r\n\r\n<img width=\"1531\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c9a957d7-a0d3-4831-90f9-a57479193ee0\"\r\n/>\r\n<img
width=\"1530\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c0aa62f0-708b-463e-9184-01d8641c8f21\"\r\n/>","sha":"9800147681323f95f5e951328f9f56a399796350","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","v9.0.0","backport:prev-minor"],"title":"[Fleet]
Fix UI error when agent goes to orphaned
state","number":207746,"url":"https://github.com/elastic/kibana/pull/207746","mergeCommit":{"message":"[Fleet]
Fix UI error when agent goes to orphaned state (#207746)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/207017\r\n\r\nIt seems that
when the orphaned agent service is restarted, it briefly\r\nhas a
component state string, instead of array, that's why the error.\r\nThe
fix checks that the components is an array before calling map.\r\n\r\nTo
verify:\r\n1. Enroll an agent to an agent policy with endpoint
integration.\r\n2. Stop agent service so that agent gets into orphaned
state.\r\n3. Now restart the service and observe that the
error\r\n`_hit$_source4.components.map is not a function` no longer
appears.\r\n\r\n<img width=\"1531\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c9a957d7-a0d3-4831-90f9-a57479193ee0\"\r\n/>\r\n<img
width=\"1530\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c0aa62f0-708b-463e-9184-01d8641c8f21\"\r\n/>","sha":"9800147681323f95f5e951328f9f56a399796350"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/207746","number":207746,"mergeCommit":{"message":"[Fleet]
Fix UI error when agent goes to orphaned state (#207746)\n\n##
Summary\r\n\r\nCloses
https://github.com/elastic/kibana/issues/207017\r\n\r\nIt seems that
when the orphaned agent service is restarted, it briefly\r\nhas a
component state string, instead of array, that's why the error.\r\nThe
fix checks that the components is an array before calling map.\r\n\r\nTo
verify:\r\n1. Enroll an agent to an agent policy with endpoint
integration.\r\n2. Stop agent service so that agent gets into orphaned
state.\r\n3. Now restart the service and observe that the
error\r\n`_hit$_source4.components.map is not a function` no longer
appears.\r\n\r\n<img width=\"1531\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c9a957d7-a0d3-4831-90f9-a57479193ee0\"\r\n/>\r\n<img
width=\"1530\"
alt=\"image\"\r\nsrc=\"https://github.com/user-attachments/assets/c0aa62f0-708b-463e-9184-01d8641c8f21\"\r\n/>","sha":"9800147681323f95f5e951328f9f56a399796350"}}]}]
BACKPORT-->

Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
viduni94 pushed a commit to viduni94/kibana that referenced this pull request Jan 23, 2025
## Summary

Closes https://github.com/elastic/kibana/issues/207017

It seems that when the orphaned agent service is restarted, it briefly
has a component state string, instead of array, that's why the error.
The fix checks that the components is an array before calling map.

To verify:
1. Enroll an agent to an agent policy with endpoint integration.
2. Stop agent service so that agent gets into orphaned state.
3. Now restart the service and observe that the error
`_hit$_source4.components.map is not a function` no longer appears.

<img width="1531" alt="image"
src="https://github.com/user-attachments/assets/c9a957d7-a0d3-4831-90f9-a57479193ee0"
/>
<img width="1530" alt="image"
src="https://github.com/user-attachments/assets/c0aa62f0-708b-463e-9184-01d8641c8f21"
/>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (9.0) the previous minor version (i.e. one version back from main) release_note:fix Team:Fleet Team label for Observability Data Collection Fleet team v8.18.0 v9.0.0
Projects
None yet
4 participants