From 16f5f44d415bbfe729bd067e84f748d3aba8a17c Mon Sep 17 00:00:00 2001 From: Alexander Reelsen Date: Wed, 5 Apr 2017 18:39:54 +0100 Subject: [PATCH] Watcher: Dont check index auto creation if disabled/transportclient (elastic/x-pack-elasticsearch#975) When watcher is disabled, no auto index creation checks should happen. Relates elastic/elasticsearch#23919 Original commit: elastic/x-pack-elasticsearch@d924838b4d18ebfa3a5840c8e340f651f9775515 --- .../main/java/org/elasticsearch/xpack/watcher/Watcher.java | 4 +++- .../xpack/watcher/WatcherPluginDisableTests.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java b/plugin/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java index 510534abc62..24ca4579055 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java @@ -208,7 +208,9 @@ public class Watcher implements ActionPlugin, ScriptPlugin { transportClient = "transport".equals(settings.get(Client.CLIENT_TYPE_SETTING_S.getKey())); this.enabled = XPackSettings.WATCHER_ENABLED.get(settings); this.transportClientMode = XPackPlugin.transportClientMode(settings); - validAutoCreateIndex(settings); + if (enabled && transportClientMode == false) { + validAutoCreateIndex(settings); + } } public Collection createComponents(Clock clock, ScriptService scriptService, InternalClient internalClient, diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java index 9de8d166857..4215bf1aaae 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java @@ -12,6 +12,7 @@ import java.util.Collections; import org.apache.http.HttpStatus; import org.elasticsearch.action.admin.cluster.node.info.NodeInfo; import org.elasticsearch.action.admin.cluster.node.info.NodesInfoResponse; +import org.elasticsearch.action.support.AutoCreateIndex; import org.elasticsearch.client.ResponseException; import org.elasticsearch.common.network.NetworkModule; import org.elasticsearch.common.settings.Settings; @@ -37,6 +38,8 @@ public class WatcherPluginDisableTests extends ESIntegTestCase { return Settings.builder() .put(super.nodeSettings(nodeOrdinal)) .put(XPackSettings.WATCHER_ENABLED.getKey(), false) + // prevent auto index creation, as watcher is disabled this should work + .put(AutoCreateIndex.AUTO_CREATE_INDEX_SETTING.getKey(), false) // disable security because of query cache check and authentication/authorization .put(XPackSettings.SECURITY_ENABLED.getKey(), false)