Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.9] [Fleet] Fix exception in agents list when units field is missin…
…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]>
- Loading branch information