Skip to content
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

Merged
merged 4 commits into from
May 11, 2023

Conversation

juliaElastic
Copy link
Contributor

@juliaElastic juliaElastic commented May 11, 2023

Summary

Fixes #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

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

@juliaElastic juliaElastic requested a review from a team as a code owner May 11, 2023 14:13
@juliaElastic juliaElastic self-assigned this May 11, 2023
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label May 11, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@juliaElastic juliaElastic changed the title fix for upgrade package with tsds removed [Fleet] fix for upgrade package with tsds removed May 11, 2023
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@juliaElastic juliaElastic added release_note:skip Skip the PR/issue when compiling release notes v8.8.0 v8.9.0 labels May 11, 2023
@juliaElastic juliaElastic requested a review from hop-dev May 11, 2023 14:14
Copy link
Member

@kpollich kpollich left a 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({
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@hop-dev hop-dev left a 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

Copy link
Contributor

@hop-dev hop-dev left a 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

@juliaElastic juliaElastic enabled auto-merge (squash) May 11, 2023 15:49
@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 400 404 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 480 484 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @juliaElastic

@juliaElastic juliaElastic merged commit a0ee7b6 into elastic:main May 11, 2023
@juliaElastic juliaElastic added the backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) label May 11, 2023
juliaElastic added a commit to juliaElastic/kibana that referenced this pull request May 11, 2023
## 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
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.8

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request May 11, 2023
## 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)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.8

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

@juliaElastic
Copy link
Contributor Author

Backport to 8.8 merged in #157415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v8.8.0 v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Fleet]: Does not allow package upgrade to disable TSDB
7 participants