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

[EPM] /packages/{package} endpoint to support upgrades #63629

Merged

Conversation

neptunian
Copy link
Contributor

@neptunian neptunian commented Apr 15, 2020

Implements updating to a compatible package working by changing the order in which items are installed and now, updated. this can be found here #59910

  • installs/updates the index templates after pipeline creation
  • differentiates between install and reinstall to avoid deleting the pipelines which need to be deleted after successful updating of index templates and current write indices. since the version is the same if its a "reinstall", don't delete the pipeline (it's already been overwritten during creation time).
  • checks if the package is already installed (an update) and deletes all kibana assets before installing again. this in case the new package has deleted some assets so overwriting existing ones is not sufficient
  • removes functionality that merges the current saved objects "installed" fields on each epm package with the new installation and now totally overwrites the installed attribute (some assets may not exist anymore so it needs to get wiped out)
  • adds functionality to update the current write indices. query for every index associated with this package
  • will "reinstall" or install the same version of a package if it matches the already installed one

What this PR does not do

  • if a package fails to install for whatever reason, there needs to be a "rollback" as the install will be partial and they could be in a state where they have different assets of both versions. @ruflin said that for now, in a blog post, they’ll have to uninstall the old package and then try to install again (the new version doesn't get written to the saved object unless it was successful)
  • logging of errors so we can see what went wrong as compatible packages should be able to update
  • block API from attempting to upgrade or downgrade major versions (not allowed right now)
  • handle failure of mappings update on the current write index. if the mapping fails for the current write index that will most likely be because they are incompatible, such as trying to change a data type on an existing field (not allowed). typically, this is the point where we'd trigger a rollover to a new index which could inherit the new mapping types from the already created index template. since we can't do that right now (waiting for datastreams), they cannot update, and this will cause an error in the update process.

Test
I think we need a test package to test more uses cases and know what to look for, but system can be used at the moment.

  1. POST http://localhost:5603/ssg/api/ingest_manager/epm/packages/system-0.0.1
  2. POST http://localhost:5603/ssg/api/ingest_manager/epm/packages/system-0.9.0
  3. saved objects package version is now at 0.9.0
    http://localhost:5601/ssg/api/saved_objects/_find?fields=title&fields=type&fields=version&per_page=10000&type=epm-package
  4. Pipelines are built and referenced in the index template in 0.0.1 and deleted in 0.9.0
    Before updating
    GET _template/logs-system.auth

Screen Shot 2020-04-20 at 5 14 47 PM

After Updating (because pipeline does not exist in 0.9.0)
GET _template/logs-system.auth
Screen Shot 2020-04-20 at 5 16 17 PM
This is also reflected in the saved objects for epm package where the ingest pipelines are no longer part of the installed assets

@neptunian neptunian added 1sp Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project and removed 1sp labels Apr 15, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/ingest-management (Feature:EPM)

@neptunian neptunian added the Team:Fleet Team label for Observability Data Collection Fleet team label Apr 15, 2020
@neptunian neptunian force-pushed the 59910-upgrade-packages-install-endpoint branch from 33d457d to fc41fa7 Compare April 20, 2020 13:14
@neptunian neptunian requested a review from ruflin April 20, 2020 14:38
@neptunian neptunian marked this pull request as ready for review April 20, 2020 15:42
@neptunian neptunian requested a review from a team April 20, 2020 15:42
@neptunian neptunian added v8.0.0 v7.8.0 release_note:skip Skip the PR/issue when compiling release notes labels Apr 20, 2020
Copy link
Contributor

@jfsiii jfsiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some comments on names and exported types that I'd like to see , but good to ship as-is from me.

@@ -256,10 +256,32 @@ export enum DefaultPackages {
endpoint = 'endpoint',
}

export interface Mappings {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make these more specific? IndexTemplateMapping(s), perhaps?

indexTemplate: IndexTemplate;
}

export interface CurrentIndex {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to x-pack/plugins/ingest_manager/server/services/epm/elasticsearch/template/template.ts? I think that's the only place it's used and I don't initially see how CurrentIndex is a top-level concept in EPM.

@@ -235,9 +241,10 @@ function getBaseTemplate(type: string, templateName: string, mappings: Mappings)
},
mappings: {
// To be filled with interesting information about this specific index
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intentional? If so, can we delete this and the comment above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on removing this for now. We can add meta data again if we need it later.

Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not check the code in detail but I'm good with getting this in based on your description.

I'm thinking it will simplify things if in the future we can

  • Install all new assets
  • Remove old assets which are not needed anymore

I would hope this also helps failure recovery but will require us to keep old and new state. Lets iterate on it.

@neptunian I think we should also have some docs on the exact behaviour on what happens on upgrade.

@@ -235,9 +241,10 @@ function getBaseTemplate(type: string, templateName: string, mappings: Mappings)
},
mappings: {
// To be filled with interesting information about this specific index
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 on removing this for now. We can add meta data again if we need it later.

@neptunian
Copy link
Contributor Author

@elasticmachine merge upstream

type: string;
properties?: Record<string, Mapping>;
export interface IndexTemplateMappings {
properties: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really any? e.g. number, string, etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually just renamed Mappings to IndexTemplateMappings that @skh created. Trying to type all the mappings and settings is going to be pretty time consuming.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

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

@neptunian neptunian merged commit adc9b0d into elastic:master Apr 21, 2020
neptunian added a commit to neptunian/kibana that referenced this pull request Apr 21, 2020
* install template after pipeline creation

* return installed pkg if this pkg version is already installed

* remove pipelines after templates are updated

* remove kibana saved objects assets before installing

* update current write indices

* add back removal of merging previous references lost in rebase

* improve some typing names, consolidate, fix bad merges

* update query to use aggregate on _index

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
@ruflin
Copy link
Member

ruflin commented Apr 22, 2020

@neptunian Could you make sure we have a follow up issue where we can track the open issues around upgrade?

gmmorris added a commit to gmmorris/kibana that referenced this pull request Apr 22, 2020
* master: (29 commits)
  [Dashboard] Deangularize navbar, attempt nr. 2 (elastic#61611)
  refactor action filter creation utils (elastic#62969)
  Refresh index pattern list before redirecting (elastic#63329)
  [APM]fixing custom link unit tests (elastic#64045)
  [Ingest] EPM & Fleet are enabled when Ingest is enabled (elastic#64103)
  [Alerting] Fixed bug with no possibility to edit the index name after adding (elastic#64033)
  [Maps] Map settings: min and max zoom (elastic#63714)
  [kbn-storybook] Use raw loader for text files (elastic#64108)
  [EPM] /packages/{package} endpoint to support upgrades (elastic#63629)
  [SIEM] New Platform Saved Objects Registration (elastic#64029)
  [Endpoint] Hook to handle events needing navigation via Router (elastic#63863)
  Fixed small issue in clone functionality (elastic#64085)
  [Endpoint]EMT-146: use ingest agent for status info (elastic#63921)
  [SIEM] Server NP Followup (elastic#64010)
  Register uiSettings on New Platform (elastic#64015)
  [Reporting] Integration polling config with client code (elastic#63754)
  [Docs]7.7 SIEM doc updates (elastic#63951)
  [SIEM] [Cases] Tags suggestions (elastic#63878)
  Include datasource UUID in agent config yaml, adjust overflow height of yaml view (elastic#64027)
  [DOCS] Add file size setting for Data Visualizer (elastic#64006)
  ...
neptunian added a commit that referenced this pull request Apr 22, 2020
* install template after pipeline creation

* return installed pkg if this pkg version is already installed

* remove pipelines after templates are updated

* remove kibana saved objects assets before installing

* update current write indices

* add back removal of merging previous references lost in rebase

* improve some typing names, consolidate, fix bad merges

* update query to use aggregate on _index

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
gmmorris added a commit to gmmorris/kibana that referenced this pull request Apr 22, 2020
…ana into task-manager/cancel-logging

* 'task-manager/cancel-logging' of github.com:gmmorris/kibana: (28 commits)
  [Dashboard] Deangularize navbar, attempt nr. 2 (elastic#61611)
  refactor action filter creation utils (elastic#62969)
  Refresh index pattern list before redirecting (elastic#63329)
  [APM]fixing custom link unit tests (elastic#64045)
  [Ingest] EPM & Fleet are enabled when Ingest is enabled (elastic#64103)
  [Alerting] Fixed bug with no possibility to edit the index name after adding (elastic#64033)
  [Maps] Map settings: min and max zoom (elastic#63714)
  [kbn-storybook] Use raw loader for text files (elastic#64108)
  [EPM] /packages/{package} endpoint to support upgrades (elastic#63629)
  [SIEM] New Platform Saved Objects Registration (elastic#64029)
  [Endpoint] Hook to handle events needing navigation via Router (elastic#63863)
  Fixed small issue in clone functionality (elastic#64085)
  [Endpoint]EMT-146: use ingest agent for status info (elastic#63921)
  [SIEM] Server NP Followup (elastic#64010)
  Register uiSettings on New Platform (elastic#64015)
  [Reporting] Integration polling config with client code (elastic#63754)
  [Docs]7.7 SIEM doc updates (elastic#63951)
  [SIEM] [Cases] Tags suggestions (elastic#63878)
  Include datasource UUID in agent config yaml, adjust overflow height of yaml view (elastic#64027)
  [DOCS] Add file size setting for Data Visualizer (elastic#64006)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:EPM Fleet team's Elastic Package Manager (aka Integrations) project release_note:skip Skip the PR/issue when compiling release notes Team:Fleet Team label for Observability Data Collection Fleet team v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants