[Fleet] Fix bulk actions incorrectly selecting agents with namespaces filter#224036
[Fleet] Fix bulk actions incorrectly selecting agents with namespaces filter#224036juliaElastic merged 5 commits intoelastic:mainfrom
Conversation
|
Pinging @elastic/fleet (Team:Fleet) |
| } | ||
| if (spaceId === DEFAULT_SPACE_ID) { | ||
| return [`namespaces:"${DEFAULT_SPACE_ID}" or not namespaces:*`]; | ||
| return [`(namespaces:"${DEFAULT_SPACE_ID}" or not namespaces:*)`]; |
There was a problem hiding this comment.
I'm wondering if it makes sense to extract these queries to a constant and put it in a common place
There was a problem hiding this comment.
good idea, done
| } | ||
| return namespace === DEFAULT_NAMESPACE_STRING | ||
| ? `namespaces:(${DEFAULT_NAMESPACE_STRING}) or not namespaces:*` | ||
| ? `(namespaces:(${DEFAULT_NAMESPACE_STRING}) or not namespaces:*)` |
There was a problem hiding this comment.
Just noticed that DEFAULT_NAMESPACE_STRING here and DEFAULT_SPACE_ID above are the same, what do you think of using only one of them?
criamico
left a comment
There was a problem hiding this comment.
Thanks for the changes! LGTM 🚀
⏳ Build in-progress, with failures
Failed CI StepsTest Failures
History
|
|
Starting backport for target branches: 9.0 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
… filter (elastic#224036) Fix bulk actions incorrectly selecting agents with namespaces filter. The namespaces filter `namespaces:(default) or not namespaces:*` was introduced with space awareness feature, it is incorrectly concatenated with other filters, ending up selecting all agents. To verify: - Enroll Fleet Server and 10 agents with horde - Search on horde agents by filtering on `eh*` - Select rows per page to be 5 - Select all agents on all pages (should be 10) - Click on bulk unenroll action - Verify that only the selected 10 agents are unenrolled - Previously with the bug, all agents were unenrolled, including Fleet Server Filters included in the search: `[ "(namespaces:(default) or not namespaces:*) AND (eh*) and (status:online or (status:error or status:degraded) or status:orphaned or (status:updating or status:unenrolling or status:enrolling) or status:offline)", "NOT status:unenrolled" ]` <img width="1412" alt="image" src="https://github.com/user-attachments/assets/4740f0c7-67ab-41c3-9dd4-0b122ed472aa" /> <img width="1278" alt="image" src="https://github.com/user-attachments/assets/b7944d43-c4a6-42ca-b1c8-c8be78fc40cf" /> - [x] [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
|
Looks like this PR has a backport PR but it still hasn't been merged. Please merge it ASAP to keep the branches relatively in sync. |
|
This PR didn't make it into the latest BC for v9.0.3. Updating the labels. |
Summary
Fix bulk actions incorrectly selecting agents with namespaces filter.
The namespaces filter
namespaces:(default) or not namespaces:*was introduced with space awareness feature, it is incorrectly concatenated with other filters, ending up selecting all agents.To verify:
eh*Filters included in the search:
[ "(namespaces:(default) or not namespaces:*) AND (eh*) and (status:online or (status:error or status:degraded) or status:orphaned or (status:updating or status:unenrolling or status:enrolling) or status:offline)", "NOT status:unenrolled" ]Checklist