-
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
[Fleet] fix for upgrade package with tsds removed #157395
Conversation
Pinging @elastic/fleet (Team:Fleet) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
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.
LGTM - I think gating this logic to only index templates that define index_mode: time_series
is the safest option.
Would it be possible to add a test case for this to install.test.ts
?
@@ -219,6 +219,17 @@ export async function installComponentAndIndexTemplateForDataStream({ | |||
componentTemplates: TemplateMap; | |||
indexTemplate: IndexTemplateEntry; | |||
}) { | |||
// update index template first in case TSDS was removed, so that it does not become invalid | |||
const existingIndexTemplate = await esClient.indices.getIndexTemplate({ |
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.
Does this API throw an error if the template doesnt exist?
Installing the index template first isn't great but I do think it is pretty safe in the update scenario. Obviously in the install scenario we couldn't fo it in this order as the index template references the component templates which wouldn't exist.
This does mean in the future if the component templates ever changed on upgrade e.g a new one was added on package upgrade then this wouldn't work, but that is completely hypothetical so I think this is fine.
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.
Does this API throw an error if the template doesnt exist?
I want to test that scenario, might have to catch a 404 error.
This does mean in the future if the component templates ever changed on upgrade e.g a new one was added on package upgrade then this wouldn't work, but that is completely hypothetical so I think this is fine.
Good point, I think it is best to catch any errors for the first index template creation, as the codes does it again after component template update.
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.
Updated the code with error handling, and added integration test.
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.
+1 to adding an integration test for this scenario as this is something that someone could unknowingly break in a refactor.
We could even use the nginx package zips we already have for ease so you dont have to create a seperate test package
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.
+1 to adding an integration test for this scenario as this is something that someone could unknowingly break in a refactor.
We could even use the nginx package zips we already have for ease so you dont have to create a seperate test package
💚 Build Succeeded
Metrics [docs]Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
## Summary Fixes elastic#157345 To test: Install `nginx-1.12.0-beta` which has `index.mode:time_series`. ``` POST http://elastic:changeme@localhost:5601/api/fleet/epm/packages/nginx-1.12.0-beta kbn-xsrf: kibana { "force": true } ``` Upgrade to `nginx-1.12.1-beta` which has `index.mode:time_series` removed. Upload this package built manually: [nginx-1.12.1-beta.zip](https://github.com/elastic/kibana/files/11452945/nginx-1.12.1-beta.zip) ``` curl -XPOST -H 'content-type: application/zip' -H 'kbn-xsrf: true' http://localhost:5601/api/fleet/epm/packages -u elastic:changeme --data-binary @nginx-1.12.1-beta.zip ``` The package should install successfully and time_series should be removed from the index template `metrics-nginx.stubstatus` WIP: update tests ### Checklist - [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
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
## Summary Fixes elastic#157345 To test: Install `nginx-1.12.0-beta` which has `index.mode:time_series`. ``` POST http://elastic:changeme@localhost:5601/api/fleet/epm/packages/nginx-1.12.0-beta kbn-xsrf: kibana { "force": true } ``` Upgrade to `nginx-1.12.1-beta` which has `index.mode:time_series` removed. Upload this package built manually: [nginx-1.12.1-beta.zip](https://github.com/elastic/kibana/files/11452945/nginx-1.12.1-beta.zip) ``` curl -XPOST -H 'content-type: application/zip' -H 'kbn-xsrf: true' http://localhost:5601/api/fleet/epm/packages -u elastic:changeme --data-binary @nginx-1.12.1-beta.zip ``` The package should install successfully and time_series should be removed from the index template `metrics-nginx.stubstatus` WIP: update tests ### Checklist - [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 (cherry picked from commit a0ee7b6)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
Backport to 8.8 merged in #157415 |
Summary
Fixes #157345
To test:
Install
nginx-1.12.0-beta
which hasindex.mode:time_series
.Upgrade to
nginx-1.12.1-beta
which hasindex.mode:time_series
removed.Upload this package built manually:
nginx-1.12.1-beta.zip
The package should install successfully and time_series should be removed from the index template
metrics-nginx.stubstatus
WIP: update tests
Checklist