-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Ingest Manager] Fix package upgrade breaking after first rollover before new data has arrived #79887
[Ingest Manager] Fix package upgrade breaking after first rollover before new data has arrived #79887
Conversation
Pinging @elastic/ingest-management (Team:Ingest Management) |
Is there also an option for us to ensure the values are always there / already set? |
throw new Error(`data_stream values are missing from the index template ${indexName}`); | ||
const dataStreamName = `${dataStream.type.value}-${dataStream.dataset.value}-${dataStream.namespace.value}`; | ||
|
||
const [, dsType, dsTemplateName, dsNamespace] = indexName.split('-'); |
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.
If I understand correctly indexName
is a only a string
vs some other type. Can we at least add some assertions to guard against undefined
values or anything to give us more confidence it's what we expect?
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.
Yeah, it's probably worth checking. If the backing index prefix changes to something like .ds_logs-...
we'd also have an invalid type. Maybe we should check that the type
is either logs
or metrics
? I'm not sure if it's valid for it to be anything else. Or maybe we can use the enums that we use to create the kibana index patterns and make sure it at least is one of those that way we'd only have to change a single place to add new valid types.
@ruflin do you mean avoid performing an upgrade until those values are present aka data has come in to populate those fields? For indices that don't receive data very often ( |
A bit more complicated but we should be able update the component template |
Oh interesting. What about the scenario where the ILM did the rollover so the empty backing index already exists and then we try to do an upgrade? |
Good point. Could always fetch the first backing index or perform a query on it:
or use a wildcard if we don't want to assume the name |
Yeah I think you can just search the data stream name: |
Yes, you're right. |
8773a00
to
edb3cc3
Compare
x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts
Show resolved
Hide resolved
namespace: string; | ||
type: DataType; | ||
} = searchDataStreamFieldsResponse.hits.hits[0]._source.data_stream; | ||
const dataStreamName = `${type}-${dataset}-${namespace}`; |
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.
nit: do we want to check that type
is a valid DataType
? I suppose if they ingested data initially with an invalid data type then we should just continue doing that 🤷
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.
Yea, i'm not sure this is the place to be validating that and whether we'd have to throw an error and stop the upgrade because of that.
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.
Can we add any tests?
These existing tests would cover that it was rolled over with the expected name https://github.com/elastic/kibana/blob/master/x-pack/test/ingest_manager_api_integration/apis/epm/data_stream.ts |
But didn't our existing tests not identify the original issue? Can we add a test which prevents a regression? |
It's true our existing test did not identify the condition that caused this bug, but the condition no longer exists where the data_stream constants would not exist in a particular index because we are no longer getting it from the current index, but checking any index in the data stream. The data stream would not exist if at least one document didn't exist and every document sends the value. So the current integration tests cover the case because it could not have rolled over if i didn't have the constants. Testing for the previous scenario would not cover the case, currently. I'd have to perform a 2nd rollover to see if it has the constants in the current write index but we no longer depend on subsequent rollovers to carry constants over. |
It'd probably still be worth creating a test that does:
|
x-pack/test/ingest_manager_api_integration/apis/epm/data_stream.ts
Outdated
Show resolved
Hide resolved
💚 Build SucceededMetrics [docs]page load bundle size
History
To update your PR or re-run it, just comment with: |
…fore new data has arrived (elastic#79887) * build datastream name from index name * query for data_stream constants to create data stream name * simply datastream tests and add a test to upgrade after a datastream rolls over * improve query * remove dup
…fore new data has arrived (elastic#79887) * build datastream name from index name * query for data_stream constants to create data stream name * simply datastream tests and add a test to upgrade after a datastream rolls over * improve query * remove dup
…a-tier-migration * 'master' of github.com:elastic/kibana: (34 commits) Line Visualization improper scaling can result in gaps elastic#79663 (elastic#80135) [Security Solution][Timeline] Fix SelectableTimeline search (elastic#80128) move field_mapping util to saved_objects plugin (elastic#79918) [ML] Datagrid: Ensure column content with 'boolean' schema is not capitalized (elastic#80041) [CI] Correctly resolve repository root for JUnit reports (elastic#80226) [Ingest Manager] Fix package upgrade breaking after first rollover before new data has arrived (elastic#79887) [Security Solution] Fix positioning of Kibana banners list inside Sec… (elastic#80124) add missing await to fix test (elastic#80202) Revert test data changed in previous commit. (elastic#79479) [Security Solution] [Sourcerer] Jest beef up (elastic#79907) Re-enable transaction duration alert story (elastic#80187) [npm] remove canvas dep (elastic#80185) [DOCS] Redirects ILM docs to Elasticsearch reference (elastic#79798) [APM] Catch health status error from ML (elastic#80131) Fix layout and remove title for add alert popover. (elastic#77633) [Discover] Loading spinner cleanup (elastic#79819) [Security Solution] [Resolver] Remove related events api (elastic#79036) [Ingest Manager] Remove fields from index pattern during package uninstall (elastic#80082) do not refetch license if signature header absents from a response (elastic#79645) Only send agent data for non-opentelemetry agents (elastic#79587) ... # Conflicts: # x-pack/plugins/index_lifecycle_management/server/routes/api/nodes/register_list_route.ts
* upstream/master: (34 commits) Improve vis editor typings (elastic#80004) Line Visualization improper scaling can result in gaps elastic#79663 (elastic#80135) [Security Solution][Timeline] Fix SelectableTimeline search (elastic#80128) move field_mapping util to saved_objects plugin (elastic#79918) [ML] Datagrid: Ensure column content with 'boolean' schema is not capitalized (elastic#80041) [CI] Correctly resolve repository root for JUnit reports (elastic#80226) [Ingest Manager] Fix package upgrade breaking after first rollover before new data has arrived (elastic#79887) [Security Solution] Fix positioning of Kibana banners list inside Sec… (elastic#80124) add missing await to fix test (elastic#80202) Revert test data changed in previous commit. (elastic#79479) [Security Solution] [Sourcerer] Jest beef up (elastic#79907) Re-enable transaction duration alert story (elastic#80187) [npm] remove canvas dep (elastic#80185) [DOCS] Redirects ILM docs to Elasticsearch reference (elastic#79798) [APM] Catch health status error from ML (elastic#80131) Fix layout and remove title for add alert popover. (elastic#77633) [Discover] Loading spinner cleanup (elastic#79819) [Security Solution] [Resolver] Remove related events api (elastic#79036) [Ingest Manager] Remove fields from index pattern during package uninstall (elastic#80082) do not refetch license if signature header absents from a response (elastic#79645) ...
Summary
Resolves #79370
If the user has rolled over a datastream in the past and tries to upgrade a package before any new data has arrived in the current write index, a failure will occur because the
data_stream
constant field mappings do not yet have values which are relied on to create the data stream name.Change
Instead of relying on constant values of the datastream mappings in the current write index to compose the name of the datastream, query for the data_stream constant values amongst all indices