Repository navigation
[Fleet] Prevent deletion of agent policies with inactive agents from UI - #175815
Merged
Merged
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
Member
Author
|
/ci |
criamico
force-pushed
the
155925_prevent_deletion_policies
branch
from
January 31, 2024 10:37
ec5b043 to
06e2015
Compare
Member
Author
|
@elasticmachine merge upstream |
Member
Author
|
/ci |
Contributor
|
Pinging @elastic/fleet (Team:Fleet) |
nchaulet
self-requested a review
January 31, 2024 17:08
nchaulet
reviewed
Jan 31, 2024
| showInactive: true, | ||
| perPage: 0, | ||
| page: 1, | ||
| kuery: `${AGENTS_PREFIX}.policy_id:${id}`, |
Member
There was a problem hiding this comment.
Should we add the unenrolled condition here too and not status: unenrolled?
Member
Author
|
@elasticmachine merge upstream |
Member
Author
|
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @criamico |
Contributor
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
Member
Author
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
criamico
added a commit
to criamico/kibana
that referenced
this pull request
Feb 2, 2024
…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:  ### 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 <42973632+kibanamachine@users.noreply.github.com> (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
criamico
added a commit
that referenced
this pull request
Feb 2, 2024
…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":"criamico@users.noreply.github.com"},"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\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 <42973632+kibanamachine@users.noreply.github.com>","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\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 <42973632+kibanamachine@users.noreply.github.com>","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\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 <42973632+kibanamachine@users.noreply.github.com>","sha":"222e894b8a483cd4a22c81dfcd2bec633a45e421"}}]}] BACKPORT--> --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Contributor
|
This PR didn't make it on time to the latest build candidate of v8.12.1. Updating the labels. |
fkanout
pushed a commit
to fkanout/kibana
that referenced
this pull request
Feb 7, 2024
…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:  ### 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 <42973632+kibanamachine@users.noreply.github.com>
CoenWarmer
pushed a commit
to CoenWarmer/kibana
that referenced
this pull request
Feb 15, 2024
…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:  ### 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 <42973632+kibanamachine@users.noreply.github.com>
fkanout
pushed a commit
to fkanout/kibana
that referenced
this pull request
Mar 4, 2024
…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:  ### 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 <42973632+kibanamachine@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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