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

[Monitoring] Remove include_type_name parameter from GET _template request #38818

Merged
merged 21 commits into from
Feb 14, 2019

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Feb 12, 2019

The HTTP exporter code in the Monitoring plugin makes GET _template requests to check for existence of templates. These requests don't need to pass the include_type_name query parameter so this PR removes it from the request. This should remove the following deprecation log entries on the Monitoring cluster in 7.0.0 onwards:

[types removal] Specifying include_type_name in get index template requests is deprecated.

Addresses #37442.

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

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 @ycombinator! I left some very minor comments.

@@ -299,6 +300,7 @@ public void onFailure(final Exception exception) {
* @param logger The logger to use for status messages.
* @param resourceBasePath The base path/endpoint to check for the resource (e.g., "/_template").
* @param resourceName The name of the resource (e.g., "template123").
* @param parameters Map of query string parametrs, if any.
Copy link
Contributor

Choose a reason for hiding this comment

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

parametrs -> parameters

@@ -88,8 +88,11 @@ protected void doCheck(final RestClient client, final ActionListener<Boolean> li
*/
@Override
protected void doPublish(final RestClient client, final ActionListener<Boolean> listener) {
Map<String, String> parameters = new TreeMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

Really small comment, I think this could just be Map<String, String> parameters = Collections.singletonMap(INCLUDE_TYPE_NAME_PARAMETER, "true");.

@@ -317,7 +320,10 @@ protected void putResource(final RestClient client,


final Request request = new Request("PUT", resourceBasePath + "/" + resourceName);
addParameters(request);
addDefaultParameters(request);
if (parameters != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I tend to prefer using empty collections instead of making parameters nullable (we could just use Collections.emptyMap() in all the calls that don't need additional parameters).

@@ -463,7 +469,11 @@ protected boolean alwaysReplaceResource(final Response response) {
return true;
}

private void addParameters(final Request request) {
private void addDefaultParameters(final Request request) {
this.addParameters(request, this.parameters);
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: avoid using this. except in constructors and equals methods.

Copy link
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

Copy link
Member

@pickypg pickypg left a comment

Choose a reason for hiding this comment

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

Change LGTM. Minor nitpicks for whitespace changes that make it look like other parts changed.

@@ -78,7 +78,7 @@ public TemplateHttpResource(final String resourceOwnerName, @Nullable final Time
@Override
protected void doCheck(final RestClient client, final ActionListener<Boolean> listener) {
versionCheckForResource(client, listener, logger,
"/_template", templateName, "monitoring template",
"/_template", templateName, "monitoring template",
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: unneeded white space change.

@@ -104,7 +104,7 @@ private void checkXPackForWatcher(final RestClient client, final ActionListener<
final CheckedFunction<Response, Boolean, IOException> doesNotExistChecker = (response) -> false;

checkForResource(client, listener, logger,
"", "_xpack", "watcher check",
"", "_xpack","watcher check",
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: unneeded white space change.

@ycombinator
Copy link
Contributor Author

@jtibshirani @jakelandis @pickypg I made a few more changes, primarily to tests, after your last rounds of review. So would you mind taking another gander at this PR when you get a chance? Thanks!

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.

The new changes look good to me.

assertHeaders(getRequest, customHeaders);

if (alreadyExists == false) {
final MockRequest putRequest = webServer.takeRequest();

assertThat(putRequest.getMethod(), equalTo("PUT"));
assertThat(putRequest.getUri().getPath(), equalTo(pathPrefix + resourcePrefix + resource.v1()));
assertMonitorVersionQueryString(resourcePrefix, getRequest.getUri().getQuery());
final String[] parameters = resourcePrefix.startsWith("/_template")
Copy link
Contributor

Choose a reason for hiding this comment

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

Small comment, but but maybe it could be more natural to use a Map here?

}

assertThat(query, equalTo(completeQueryString));
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe that this assert will only work on with empty or single params, or maps backed by a TreeMap since the order is relevant when comparing the String representation.

I would suggest to avoid re-building the string, and run the String result of getRequest.getUri().getQuery() (e.g. the first param) through https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/rest/RestUtils.java#L40 to get the corresponding Map and then compare the Maps.

@@ -182,16 +187,20 @@ protected void assertPublishWithException(final PublishableHttpResource resource

verifyListener(null);

Map <String, String> allParameters = new TreeMap<>();
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: Generally try to avoid TreeMap unless order is important.

Copy link
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

@ycombinator ycombinator merged commit 7bcfa45 into elastic:master Feb 14, 2019
@ycombinator ycombinator deleted the monitoring-remove-type-param branch February 14, 2019 20:55
ycombinator added a commit to ycombinator/elasticsearch that referenced this pull request Feb 14, 2019
…request (elastic#38818)

The HTTP exporter code in the Monitoring plugin makes `GET _template` requests to check for existence of templates. These requests don't need to pass the `include_type_name` query parameter so this PR removes it from the request. This should remove the following deprecation log entries on the Monitoring cluster in 7.0.0 onwards:

```
[types removal] Specifying include_type_name in get index template requests is deprecated.
```
ycombinator added a commit to ycombinator/elasticsearch that referenced this pull request Feb 14, 2019
…request (elastic#38818)

The HTTP exporter code in the Monitoring plugin makes `GET _template` requests to check for existence of templates. These requests don't need to pass the `include_type_name` query parameter so this PR removes it from the request. This should remove the following deprecation log entries on the Monitoring cluster in 7.0.0 onwards:

```
[types removal] Specifying include_type_name in get index template requests is deprecated.
```
jasontedor added a commit to jasontedor/elasticsearch that referenced this pull request Feb 14, 2019
* master:
  Adjust BWC version for token/API key service (elastic#38917)
  [Monitoring] Remove `include_type_name` parameter from GET _template request (elastic#38818)
  Revert "[test] disable packaging tests for suse boxes" (elastic#38864)
ycombinator added a commit that referenced this pull request Feb 15, 2019
…request (#38926)

Backport of #38818 to `7.0`. Original description:

The HTTP exporter code in the Monitoring plugin makes `GET _template` requests to check for existence of templates. These requests don't need to pass the `include_type_name` query parameter so this PR removes it from the request. This should remove the following deprecation log entries on the Monitoring cluster in 7.0.0 onwards:

```
[types removal] Specifying include_type_name in get index template requests is deprecated.
```
ycombinator added a commit that referenced this pull request Feb 15, 2019
…request (#38925)

Backport of #38818 to `7.x`. Original description:

The HTTP exporter code in the Monitoring plugin makes `GET _template` requests to check for existence of templates. These requests don't need to pass the `include_type_name` query parameter so this PR removes it from the request. This should remove the following deprecation log entries on the Monitoring cluster in 7.0.0 onwards:

```
[types removal] Specifying include_type_name in get index template requests is deprecated.
```
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.

7 participants