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
Add support for fine-grained settings #10116
Add support for fine-grained settings #10116
Conversation
4970d11
to
6450c98
Compare
@s1monw can you have a look please? @clintongormley can you please review the updated docs and the new settings api-wise? @dadoonet have time to double check that this breaks only potentially rivers, similar to #9992 ? |
|
||
static ScriptMode parse(String input) { | ||
input = input.toLowerCase(Locale.ROOT); | ||
switch(input) { |
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 have to have a gazillion different options here? can we just use valueOf(input.toUpperCase())
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.
we can but we usually tend to be "understanding" with user input. I don't think this is a big problem, I actually did it because the suggested syntax ("enable" and "disable") differs from what we do in other places. Also whenever we accept a boolean we accept on
, off
, true
and false
if I remember correctly
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.
then use org.elasticsearch.common.Booleans
in these cases. This one has 3 option can't we just have the 3 options and be done with it? I don't get why we need to complicate things with a gazillion options
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.
sounds good to me I am going to use Booleans
, much better. @clintongormley that means I am going to drop support for enable
and disable
as values, as we never supported those anywhere else. We support on
,true
,1
,yes
,off
,false
,0
,no
or sandbox
. I will update the docs too
Overall this looks very very good @javanna good job! I left a bunch of comments... |
6450c98
to
80b01bf
Compare
I pushed a few more commits to address review comments, and replied to all of them. Sorry if the comments got messed up, I rebased by mistake, not intentionally... |
public String toString() { | ||
//ScriptModes looks for 'dynamic' rather than 'inline' when reading settings, we should rename but we want to keep bw comp for now. | ||
if (this == INLINE) { | ||
return "dynamic"; |
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.
@clintongormley we use inline
instead of dynamic
to refer to dynamic scripts in core (also Java API)... I added this special case to convert ScriptType.INLINE to the dynamic
string in a bw comp manner. At some point we will have to choose for one of the two. Wondering which one we prefer: either use inline in settings here or rename ScriptType.INLINE to DYNAMIC in the future (master, it's a breaking change).
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.
Honestly I prefer inline, but all the user-facing stuff has been called dynamic, so I'd probably stick with that.
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.
oh boy that means that we should keep this distinction in master too, cause it's not just about bw comp. we prefer inline internally but we always called it dynamic when talking to the outside world... but I see your point, coming up with inline now among settings is confusing.
| `enable` |scripting is turned on, in the context of the setting being set. | ||
| `sandbox` |scripts may be executed only for languages that are sandboxed. | ||
|======================================================================= | ||
|
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.
Possibly mention that only expressions is sandboxed?
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.
mustache is too :) I will look into clarifying
Docs look great @javanna |
Allow to on/off scripting based on their source (where they get loaded from), the operation that executes them and their language. The settings cover the following combinations: - mode: on, off, sandbox - source: indexed, dynamic, file - engine: groovy, expressions, mustache, etc - operation: update, search, aggs, mapping The following settings are supported for every engine: script.engine.groovy.indexed.update: sandbox/on/off script.engine.groovy.indexed.search: sandbox/on/off script.engine.groovy.indexed.aggs: sandbox/on/off script.engine.groovy.indexed.mapping: sandbox/on/off script.engine.groovy.dynamic.update: sandbox/on/off script.engine.groovy.dynamic.search: sandbox/on/off script.engine.groovy.dynamic.aggs: sandbox/on/off script.engine.groovy.dynamic.mapping: sandbox/on/off script.engine.groovy.file.update: sandbox/on/off script.engine.groovy.file.search: sandbox/on/off script.engine.groovy.file.aggs: sandbox/on/off script.engine.groovy.file.mapping: sandbox/on/off For ease of use, the following more generic settings are supported too: script.indexed: sandbox/on/off script.dynamic: sandbox/on/off script.file: sandbox/on/off script.update: sandbox/on/off script.search: sandbox/on/off script.aggs: sandbox/on/off script.mapping: sandbox/on/off These will be used to calculate the more specific settings, using the stricter setting of each combination. Operation based settings have precedence over conflicting source based ones. Note that the `mustache` engine is affected by generic settings applied to any language, while native scripts aren't as they are static by definition. Also, the previous `script.disable_dynamic` setting can now be deprecated. Closes elastic#6418 Closes elastic#10116 Closes elastic#10274
marking as breaking as it breaks plugins that make use of |
Now that fine-grained script settings are supported (elastic#10116) we can remove support for the script.disable_dynamic setting. Same result as `script.disable_dynamic: false` can be obtained as follows: ``` script.inline: on script.indexed: on ```
Due to this change elastic/elasticsearch#10116 we need to update river plugin starting 1.6.0. Was a breaking change. Closes #95. (cherry picked from commit 361b613)
Due to this change elastic/elasticsearch#10116 we need to update river plugin starting 1.6.0. Was a breaking change. Closes #95.
Now that fine-grained script settings are supported (elastic#10116) we can remove support for the script.disable_dynamic setting. Same result as `script.disable_dynamic: false` can be obtained as follows: ``` script.inline: on script.indexed: on ``` An exception is thrown at startup when the old setting is set, so we make sure we tell users they have to change it rather than ignoring the setting. Closes elastic#10286
Due to this change elastic/elasticsearch#10116 we need to update river plugin starting 1.6.0. Was a breaking change. Closes #96.
Due to this change elastic/elasticsearch#10116 we need to update river plugin starting 1.6.0. Was a breaking change. Closes #96. (cherry picked from commit 3a157b6)
Plugins can make use of scripts and expose custom scripting features. Fine-grained settings introduced with elastic#10116 don't support any custom use of scripts, hence plugins are forced to choose between update, mapping, search and aggs. Introduced a new generic plugins category that can be used by plugins. Fine-grained settings apply as well: `script.plugins: off` disable any script type, for any language, only when scripts are used from plugins. `script.engine.groovy.inline.plugins: off` disables scripts when used as part of plugins, only for inline scripts and groovy language. Relates to elastic#10347
Plugins can make use of scripts and expose custom scripting features. Fine-grained settings introduced with elastic#10116 don't support any custom use of scripts, hence plugins are forced to choose between update, mapping, search and aggs. Introduced a new generic plugins category that can be used by plugins. Fine-grained settings apply as well: `script.plugins: off` disable any script type, for any language, only when scripts are used from plugins. `script.engine.groovy.inline.plugins: off` disables scripts when used as part of plugins, only for inline scripts and groovy language. Relates to elastic#10347
Removing the breaking label, this is not breaking anymore after #10419. This change itself used to be breaking, but the breakage was never released, thus 1.6 won't break anything around |
Note that this PR is against
1.x
.Allow to enable/disable scripting based on their source (where they get loaded from), the operation that executes them and their language.
The settings cover the following combinations:
on
,off
,sandbox
indexed
,dynamic
,file
groovy
,expression
,mustache
, etcupdate
,search
,aggs
,mapping
The following settings are supported for every engine:
For ease of use, the following more generic settings are supported too:
and
These will be used to calculate the more specific settings, using the stricter setting of each combination. Operation based settings have precedence over conflicting source based ones.
Note that the
mustache
engine is affected by generic settings applied to any language, while native scripts aren't as they are static by definition.Also, the previous
script.disable_dynamic
setting can now be deprecated.Closes #6418
Closes #10274