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

[Management] Enable index pattern version conflicts #18937

Merged

Conversation

chrisronline
Copy link
Contributor

@chrisronline chrisronline commented May 8, 2018

Resolves #18584, #15738, #19037

Summary

This PR adds support for index patterns to leverage optimistic concurrency which is already supported through the saved objects api.

The basic flow is:

  1. We attempt to update the index pattern and provide the current version we know about
  2. ES will either accept it or reject it if the version is off
  3. We attempt to discover what changed from the most up to version and our local version and if the changes are not related to our current changes, we merged our local version with the up to date version and re-save.

Testing

There are three main test cases I've been using to test this:

Changing a field format

  1. Open two tabs, both open to editing the same field format (on the same field and same index pattern)
  2. Change the format in one tab, save and wait for the response from the server
  3. Change the format in the other tab to something different than the original and value you changed in the first tab. Then click save. You should see a toast error indicating you need to refresh the page to continue.

Not changing a field format in the second tab

  1. Open two tabs, both open to editing the same field format (on the same field and same index pattern)
  2. Change the format in one tab, save and wait for the response from the server
  3. Do not change anything in the other tab and click save. It should successfully save. Click edit again and you see the value you entered from the first tab.

Using discover

  1. Open a tab to edit a field format for an index pattern
  2. Open a second tab on Discover
  3. Change the field format in the first tab and save. Wait for the response.
  4. Go to discover and click Add or Remove on any of the fields on the left (ensure it's the same index pattern). It should successfully go through and the field formatting changes made in step 3 should be preserved (verify by refreshing the page on tab 1 and clicking edit again)

Questions/Areas of Note

The code around trying to resolve the conflicts manually feels a bit trappy but it felt like a good use case to support to avoid unnecessary page refreshes (honestly, maybe needing to refresh the page is up for debate too?). All reviewers: please spend extra time reviewing this. I added a unit test but would love some more validation here.

cc @tylersmalley

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

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

I can't get formatting to be cleared using two tabs like before, so that issue is taken care of! There are still two issues that I see:

Refresh requires two clicks

  1. Open two tabs to index pattern fields list.
  2. In tab 1, change a field's format to anything other than default, save.
  3. In tab 2, click refresh fields - list is not updated with new format. Click refresh again - list is updated.

Default format can be overridden with old version

  1. Open two tabs to index pattern fields list - with at least one field that has a format other than default (will use Number for example)
  2. In tab 1, change that field's Number format to default, save.
  3. In tab 2, click refresh fields.
  4. In tab 1, reload page - that field's format is back to Number.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@chrisronline
Copy link
Contributor Author

@jen-huang Great finds! After investigation, I opened #19037 to describe some of the issues I saw related to this. 94c71bb should address your issues as well as the earlier mentioned issue!

@elasticmachine
Copy link
Contributor

💔 Build Failed

@chrisronline
Copy link
Contributor Author

jenkins, test this

@elasticmachine
Copy link
Contributor

💔 Build Failed

@chrisronline
Copy link
Contributor Author

jenkins, test this

@elasticmachine
Copy link
Contributor

💔 Build Failed

@chrisronline
Copy link
Contributor Author

Tests pass locally. This is a bummer

jenkins, test this

@elasticmachine
Copy link
Contributor

💔 Build Failed

@chrisronline chrisronline force-pushed the index_pattern_version_conflicts branch from 94c71bb to af6fdda Compare May 15, 2018 17:08
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Copy link
Contributor

@jen-huang jen-huang left a comment

Choose a reason for hiding this comment

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

@chrisronline Those changes fixed the two issues I was seeing! And I'm not seeing the issues described in #19037. Resetting to default works fine for me.

However, I am seeing an issue where versioning isn't kicking in once a field has been changed. Steps:

  1. Open two tabs to the same index pattern
  2. In tab 1, click Edit on a string field, change its format to String and save
  3. In tab 2, click refresh fields (the new String format for the edited field shows correctly)
  4. Stay in tab 2, click Edit in the same updated field, change its format to Truncated String and save
  5. In tab 1, DO NOT REFRESH FIELDS, click edit in the same field, change its format from String (outdated since we didn't refresh) to Url
  6. Observe that the save was successful. I would expect the toast about having to refresh fields to pop up at this point.

However, this might be an edge case. I think we've resolved the biggest issue of refreshing fields overwriting changes already, so PR LGTM!

@chrisronline
Copy link
Contributor Author

@jen-huang That's a legit bug! Great find!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@jen-huang
Copy link
Contributor

✅ Confirmed changes fixed the bug!

Copy link
Contributor

@bmcconaghy bmcconaghy left a comment

Choose a reason for hiding this comment

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

LGTM

@chrisronline chrisronline merged commit 54b7a68 into elastic:master May 22, 2018
@chrisronline chrisronline deleted the index_pattern_version_conflicts branch May 22, 2018 13:36
chrisronline added a commit to chrisronline/kibana that referenced this pull request May 22, 2018
* Pass the version along so we can get version conflict errors, then try and resolve if we can

* Update the version post save

* Refactor slightly to match setId pattern

* Tests and updates to ensure the actual changes aren't clobbered

* Ensure we return the id

* Avoid infinite recursion, welcome suggestions on how to unit test this

* Change logic for refresh fields UI button. Now it will re-call init and force a fields refresh. This ensures we pick up on field format (and other) changes

* Fix a couple issues with saving field formats, elastic#19037

* Use the right key for version
chrisronline added a commit that referenced this pull request May 22, 2018
* Pass the version along so we can get version conflict errors, then try and resolve if we can

* Update the version post save

* Refactor slightly to match setId pattern

* Tests and updates to ensure the actual changes aren't clobbered

* Ensure we return the id

* Avoid infinite recursion, welcome suggestions on how to unit test this

* Change logic for refresh fields UI button. Now it will re-call init and force a fields refresh. This ensures we pick up on field format (and other) changes

* Fix a couple issues with saving field formats, #19037

* Use the right key for version
@chrisronline
Copy link
Contributor Author

Backport:

6.x: 55b8130

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Field formatting disappears sporadically
4 participants