Skip to content

Don't emit deprecation warnings on calls to the monitoring bulk API.#39805

Merged
jpountz merged 4 commits intoelastic:masterfrom
jpountz:fix/monitoring_bulk_warnings
Mar 8, 2019
Merged

Don't emit deprecation warnings on calls to the monitoring bulk API.#39805
jpountz merged 4 commits intoelastic:masterfrom
jpountz:fix/monitoring_bulk_warnings

Conversation

@jpountz
Copy link
Copy Markdown
Contributor

@jpountz jpountz commented Mar 7, 2019

The monitoring bulk API accepts the same format as the bulk API, yet its concept
of types is different from "mapping types" and the deprecation warning is only
emitted as a side-effect of this API reusing the parsing logic of bulk requests.

This commit extracts the parsing logic from _bulk into its own class with a
new flag that allows to configure whether usage of _type should emit a warning
or not. Support for payloads has been removed for simplicity since they were
unused.

@jakelandis has a separate change that removes this notion of type from the
monitoring bulk API that we are considering bringing to 8.0: #39336.

The monitoring bulk API accepts the same format as the bulk API, yet its concept
of types is different from "mapping types" and the deprecation warning is only
emitted as a side-effect of this API reusing the parsing logic of bulk requests.

This commit extracts the parsing logic from `_bulk` into its own class with a
new flag that allows to configure whether usage of `_type` should emit a warning
or not. Support for payloads has been removed for simplicity since they were
unused.

@jakelandis has a separate change that removes this notion of type from the
monitoring bulk API that we are considering bringing to 8.0: elastic#39336.
@jpountz jpountz requested a review from jakelandis March 7, 2019 18:24
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-core-features

Copy link
Copy Markdown
Contributor

@jakelandis jakelandis left a comment

Choose a reason for hiding this comment

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

LGTM, just a couple minor comments.

Also, just for my own education, what were payloads ?

* will be passed to the {@code indexRequestConsumer}, update requests to the
* {@code updateRequestConsumer} and delete requests to the {@code deleteRequestConsumer}.
*/
public void parse(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this method as-is carry a @deprecate and then add in a non-deprecrated variant that passes in the defaultType for type for you. I found that deprecation (in the BulkRequest) helpful to know I shouldn't pass in a defaultType (with out that pattern I would be unsure to explicitly send _doc or null).

For example BulkRequest#add helps the developer out to know not to pass in a defaultType https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/bulk/BulkRequest.java#L343

public void parse(
BytesReference data, @Nullable String defaultIndex, @Nullable String defaultType,
@Nullable String defaultRouting, @Nullable FetchSourceContext defaultFetchSourceContext,
@Nullable String defaultPipeline, boolean allowExplicitIndex,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: should the variables get renamed ? defaultRouting -> routing and defaultPipeline -> pipeline (since here there is no delineation between default or global)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think the defaultRouting and defaultPipeline names still make sense since they can be overridden on a per-document basis?

parsed.set(true);
},
req -> fail(), req -> fail());
assertTrue(parsed.get());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this (and tests below) need to conditionally assert assertWarnings(RestBulkAction.TYPES_DEPRECATION_MESSAGE); based on the randomBoolean() (line 34) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They don't since the document doesn't include a _type.

@jakelandis
Copy link
Copy Markdown
Contributor

has a separate change that removes this notion of type from the monitoring bulk API that we are considering bringing to 8.0: #39336.

The statement is correct, but it won't be that PR #.

@jakelandis
Copy link
Copy Markdown
Contributor

The CI failure is can be fixed with

diff --git a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
index 6d3e4c04c13..ebd6590a80c 100644
--- a/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
+++ b/server/src/test/java/org/elasticsearch/action/bulk/BulkRequestTests.java
@@ -352,7 +352,7 @@ public class BulkRequestTests extends ESTestCase {
         String bulkAction = copyToStringFromClasspath("/org/elasticsearch/action/bulk/simple-bulk11.json");
         IllegalArgumentException expectThrows = expectThrows(IllegalArgumentException.class, () -> new BulkRequest()
                 .add(bulkAction.getBytes(StandardCharsets.UTF_8), 0, bulkAction.length(), null, XContentType.JSON));
-        assertEquals("The bulk request must be terminated by a newline [\n]", expectThrows.getMessage());
+        assertEquals("The bulk request must be terminated by a newline [\\n]", expectThrows.getMessage());

         String bulkActionWithNewLine = bulkAction + "\n";
         BulkRequest bulkRequestWithNewLine = new BulkRequest();

(I assume that was an intentional change)

@jpountz
Copy link
Copy Markdown
Contributor Author

jpountz commented Mar 8, 2019

Thanks, I wanted to open this PR before logging off and I had not had time to run all tests yet. The change to the error is intentional indeed. Thanks for reviewing!

I am not entirely sure about payloads. I suspect it was a way to associate metadata with every index request that would be included in the response as well, but the git log suggests that we started adding this feature and never finished.

@jpountz jpountz merged commit 8d359db into elastic:master Mar 8, 2019
@jpountz jpountz deleted the fix/monitoring_bulk_warnings branch March 8, 2019 13:01
jpountz added a commit to jpountz/elasticsearch that referenced this pull request Mar 8, 2019
…lastic#39805)

The monitoring bulk API accepts the same format as the bulk API, yet its concept
of types is different from "mapping types" and the deprecation warning is only
emitted as a side-effect of this API reusing the parsing logic of bulk requests.

This commit extracts the parsing logic from `_bulk` into its own class with a
new flag that allows to configure whether usage of `_type` should emit a warning
or not. Support for payloads has been removed for simplicity since they were
unused.

@jakelandis has a separate change that removes this notion of type from the
monitoring bulk API that we are considering bringing to 8.0.
jpountz added a commit to jpountz/elasticsearch that referenced this pull request Mar 8, 2019
…lastic#39805)

The monitoring bulk API accepts the same format as the bulk API, yet its concept
of types is different from "mapping types" and the deprecation warning is only
emitted as a side-effect of this API reusing the parsing logic of bulk requests.

This commit extracts the parsing logic from `_bulk` into its own class with a
new flag that allows to configure whether usage of `_type` should emit a warning
or not. Support for payloads has been removed for simplicity since they were
unused.

@jakelandis has a separate change that removes this notion of type from the
monitoring bulk API that we are considering bringing to 8.0.
jpountz added a commit that referenced this pull request Mar 11, 2019
…39805) (#39838)

The monitoring bulk API accepts the same format as the bulk API, yet its concept
of types is different from "mapping types" and the deprecation warning is only
emitted as a side-effect of this API reusing the parsing logic of bulk requests.

This commit extracts the parsing logic from `_bulk` into its own class with a
new flag that allows to configure whether usage of `_type` should emit a warning
or not. Support for payloads has been removed for simplicity since they were
unused.

@jakelandis has a separate change that removes this notion of type from the
monitoring bulk API that we are considering bringing to 8.0.
jpountz added a commit that referenced this pull request Mar 11, 2019
…39805) (#39843)

The monitoring bulk API accepts the same format as the bulk API, yet its concept
of types is different from "mapping types" and the deprecation warning is only
emitted as a side-effect of this API reusing the parsing logic of bulk requests.

This commit extracts the parsing logic from `_bulk` into its own class with a
new flag that allows to configure whether usage of `_type` should emit a warning
or not. Support for payloads has been removed for simplicity since they were
unused.

@jakelandis has a separate change that removes this notion of type from the
monitoring bulk API that we are considering bringing to 8.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants