🌊 Streams: Handle stale classic streams #208221
Open
+147
−41
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.
An invariant we have to handle somehow is if a user made additions to an unwired data stream via the streams interface, then the underlying data stream gets deleted.
This is "allowed", since the data stream is not managed by streams.
Currently, the UI breaks if this happens and shows error toasts when trying to load the doc count or when trying to change processing.
This PR makes this a regular case the API can handle:
GET /api/streams/<id>
endpoint does not throw, but still returns the existing definition. A new keydata_stream_exists
indicates whether we are in this situationTrying to update ingest via the API will still result in an error.
Another weird behavior related to that was that if a dashboard is linked to a stale classic stream, no definition is ever saved and the stream disappears from the list when deleted, making the dashboard link inaccessible. This PR introduces
ensureStream
which is called by the dashboard APIs and makes sure the definition is there if dashboard links exist. As a side effect, this makes sure that a user can't add dashboard links to a stream they don't have access to - IMHO we should have done that from the start.This does not touch wired streams - for those, the data stream getting deleted is a breach of contract. We should still handle it gracefully, but in this case I think we should go another route and offer a button in the UI to use the "resync" API to reconcile the state of the streams layer and Elasticsearch. I will look into this on a separate PR.