[Monitoring] Remove include_type_name parameter from GET _template request#38818
Conversation
|
Pinging @elastic/es-core-features |
jtibshirani
left a comment
There was a problem hiding this comment.
Thanks @ycombinator! I left some very minor comments.
| * @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.
parametrs -> parameters
| */ | ||
| @Override | ||
| protected void doPublish(final RestClient client, final ActionListener<Boolean> listener) { | ||
| Map<String, String> parameters = new TreeMap<>(); |
There was a problem hiding this comment.
Really small comment, I think this could just be Map<String, String> parameters = Collections.singletonMap(INCLUDE_TYPE_NAME_PARAMETER, "true");.
| final Request request = new Request("PUT", resourceBasePath + "/" + resourceName); | ||
| addParameters(request); | ||
| addDefaultParameters(request); | ||
| if (parameters != null) { |
There was a problem hiding this comment.
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
|
|
||
| private void addParameters(final Request request) { | ||
| private void addDefaultParameters(final Request request) { | ||
| this.addParameters(request, this.parameters); |
There was a problem hiding this comment.
nitpick: avoid using this. except in constructors and equals methods.
pickypg
left a comment
There was a problem hiding this comment.
Change LGTM. Minor nitpicks for whitespace changes that make it look like other parts changed.
| 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.
Nitpick: unneeded white space change.
|
|
||
| checkForResource(client, listener, logger, | ||
| "", "_xpack", "watcher check", | ||
| "", "_xpack","watcher check", |
There was a problem hiding this comment.
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! |
jtibshirani
left a comment
There was a problem hiding this comment.
The new changes look good to me.
| 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.
Small comment, but but maybe it could be more natural to use a Map here?
| completeQueryString = queryString + "&" + completeQueryString; | ||
| } | ||
|
|
||
| assertThat(query, equalTo(completeQueryString)); |
There was a problem hiding this comment.
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.
|
|
||
| verifyListener(null); | ||
|
|
||
| Map <String, String> allParameters = new TreeMap<>(); |
There was a problem hiding this comment.
nitpick: Generally try to avoid TreeMap unless order is important.
…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 _templaterequests to check for existence of templates. These requests don't need to pass theinclude_type_namequery 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.