-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] Update data streams mappings directly instead of against backing indices #89660
Conversation
… indices, update integration tests to test with multiple namespaces
Pinging @elastic/fleet (Feature:EPM) |
Pinging @elastic/ingest-management (Team:Ingest Management) |
Looks great! This really simplifies things. Though I'd like to make sure, is there any concern about updating all the backing indices of the datastream? The docs say "Changing the mapping of an existing field could invalidate any data that’s already indexed". Is that expected? There is a |
@neptunian Thanks for pointing that out! I'm not sure about what the consequences of updating all backing indices mappings are, but it sounds like setting |
return updateExistingIndex({ indexName, callCluster, indexTemplate }); | ||
}); | ||
await Promise.all(updateIndexPromises); | ||
const updatedataStreamPromises = indexNameWithTemplates.map( |
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.
This should be moved inside the Promise.all
. If updateExistingDataStream
throws/rejects before the await Promise.all
line we'll crash due to UnhandledPromiseRejection
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.
@jfsiii Can you elaborate or provide revised code? updatedataStreamPromises
is passed to the Promise.all
and updateExistingDataStream
is async?
Also, I didn't change the logic here, just renaming. Due to being this a priority fix, I might merge this and follow up on code improvements based on your feedback afterwards.
We should not try to update all backing indices but only the one we currently write to. Otherwise it would update many indices where the new mapping does not matter and in addition it would slow down. Also it would probably trigger a rollover if just a single old index does not match the mapping, so rollover from there forward would always happen. |
@EricDavisX It would be great if we could add a test case to our e2e using multiple namespaces to uncover this issue here. |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
…ing indices (elastic#89660) * Update data streams mappings directly instead of querying for backing indices, update integration tests to test with multiple namespaces * Add flag to only update mappings of the current write index Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…ing indices (elastic#89660) * Update data streams mappings directly instead of querying for backing indices, update integration tests to test with multiple namespaces * Add flag to only update mappings of the current write index Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts # x-pack/test/fleet_api_integration/apis/epm/data_stream.ts
…ing indices (#89660) (#89892) * Update data streams mappings directly instead of querying for backing indices, update integration tests to test with multiple namespaces * Add flag to only update mappings of the current write index Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…ing indices (#89660) (#89891) * Update data streams mappings directly instead of querying for backing indices, update integration tests to test with multiple namespaces * Add flag to only update mappings of the current write index Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
…ing indices (#89660) (#89896) * Update data streams mappings directly instead of querying for backing indices, update integration tests to test with multiple namespaces * Add flag to only update mappings of the current write index Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # x-pack/plugins/fleet/server/services/epm/elasticsearch/template/template.ts # x-pack/test/fleet_api_integration/apis/epm/data_stream.ts
Summary
Resolves #89436. This fixes the concurrent rollover errors when upgrading a package that 1) has incompatible mappings and 2) already has data streams created with different namespaces.
In the case when we detect incompatible mappings, we trigger a rollover on the data stream instead. When this code was written originally in #69180, Elasticsearch did not support updating mappings on the data stream directly, so we had to workaround it by querying for the backing indices. This caused problems when there are multiple namespaces.
ES added support for updating data stream mappings directly in elastic/elasticsearch#58231 (corresponding docs).
This PR:
write_index_only
parameter to protect data in backing indices: LOCThe corresponding API integration test suite was updated to perform against multiple data streams with multiple namespaces.