-
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] Prevent deletion of agent policies with inactive agents from UI #175815
[Fleet] Prevent deletion of agent policies with inactive agents from UI #175815
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
/ci |
ec5b043
to
06e2015
Compare
@elasticmachine merge upstream |
/ci |
Pinging @elastic/fleet (Team:Fleet) |
const { total } = await getAgentsByKuery(esClient, soClient, { | ||
showInactive: false, | ||
showInactive: true, | ||
perPage: 0, | ||
page: 1, | ||
kuery: `${AGENTS_PREFIX}.policy_id:${id}`, |
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.
Should we add the unenrolled condition here too and not status: unenrolled
?
@elasticmachine merge upstream |
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.
LGTM 🚀
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @criamico |
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…UI (elastic#175815) Fixes elastic#155925 ## Summary Prevent deleting an agent policy that has inactive agents assigned. The workaround to fix existing "orphaned" agents is outlined [here](elastic#155925 (comment)). ### API Adding check for inactive agents to the agent policy "delete" endpoint - It will now fail if the policy has either active or inactive agents: ``` POST /api/fleet/agent_policies/delete { agentPolicyId: 1234534, } ``` ### UI Warning added to the "delete" action in the UI when trying to delete a policy that has active or inactive agents. ## Testing - Have a policy with many inactive agents assigned to it - Try to delete it from the agent policy list or settings - The deletion is prevented and a warning is raised: ![Screenshot 2024-01-31 at 12 03 11](https://github.com/elastic/kibana/assets/16084106/644c9e9e-9820-4251-81fb-58f74ab57377) ### Checklist - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 222e894) # Conflicts: # x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/components/agent_policy_delete_provider.tsx # x-pack/plugins/fleet/server/services/agent_policy.ts
…s from UI (#175815) (#176131) # Backport This will backport the following commits from `main` to `8.12`: - [[Fleet] Prevent deletion of agent policies with inactive agents from UI (#175815)](#175815) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Cristina Amico","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-02-01T20:25:45Z","message":"[Fleet] Prevent deletion of agent policies with inactive agents from UI (#175815)\n\nFixes https://github.com/elastic/kibana/issues/155925\r\n\r\n## Summary\r\nPrevent deleting an agent policy that has inactive agents assigned. The\r\nworkaround to fix existing \"orphaned\" agents is outlined\r\n[here](https://github.com/elastic/kibana/issues/155925#issuecomment-1919250162).\r\n\r\n### API\r\nAdding check for inactive agents to the agent policy \"delete\" endpoint -\r\nIt will now fail if the policy has either active or inactive agents:\r\n\r\n```\r\n POST /api/fleet/agent_policies/delete\r\n {\r\n agentPolicyId: 1234534,\r\n }\r\n```\r\n\r\n### UI \r\nWarning added to the \"delete\" action in the UI when trying to delete a\r\npolicy that has active or inactive agents.\r\n\r\n## Testing\r\n- Have a policy with many inactive agents assigned to it\r\n- Try to delete it from the agent policy list or settings\r\n- The deletion is prevented and a warning is raised:\r\n\r\n![Screenshot 2024-01-31 at 12 03\r\n11](https://github.com/elastic/kibana/assets/16084106/644c9e9e-9820-4251-81fb-58f74ab57377)\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\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":"222e894b8a483cd4a22c81dfcd2bec633a45e421","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Fleet","backport:prev-minor","v8.13.0"],"number":175815,"url":"https://github.com/elastic/kibana/pull/175815","mergeCommit":{"message":"[Fleet] Prevent deletion of agent policies with inactive agents from UI (#175815)\n\nFixes https://github.com/elastic/kibana/issues/155925\r\n\r\n## Summary\r\nPrevent deleting an agent policy that has inactive agents assigned. The\r\nworkaround to fix existing \"orphaned\" agents is outlined\r\n[here](https://github.com/elastic/kibana/issues/155925#issuecomment-1919250162).\r\n\r\n### API\r\nAdding check for inactive agents to the agent policy \"delete\" endpoint -\r\nIt will now fail if the policy has either active or inactive agents:\r\n\r\n```\r\n POST /api/fleet/agent_policies/delete\r\n {\r\n agentPolicyId: 1234534,\r\n }\r\n```\r\n\r\n### UI \r\nWarning added to the \"delete\" action in the UI when trying to delete a\r\npolicy that has active or inactive agents.\r\n\r\n## Testing\r\n- Have a policy with many inactive agents assigned to it\r\n- Try to delete it from the agent policy list or settings\r\n- The deletion is prevented and a warning is raised:\r\n\r\n![Screenshot 2024-01-31 at 12 03\r\n11](https://github.com/elastic/kibana/assets/16084106/644c9e9e-9820-4251-81fb-58f74ab57377)\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\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":"222e894b8a483cd4a22c81dfcd2bec633a45e421"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/175815","number":175815,"mergeCommit":{"message":"[Fleet] Prevent deletion of agent policies with inactive agents from UI (#175815)\n\nFixes https://github.com/elastic/kibana/issues/155925\r\n\r\n## Summary\r\nPrevent deleting an agent policy that has inactive agents assigned. The\r\nworkaround to fix existing \"orphaned\" agents is outlined\r\n[here](https://github.com/elastic/kibana/issues/155925#issuecomment-1919250162).\r\n\r\n### API\r\nAdding check for inactive agents to the agent policy \"delete\" endpoint -\r\nIt will now fail if the policy has either active or inactive agents:\r\n\r\n```\r\n POST /api/fleet/agent_policies/delete\r\n {\r\n agentPolicyId: 1234534,\r\n }\r\n```\r\n\r\n### UI \r\nWarning added to the \"delete\" action in the UI when trying to delete a\r\npolicy that has active or inactive agents.\r\n\r\n## Testing\r\n- Have a policy with many inactive agents assigned to it\r\n- Try to delete it from the agent policy list or settings\r\n- The deletion is prevented and a warning is raised:\r\n\r\n![Screenshot 2024-01-31 at 12 03\r\n11](https://github.com/elastic/kibana/assets/16084106/644c9e9e-9820-4251-81fb-58f74ab57377)\r\n\r\n\r\n\r\n### Checklist\r\n\r\n- [ ]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas added for features that require explanation or tutorials\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":"222e894b8a483cd4a22c81dfcd2bec633a45e421"}}]}] BACKPORT--> --------- Co-authored-by: Kibana Machine <[email protected]>
This PR didn't make it on time to the latest build candidate of v8.12.1. Updating the labels. |
…UI (elastic#175815) Fixes elastic#155925 ## Summary Prevent deleting an agent policy that has inactive agents assigned. The workaround to fix existing "orphaned" agents is outlined [here](elastic#155925 (comment)). ### API Adding check for inactive agents to the agent policy "delete" endpoint - It will now fail if the policy has either active or inactive agents: ``` POST /api/fleet/agent_policies/delete { agentPolicyId: 1234534, } ``` ### UI Warning added to the "delete" action in the UI when trying to delete a policy that has active or inactive agents. ## Testing - Have a policy with many inactive agents assigned to it - Try to delete it from the agent policy list or settings - The deletion is prevented and a warning is raised: ![Screenshot 2024-01-31 at 12 03 11](https://github.com/elastic/kibana/assets/16084106/644c9e9e-9820-4251-81fb-58f74ab57377) ### Checklist - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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]>
…UI (elastic#175815) Fixes elastic#155925 ## Summary Prevent deleting an agent policy that has inactive agents assigned. The workaround to fix existing "orphaned" agents is outlined [here](elastic#155925 (comment)). ### API Adding check for inactive agents to the agent policy "delete" endpoint - It will now fail if the policy has either active or inactive agents: ``` POST /api/fleet/agent_policies/delete { agentPolicyId: 1234534, } ``` ### UI Warning added to the "delete" action in the UI when trying to delete a policy that has active or inactive agents. ## Testing - Have a policy with many inactive agents assigned to it - Try to delete it from the agent policy list or settings - The deletion is prevented and a warning is raised: ![Screenshot 2024-01-31 at 12 03 11](https://github.com/elastic/kibana/assets/16084106/644c9e9e-9820-4251-81fb-58f74ab57377) ### Checklist - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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]>
…UI (elastic#175815) Fixes elastic#155925 ## Summary Prevent deleting an agent policy that has inactive agents assigned. The workaround to fix existing "orphaned" agents is outlined [here](elastic#155925 (comment)). ### API Adding check for inactive agents to the agent policy "delete" endpoint - It will now fail if the policy has either active or inactive agents: ``` POST /api/fleet/agent_policies/delete { agentPolicyId: 1234534, } ``` ### UI Warning added to the "delete" action in the UI when trying to delete a policy that has active or inactive agents. ## Testing - Have a policy with many inactive agents assigned to it - Try to delete it from the agent policy list or settings - The deletion is prevented and a warning is raised: ![Screenshot 2024-01-31 at 12 03 11](https://github.com/elastic/kibana/assets/16084106/644c9e9e-9820-4251-81fb-58f74ab57377) ### Checklist - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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]>
Fixes #155925
Summary
Prevent deleting an agent policy that has inactive agents assigned. The workaround to fix existing "orphaned" agents is outlined here.
API
Adding check for inactive agents to the agent policy "delete" endpoint - It will now fail if the policy has either active or inactive agents:
UI
Warning added to the "delete" action in the UI when trying to delete a policy that has active or inactive agents.
Testing
Checklist