Skip to content

Conversation

@jdconrad
Copy link
Contributor

This adds deprecation to _type in the script contexts for ingest and update. This adds a DeprecationMap that wraps the ctx Map containing _type for these specific contexts.

@jdconrad jdconrad added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >deprecation v7.0.0 labels Jan 16, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra

@jtibshirani
Copy link
Contributor

Looks good to me from the types deprecation side. Thanks @jdconrad for the very speedy work on this!

public IngestDocument execute(IngestDocument document) {
IngestScript.Factory factory = scriptService.compile(script, IngestScript.CONTEXT);
factory.newInstance(script.getParams()).execute(document.getSourceAndMetadata());
factory.newInstance(script.getParams()).execute(new DeprecationMap(document.getSourceAndMetadata(), DEPRECATIONS));
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that DeprecationMap uses deprecated instead of deprecatedAndMaybeLog. Is this something we might want to change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. @rjernst What are your thoughts here?

Copy link
Member

Choose a reason for hiding this comment

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

I agree deprecatedAndMaybeLog should be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 1

1 similar comment
@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 1

@jdconrad
Copy link
Contributor Author

@rjernst Modified DeprecationMap to use deprecateAndMaybeLog. Ready for another review.

@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 1

@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 2

1 similar comment
@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 2

@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 1

@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 2

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

Map<String, String> deprecations = new HashMap<>();
deprecations.put(
"_type",
"[types removal] Looking up doc types [_type] in scripts is deprecated."
Copy link
Member

Choose a reason for hiding this comment

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

Why the prefix [types removal]? I dont' think we have any prefixes like that in other deprecation messages.

Copy link
Contributor

Choose a reason for hiding this comment

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

We had to choose a shared prefix in order for there to be a consistent way to detect types deprecation messages in REST tests (and ignore them). I think @jdconrad is just using this prefix here for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was copied from the other types removal messages. I'd like to keep it for consistency unless there are other objections.

String deprecationMessage = deprecations.get(key);
if (deprecationMessage != null) {
deprecationLogger.deprecated(deprecationMessage);
deprecationLogger.deprecatedAndMaybeLog(logKeyPrefix + "_" + key, deprecationMessage);
Copy link
Member

Choose a reason for hiding this comment

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

nit: i would use - as the separator, so there is a clear distinction with the map key, since all our context names use underscores.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@jdconrad
Copy link
Contributor Author

@rjernst @jtibshirani Thanks for the reviews. Will commit as soon as CI passes.

@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 1

1 similar comment
@jdconrad
Copy link
Contributor Author

@elasticmachine run gradle build tests 1

@jdconrad jdconrad merged commit de55b4d into elastic:master Jan 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >deprecation v7.0.0-beta1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants