fix(streams): Delete stream's queries and children's queries upon stream deletion#230126
Conversation
|
/ci |
|
/ci |
|
/ci |
|
Pinging @elastic/obs-ux-management-team (Team:obs-ux-management) |
flash1293
left a comment
There was a problem hiding this comment.
Good start moving query handling into the execution plan! Left some comments
| ...delete_dot_streams_document, | ||
| ]); | ||
|
|
||
| await this.deleteQueries(delete_queries); |
There was a problem hiding this comment.
can we add this to an existing parallel batch?
There was a problem hiding this comment.
yes sure, just don't want to do it too early in case another step fails, might do it with the previous call.
There was a problem hiding this comment.
Since this won't be super cheap (requires at least one request to Elasticsearch to check whether queries exist), we shouldn't make it its own step if we don't have to.
There was a problem hiding this comment.
sounds good, I'll move it above
...ns/shared/streams/server/lib/streams/state_management/execution_plan/required_permissions.ts
Show resolved
Hide resolved
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
cc @kdelemme |
flash1293
left a comment
There was a problem hiding this comment.
LGTM, works as expected
…eam deletion (elastic#230126) ## Summary Resolves elastic#229715 When deleting a stream we used to delete the queries attached to it but did not delete the children's stream queries. This PR handles the deletion of the queries when deleting a stream directly from the state management service for both classic and wired streams, thus deleting all children's stream queries. I'm not changing how we manage queries in this PR to keep the surface area small. ### Manual tests ``` PUT kbn:/api/streams/logs.child { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [ { "destination": "logs.child.child", "if": { "field": "foo", "operator": "eq", "value": "bar" } }, { "destination": "logs.child.child2", "if": { "always": {} } } ] } } }, "dashboards": [], "queries": [ { "id": "f744f2d0-0b17-477e-b80a-c11b98ddfc2d", "title": "logs.child.first", "kql": { "query": "message:\"test\"" } }, { "id": "2ce604e7-4156-44eb-bf3f-97ef2b333818", "title": "logs.child.second", "kql": { "query": "" } } ] } PUT kbn:/api/streams/logs.child.child { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [] } } }, "dashboards": [], "queries": [ { "id": "009a886b-9abe-4c1c-91e3-34f17691418e", "title": "logs.child.child", "kql": { "query": "" } } ] } PUT kbn:/api/streams/logs.child.child2 { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [] } } }, "dashboards": [], "queries": [ { "id": "a966e062-303d-42f5-84b0-017414ab7ef1", "title": "logs.child.child2.first", "kql": { "query": "" } }, { "id": "3a8538c0-06eb-45ec-8ee3-3b4b5363dd17", "title": "logs.child.child2.second", "kql": { "query": "" } } ] } DELETE kbn:/api/streams/logs.child ``` Assert all rules in the stack management are gone.
…eam deletion (elastic#230126) ## Summary Resolves elastic#229715 When deleting a stream we used to delete the queries attached to it but did not delete the children's stream queries. This PR handles the deletion of the queries when deleting a stream directly from the state management service for both classic and wired streams, thus deleting all children's stream queries. I'm not changing how we manage queries in this PR to keep the surface area small. ### Manual tests ``` PUT kbn:/api/streams/logs.child { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [ { "destination": "logs.child.child", "if": { "field": "foo", "operator": "eq", "value": "bar" } }, { "destination": "logs.child.child2", "if": { "always": {} } } ] } } }, "dashboards": [], "queries": [ { "id": "f744f2d0-0b17-477e-b80a-c11b98ddfc2d", "title": "logs.child.first", "kql": { "query": "message:\"test\"" } }, { "id": "2ce604e7-4156-44eb-bf3f-97ef2b333818", "title": "logs.child.second", "kql": { "query": "" } } ] } PUT kbn:/api/streams/logs.child.child { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [] } } }, "dashboards": [], "queries": [ { "id": "009a886b-9abe-4c1c-91e3-34f17691418e", "title": "logs.child.child", "kql": { "query": "" } } ] } PUT kbn:/api/streams/logs.child.child2 { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [] } } }, "dashboards": [], "queries": [ { "id": "a966e062-303d-42f5-84b0-017414ab7ef1", "title": "logs.child.child2.first", "kql": { "query": "" } }, { "id": "3a8538c0-06eb-45ec-8ee3-3b4b5363dd17", "title": "logs.child.child2.second", "kql": { "query": "" } } ] } DELETE kbn:/api/streams/logs.child ``` Assert all rules in the stack management are gone.
…eam deletion (elastic#230126) ## Summary Resolves elastic#229715 When deleting a stream we used to delete the queries attached to it but did not delete the children's stream queries. This PR handles the deletion of the queries when deleting a stream directly from the state management service for both classic and wired streams, thus deleting all children's stream queries. I'm not changing how we manage queries in this PR to keep the surface area small. ### Manual tests ``` PUT kbn:/api/streams/logs.child { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [ { "destination": "logs.child.child", "if": { "field": "foo", "operator": "eq", "value": "bar" } }, { "destination": "logs.child.child2", "if": { "always": {} } } ] } } }, "dashboards": [], "queries": [ { "id": "f744f2d0-0b17-477e-b80a-c11b98ddfc2d", "title": "logs.child.first", "kql": { "query": "message:\"test\"" } }, { "id": "2ce604e7-4156-44eb-bf3f-97ef2b333818", "title": "logs.child.second", "kql": { "query": "" } } ] } PUT kbn:/api/streams/logs.child.child { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [] } } }, "dashboards": [], "queries": [ { "id": "009a886b-9abe-4c1c-91e3-34f17691418e", "title": "logs.child.child", "kql": { "query": "" } } ] } PUT kbn:/api/streams/logs.child.child2 { "stream": { "description": "", "ingest": { "processing": [], "lifecycle": { "inherit": {} }, "wired": { "fields": {}, "routing": [] } } }, "dashboards": [], "queries": [ { "id": "a966e062-303d-42f5-84b0-017414ab7ef1", "title": "logs.child.child2.first", "kql": { "query": "" } }, { "id": "3a8538c0-06eb-45ec-8ee3-3b4b5363dd17", "title": "logs.child.child2.second", "kql": { "query": "" } } ] } DELETE kbn:/api/streams/logs.child ``` Assert all rules in the stack management are gone.
Summary
Resolves #229715
When deleting a stream we used to delete the queries attached to it but did not delete the children's stream queries.
This PR handles the deletion of the queries when deleting a stream directly from the state management service for both classic and wired streams, thus deleting all children's stream queries.
I'm not changing how we manage queries in this PR to keep the surface area small.
Manual tests
Assert all rules in the stack management are gone.