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

Script: no compile rate limit for ingest templates #69841

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public <T> T compile(

@Override
public Set<ScriptContext<?>> getSupportedContexts() {
return Set.of(TemplateScript.CONTEXT);
return Set.of(TemplateScript.CONTEXT, TemplateScript.INGEST_CONTEXT);
}

private CustomMustacheFactory createMustacheFactory(Map<String, String> options) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ static ValueSource wrap(Object value, ScriptService scriptService, Map<String, S
// modified if templating is not available
if (scriptService.isLangSupported(DEFAULT_TEMPLATE_LANG) && ((String) value).contains("{{")) {
Script script = new Script(ScriptType.INLINE, DEFAULT_TEMPLATE_LANG, (String) value, scriptOptions, Map.of());
return new TemplatedValue(scriptService.compile(script, TemplateScript.CONTEXT));
return new TemplatedValue(scriptService.compile(script, TemplateScript.INGEST_CONTEXT));
} else {
return new ObjectValue(value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class ScriptModule {
SimilarityScript.CONTEXT,
SimilarityWeightScript.CONTEXT,
TemplateScript.CONTEXT,
TemplateScript.INGEST_CONTEXT,
MovingFunctionScript.CONTEXT,
ScriptedMetricAggContexts.InitScript.CONTEXT,
ScriptedMetricAggContexts.MapScript.CONTEXT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

package org.elasticsearch.script;

import org.elasticsearch.common.unit.TimeValue;

import java.util.Map;

/**
Expand Down Expand Up @@ -35,4 +37,8 @@ public interface Factory {
}

public static final ScriptContext<Factory> CONTEXT = new ScriptContext<>("template", Factory.class);

// Remove compilation rate limit for ingest
stu-elastic marked this conversation as resolved.
Show resolved Hide resolved
public static final ScriptContext<Factory> INGEST_CONTEXT = new ScriptContext<>("ingest_template", Factory.class,
200, TimeValue.timeValueMillis(0), ScriptCache.UNLIMITED_COMPILATION_RATE.asTuple());
}