-
Notifications
You must be signed in to change notification settings - Fork 25k
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
[REST Compatible API] 'template' parameter and field on PUT index template #71238
[REST Compatible API] 'template' parameter and field on PUT index template #71238
Conversation
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. 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"))); |
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.
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]
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 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.
elasticsearch/server/src/main/java/org/elasticsearch/common/xcontent/LoggingDeprecationHandler.java
Lines 74 to 81 in 14aba7b
@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?
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.
Let's leave this as-is and discuss in our next sync. No need to block this PR.
@@ -51,6 +60,11 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC | |||
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")) { |
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.
do we need a log message here since we already have one above ?
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.
Unfortunately, yes. They're different scenarios -- ?template=blah
in the url versus "template":"blah"
in the json body.
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Related to #51816 / #68905. See also especially #49460 -- this adds back the index template parameter and field (via rest compatibility).