Skip to content
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

Remove deprecated code from stored scripts #78643

Merged
merged 10 commits into from
Oct 5, 2021
Merged

Conversation

jdconrad
Copy link
Contributor

@jdconrad jdconrad commented Oct 4, 2021

This change removes several pieces of deprecated code from stored scripts.

Stored scripts/templates are no longer allowed to be an empty and will throw an exception when used with PutStoredScript.

ScriptMetadata will now drop any existing stored scripts that are empty with a deprecation warning in the case they have not been previously removed.

The code field is now only allowed as source as part of a PutStoredScript JSON blob.

@jdconrad jdconrad added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring v8.0.0 labels Oct 4, 2021
@jdconrad jdconrad requested a review from rjernst October 4, 2021 19:47
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Oct 4, 2021
@elasticmachine
Copy link
Collaborator

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

@jdconrad jdconrad requested a review from jrodewig October 4, 2021 19:51
@jdconrad
Copy link
Contributor Author

jdconrad commented Oct 4, 2021

@jrodewig Would you please review the migration docs I've added here? Thanks in advance!

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

// since there is a guarantee no more empty scripts will exist
if (source.getSource().isEmpty()) {
if (Script.DEFAULT_TEMPLATE_LANG.equals(source.getLang())) {
deprecationLogger.critical(DeprecationCategory.TEMPLATES, "empty_templates",
Copy link
Member

Choose a reason for hiding this comment

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

I think these should be warning logs, not deprecations. The deprecation already happened, this is a warning that we are dropping something meaningless.

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.

Copy link
Contributor

@jrodewig jrodewig left a comment

Choose a reason for hiding this comment

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

Thanks @jdconrad! I left some suggestions and questions. I'll take another look once those are addressed.

@@ -22,4 +22,29 @@ scripts. Any use of `getDayOfWeek` expecting a return value of `int` will result
in a compilation error or runtime error and may not allow the upgraded node to
start.
====

.Empty scripts/templates are no longer allowed as stored scripts.
Copy link
Contributor

@jrodewig jrodewig Oct 5, 2021

Choose a reason for hiding this comment

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

Suggested change
.Empty scripts/templates are no longer allowed as stored scripts.
.Stored scripts no longer support empty scripts or search templates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 30 to 31
Empty scripts/templates cannot be specified as the source of a
PutStoredScript action.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason we reference the PutStoredScript action rather than the create or update stored script API here?

It doesn't look like it in the code, but the wording made me wonder if this only impacted the Java client.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No! Just a mistake on my part.

Comment on lines 34 to 36
Before upgrading, remove stored scripts/templates that are empty. Otherwise,
these scripts will be dropped, and may not align with the scripts on older
nodes.
Copy link
Contributor

Choose a reason for hiding this comment

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

I added a link to the delete stored script API. I assume the user will use that API to remove the scripts.

Suggested change
Before upgrading, remove stored scripts/templates that are empty. Otherwise,
these scripts will be dropped, and may not align with the scripts on older
nodes.
Before upgrading, use the {ref}/delete-stored-script-api.html[delete stored
script API] to delete any empty stored scripts or search templates.
In 8.0, {es} will drop any empty stored scripts or empty search templates from
the cluster state. Requests to create a stored script or search template with
an empty `source` will return an error.

and may not align with the scripts on older nodes.

My suggestion doesn't include this because I wasn't sure what it meant. Does it just mean that behavior will be different after the upgrade?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Poor wording on my part. I'm adopting your suggestion as the entirety of the text here.

nodes.
====

.The `code` field can no longer be specified as part of a stored script/template.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.The `code` field can no longer be specified as part of a stored script/template.
.The create or update stored script API's `code` parameter has been removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 43 to 44
The `code` field is replaced by the `source` field as the only way to specify
the source of a script.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The `code` field is replaced by the `source` field as the only way to specify
the source of a script.
The {ref}/create-stored-script-api.html[create or update stored script API]'s
`code` parameter has been removed. Use the `source` parameter instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 47 to 48
Before upgrading, any calls to PutStoredScript should use `source` instead
of `code`.
Copy link
Contributor

@jrodewig jrodewig Oct 5, 2021

Choose a reason for hiding this comment

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

Suggested change
Before upgrading, any calls to PutStoredScript should use `source` instead
of `code`.
Discontinue use of the `code` parameter. Requests that include the parameter
will return an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@jdconrad
Copy link
Contributor Author

jdconrad commented Oct 5, 2021

@jrodewig Thanks for the detailed review! I have merged your feedback and updated the details for section where script source cannot be empty. Ready for the next round.

Copy link
Contributor

@jrodewig jrodewig left a comment

Choose a reason for hiding this comment

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

Docs look great! Thanks @jdconrad!

@jdconrad
Copy link
Contributor Author

jdconrad commented Oct 5, 2021

@rjernst and @jrodewig Thanks for the reviews!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >refactoring Team:Core/Infra Meta label for core/infra team v8.0.0-beta1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants