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

deprecate types for watcher #37594

Merged
merged 8 commits into from
Jan 28, 2019

Conversation

jakelandis
Copy link
Contributor

this commit adds deprecation warnings for index actions
and search actions when executed via watcher

relates #35190

this commit adds deprecation warnings for index actions
and search actions when executed via watcher

relates elastic#35190
Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

Thanks @jakelandis, this looks good to me overall from the types deprecation side. A couple comments about testing:

  • It would be nice to add a test for an index action that omits the type parameter completely, as I don't think this was allowed before we introduced the typeless _bulk and index APIs.
  • Relatedly, we've been making sure to update the REST tests to use the new typeless APIs wherever possible. I noticed that 70_put_watch_with_index_action_using_id and other tests still use a document type. It would be good to make these tests typeless (adding a skip for all versions < 7.0, since they don't support omitting the document type), and also create another one 71_..._with_types to make sure to still test the old functionality in a mixed-version setting. This PR gives a good example of how we've been updating the REST yml tests: Deprecate the document create endpoint. #36863

@spinscale
Copy link
Contributor

as we are using the WatcherSearchTemplateRequest also for search transforms this is implicitely covered as well.

One thing to note: This will be logged with every watch execution.

Copy link
Contributor

@spinscale spinscale left a comment

Choose a reason for hiding this comment

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

fine from the watcher side of things

@jtibshirani
Copy link
Contributor

I'm not sure if you're looking for another review just yet, but in hopes of saving you some time:

@jakelandis
Copy link
Contributor Author

@jtibshirani - not quite ready for review. I have a few more tests I am stabilizing.

However, for any of the REST tests under https://github.com/elastic/elasticsearch/tree/master/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher I am pretty confident that they do not need to be bwc since they are not run in any mixed cluster environment.

I will ping you here when this is ready for re-review.

@@ -90,7 +90,7 @@ public void testResponseToData() throws Exception {

public void testSerializeSearchRequest() throws Exception {
String[] expectedIndices = generateRandomStringArray(5, 5, true);
String[] expectedTypes = generateRandomStringArray(2, 5, true);
String[] expectedTypes = generateRandomStringArray(2, 5, true, false);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This parameter controls if there can be an types = [] (empty array). Empty types will be treated as null, but will still trigger deprecation warning. I chose to dis-allow this in the tests since it is an odd/rare case of specifying types, but without specifying types which would make the tests more complex then they already are (3 states instead of 2 when determining if it hasTypes).

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a very minor point, but I wonder if it would be possible to do a small refactor in WatcherSearchTemplateRequest#fromXContent so that an empty types array is not treated as type == null?

@jakelandis
Copy link
Contributor Author

@jtibshirani @spinscale - would mind taking another look. I have updated the all of the testing to either be type free or deprecation aware.

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

I am pretty confident that they do not need to be bwc since they are not run in any mixed cluster environment.

Thanks, I wasn't aware that these tests weren't run in a mixed-version set-up like the other REST yml tests. My one question here is whether you feel the old behavior (in particular supplying types in index actions) still has some test coverage? We will still be supporting it for the duration of 7.x.

One area I overlooked in my original review is documentation. For example, it would be great to update watcher/actions/index.asciidoc to no longer specify doc_type in the index action.

Lastly, I wanted to double-check that we are fine with this approach of issuing a deprecation warning on every watch execution, and also for 'get watch' requests that load deprecated watch definitions.

@@ -90,7 +90,7 @@ public void testResponseToData() throws Exception {

public void testSerializeSearchRequest() throws Exception {
String[] expectedIndices = generateRandomStringArray(5, 5, true);
String[] expectedTypes = generateRandomStringArray(2, 5, true);
String[] expectedTypes = generateRandomStringArray(2, 5, true, false);
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a very minor point, but I wonder if it would be possible to do a small refactor in WatcherSearchTemplateRequest#fromXContent so that an empty types array is not treated as type == null?

@jakelandis
Copy link
Contributor Author

@jtibshirani thanks for the re-review.

I wasn't aware that these tests weren't run in a mixed-version set-up like the other REST yml tests.

Same here until I tried to explicitly test them and couldn't find a way to run them. It isn't just watcher, but all the x-pack tests in this package.

one question here is whether you feel the old behavior (in particular supplying types in index actions) still has some test coverage?

Yes, index actions are explicitly unit tested here and integration here. Search is similarly tested. While we don't have as many REST tests that cover this flow, the unit tests do a good job and the REST integration covers the paths in question.

One area I overlooked in my original review is documentation

Agree'd but would prefer to do that on a separate PR.

Lastly, I wanted to double-check that we are fine with this approach of issuing a deprecation warning on every watch execution, and also for 'get watch' requests that load deprecated watch definitions.

It will send the deprecation header, but may or may not log based on the behavior of deprecatedAndMaybeLog. For internal watch execution (ie. the scheduled watch) the header will just be discarded, there isn't a worry about flooding the deprecation logs.

This is a very minor point, but I wonder if it would be possible to do a small refactor in WatcherSearchTemplateRequest#fromXContent so that an empty types array is not treated as type == null

I believe that if, for some reason, a user sets the types to [] it should be treated as null. It is odd that we accept empty array at all since this is an optional field. I would prefer in 7.x to (logically) cast [] to no type (null), so when we remove types altogether it less of a corner case.

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

I believe that if, for some reason, a user sets the types to [] it should be treated as null.

For context, elsewhere in the search code we always model 'no types' as an empty types array, and do not use null. So I was suggesting keeping that as the standard, as opposed to allowing the types array to become null at any point. In any case, happy to do what you find cleanest here!

@jakelandis jakelandis merged commit 99b75a9 into elastic:master Jan 28, 2019
jakelandis added a commit to jakelandis/elasticsearch that referenced this pull request Jan 30, 2019
Types have been deprecated and this commit removes the documentation
for specifying types in the index action, and search input/transform.

Relates elastic#37594 elastic#35190
jakelandis added a commit that referenced this pull request Jan 30, 2019
Types have been deprecated and this commit removes the documentation
for specifying types in the index action, and search input/transform.

Relates #37594 #35190
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.

None yet

4 participants