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

Remove dependency on doc versions #29906

Merged
merged 24 commits into from
Feb 5, 2019

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Feb 2, 2019

See elastic/elasticsearch#38254

Using the version parameter to implement optimistic concurrency is not going to be supported in 7.0, so we need to replace our usage of document version with the new _seq_no and _primary_term parameters. These fields are returned in the same way that _version was returned on all read/write requests except for search, where it needs to be requested by sending seq_no_primary_term: true in the body of the search request. These parameters are sent back to Elasticsearch on write requests with the if_seq_no and if_primary_term parameters, and are functionally equivalent to sending a version in a write request before elastic/elasticsearch#38254.

To make these updates I searched the code base for uses of a version and _version, then triaged each usage, so I'm fairly confident that I got everything but it's possible something slipped through the cracks, so if you know of any usage of the document version field please help me out by double checking that I converted it.

  • Saved Objects: @elastic/kibana-platform, @elastic/es-security - for BWC and ergonomics the version provided by the Saved Objects client/API was not removed, it was converted from a number to a string whose value is base64(json([_seq_no, _primary_term])). This allows the Saved Objects API and its consumers to remain mostly unmodified, as long as the underlying value in the version field is irrelevant. This was the case for all usages in Kibana, only thing that needed updating was tests and TS types.

  • Reporting/esqueue: @joelgriffith, @tsullivan - the version parameter was used here specifically for implementing optimistic concurrency, and since its usage was contained within the esqueue module I just updated it to use the new _seq_no and _primary_term fields.

  • Task Manager: @tsullivan @njd5475 - Like esqueue this module uses version for optimistic concurrency but the usage is contained with the module so I just updated it to use, store, and request the _seq_no and _primary_term fields.

  • ML: @elastic/ml-ui - Best I could tell the only "version" in the ML code refers to the stack version, 077245f

  • Beats CM: @elastic/beats - Looks like the references to _version in the code is only in the types but not in the code itself. I updated the types to use _seq_no and _primary_term, and their camelCase equivalents where appropriate. I did find a method that used one of the types referencing version but when investigating its usage it seemed the only consumer of that method was itself so i removed it. 52d890f

  • Spaces (tests): @elastic/kibana-security - The spaces test helpers use saved objects with versions in a number of places, so I updated them to use the new string versions where the version was predictable, and removed the assertion on version where it wasn't. We test the version in the saved objects code so this should be fine.

@spalger spalger added the WIP Work in progress label Feb 2, 2019
@spalger spalger requested review from a team as code owners February 2, 2019 12:18
@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@spalger spalger changed the title Remove dependency on ES version Remove dependency on doc versions Feb 3, 2019
@elasticmachine

This comment has been minimized.

@elasticmachine

This comment has been minimized.

@spalger spalger added the review label Feb 4, 2019
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@mikecote mikecote left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Contributor

@njd5475 njd5475 left a comment

Choose a reason for hiding this comment

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

LGTM

@elasticmachine

This comment has been minimized.

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@spalger spalger merged commit b4725b7 into elastic:master Feb 5, 2019
@spalger spalger removed the v6.7.0 label Feb 5, 2019
spalger pushed a commit to spalger/kibana that referenced this pull request Feb 5, 2019
See elastic/elasticsearch#38254

Using the `version` parameter to implement optimistic concurrency is not going to be supported in 7.0, so we need to replace our usage of document version with the new `_seq_no` and `_primary_term` parameters. These fields are returned in the same way that `_version` was returned on all read/write requests except for search, where it needs to be requested by sending `seq_no_primary_term: true` in the body of the search request. These parameters are sent back to Elasticsearch on write requests with the `if_seq_no` and `if_primary_term` parameters, and are functionally equivalent to sending a `version` in a write request before elastic/elasticsearch#38254.

To make these updates I searched the code base for uses of a `version` and `_version`, then triaged each usage, so I'm fairly confident that I got everything but it's possible something slipped through the cracks, so if you know of any usage of the document version field please help me out by double checking that I converted it.

- [x] **Saved Objects**:  @elastic/kibana-platform, @elastic/es-security - for BWC and ergonomics the `version` provided by the Saved Objects client/API was not removed, it was converted from a number to a string whose value is `base64(json([_seq_no, _primary_term]))`. This allows the Saved Objects API and its consumers to remain mostly unmodified, as long as the underlying value in the version field is irrelevant. This was the case for all usages in Kibana, only thing that needed updating was tests and TS types.

- [x] **Reporting/esqueue**: @joelgriffith, @tsullivan - the version parameter was used here specifically for implementing optimistic concurrency, and since its usage was contained within the esqueue module I just updated it to use the new `_seq_no` and `_primary_term` fields.

- [x] **Task Manager**: @tsullivan @njd5475 - Like esqueue this module uses version for optimistic concurrency but the usage is contained with the module so I just updated it to use, store, and request the `_seq_no` and `_primary_term` fields.

- [ ] **ML**: @elastic/ml-ui - Best I could tell the only "version" in the ML code refers to the stack version, elastic@077245f

- [ ] **Beats CM**: @elastic/beats - Looks like the references to `_version` in the code is only in the types but not in the code itself. I updated the types to use `_seq_no` and `_primary_term`, and their camelCase equivalents where appropriate. I did find a method that used one of the types referencing version but when investigating its usage it seemed the only consumer of that method was itself so i removed it. elastic@52d890f

- [x] **Spaces (tests)**: @elastic/kibana-security - The spaces test helpers use saved objects with versions in a number of places, so I updated them to use the new string versions where the version was predictable, and removed the assertion on version where it wasn't. We test the version in the saved objects code so this should be fine.
@walterra
Copy link
Contributor

walterra commented Feb 5, 2019

You're right we haven't been using version in ML in that context, LGTM!

@sorenlouv
Copy link
Member

sorenlouv commented Feb 12, 2019

@spalger This change caused some things to go awry with APM Getting Started flow (#30651). But not to worry! :) We have a PR ready with a fix #30796. Can you verify it is the correct approach?

Btw. Is there something we could have done to avoid this? Eg. add a test or somehow made it clear we depend on the saved objects API?

@spalger
Copy link
Contributor Author

spalger commented Feb 13, 2019

@sqren best option would be to have it covered by a functional test, I'm kind of surprised that I missed that.

spalger pushed a commit that referenced this pull request Feb 14, 2019
Backports the following commits to 6.x:
 - Remove dependency on doc versions  (#29906)
weltenwort added a commit that referenced this pull request Mar 11, 2019
) (#32938)

Backports the following commits to 6.7:
 - [Infra UI] Adapt settings ui to saved object version type change (#30082) (#29622)

Caused by backport of #29906 to `6.x`.
@spalger spalger added the non-issue Indicates to automation that a pull request should not appear in the release notes label Mar 22, 2019
@spalger spalger deleted the fix/remove-dependency-on-es-version branch August 18, 2020 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
(Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead Feature:Metrics UI Metrics UI feature Feature:Security/Spaces Platform Security - Spaces feature non-issue Indicates to automation that a pull request should not appear in the release notes review Team:Beats Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.