Skip to content

Conversation

@joegallo
Copy link
Contributor

@joegallo joegallo commented Apr 2, 2021

Related to #51816 / #68905. See also especially #49460 -- this adds back the index template parameter and field (via rest compatibility).

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. Nothing blocking but a couple questions about the log message.

if (request.getRestApiVersion() == RestApiVersion.V_7 && request.hasParam("template")) {
deprecationLogger.compatibleApiWarning("template_parameter_deprecation",
"Deprecated parameter [template] used, replaced by [index_patterns]");
putRequest.patterns(List.of(request.param("template")));
Copy link
Contributor

Choose a reason for hiding this comment

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

Can the message be a bit more descriptive ?

The deprecated field [template] was included in the request, API compatibility was used to map this field to [index_patterns]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could change it, sure, but I was aiming to have it be very much in line with the automatic logging we'll see from ParseField when api compatibility is invoked.

@Override
public void logReplacedField(String parserName, Supplier<XContentLocation> location, String oldName, String replacedName,
boolean isCompatibleDeprecation) {
String prefix = parserLocation(parserName, location);
TriConsumer<String, Object[], String> loggingFunction = getLoggingFunction(isCompatibleDeprecation);
loggingFunction.apply("{}Deprecated field [{}] used, replaced by [{}]",
new Object[]{prefix, oldName, replacedName}, oldName);
}

So on the one hand we could be consistent with that (my original aim) or on the other we could be more descriptive. I don't have a strong preference -- which way would you prefer it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave this as-is and discuss in our next sync. No need to block this PR.

Map<String, Object> sourceAsMap = XContentHelper.convertToMap(request.requiredContent(), false,
request.getXContentType()).v2();
sourceAsMap = RestCreateIndexAction.prepareMappings(sourceAsMap);
if (request.getRestApiVersion() == RestApiVersion.V_7 && sourceAsMap.containsKey("template")) {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need a log message here since we already have one above ?

Copy link
Contributor Author

@joegallo joegallo Apr 2, 2021

Choose a reason for hiding this comment

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

Unfortunately, yes. They're different scenarios -- ?template=blah in the url versus "template":"blah" in the json body.

@joegallo joegallo changed the title [REST Compatible API] 'template' parameter and field on PUT index template. [REST Compatible API] 'template' parameter and field on PUT index template Apr 2, 2021
@joegallo joegallo removed the WIP label Apr 2, 2021
@joegallo joegallo marked this pull request as ready for review April 2, 2021 19:13
@joegallo joegallo merged commit 4ff17c1 into elastic:master Apr 2, 2021
@joegallo joegallo deleted the put-index-template-api-version-compatibility branch April 2, 2021 19:17
@jakelandis jakelandis added v8.0.0-alpha1 >enhancement :Core/Infra/REST API REST infrastructure and utilities and removed v8.0.0 labels Jul 26, 2021
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Jul 28, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/REST API REST infrastructure and utilities >enhancement Team:Core/Infra Meta label for core/infra team v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants