-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] Fix UI error when agent goes to orphaned state #207746
Conversation
Pinging @elastic/fleet (Team:Fleet) |
There was a problem hiding this 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?
Starting backport for target branches: 8.x |
It shouldn't be a string, maybe it's a bug in agent. I'll send it to the agent team to investigate. |
## 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)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
#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>
## 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" />
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:
_hit$_source4.components.map is not a function
no longer appears.