-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
[Monitoring] Remove include_type_name
parameter from GET _template request
#38818
Conversation
Pinging @elastic/es-core-features |
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 @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. |
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.
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<>(); |
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.
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) { |
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 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).
.../src/main/java/org/elasticsearch/xpack/monitoring/exporter/http/PublishableHttpResource.java
Show resolved
Hide resolved
@@ -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); |
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.
nitpick: avoid using this.
except in constructors and equals methods.
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.
LGTM
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.
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", |
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.
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", |
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.
Nitpick: unneeded white space change.
@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! |
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.
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") |
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.
Small comment, but but maybe it could be more natural to use a Map
here?
} | ||
|
||
assertThat(query, equalTo(completeQueryString)); |
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 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<>(); |
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.
nitpick: Generally try to avoid TreeMap unless order is important.
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.
LGTM
…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. ```
…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. ```
* 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)
…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. ```
…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. ```
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 theinclude_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:Addresses #37442.