-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
deprecate types for watcher #37594
Conversation
this commit adds deprecation warnings for index actions and search actions when executed via watcher relates elastic#35190
There was a problem hiding this 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 one71_..._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
as we are using the One thing to note: This will be logged with every watch execution. |
There was a problem hiding this 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
I'm not sure if you're looking for another review just yet, but in hopes of saving you some time:
|
@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); |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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
?
@jtibshirani @spinscale - would mind taking another look. I have updated the all of the testing to either be type free or deprecation aware. |
There was a problem hiding this 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); |
There was a problem hiding this comment.
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
?
@jtibshirani thanks for the re-review.
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.
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.
Agree'd but would prefer to do that on a separate PR.
It will send the deprecation header, but may or may not log based on the behavior of
I believe that if, for some reason, a user sets the types to |
There was a problem hiding this 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!
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
this commit adds deprecation warnings for index actions
and search actions when executed via watcher
relates #35190