Skip to content

Commit 006c274

Browse files
Remove cluster.logsdb.enabled from StackPlugin (elastic#113616) (elastic#114664)
After introducing elastic#113505 we need to remove `cluster.logsdb.enabled` from `StackPlugin` and `StackTemplateRegistry`. (cherry picked from commit 487c556) Co-authored-by: Salvatore Campagna <93581129+salvatore-campagna@users.noreply.github.com>
1 parent 47bf5b9 commit 006c274

File tree

7 files changed

+36
-57
lines changed

7 files changed

+36
-57
lines changed

modules/data-streams/src/javaRestTest/java/org/elasticsearch/datastreams/logsdb/LogsIndexModeCustomSettingsIT.java

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,15 @@ public void testOverrideIndexSorting() throws IOException {
9797
assertThat(type, equalTo("date"));
9898
}
9999

100-
public void testConfigureStoredSource() throws IOException {
100+
public void testConfigureStoredSourceBeforeIndexCreation() throws IOException {
101101
var storedSourceMapping = """
102102
{
103103
"template": {
104+
"settings": {
105+
"index": {
106+
"mode": "logsdb"
107+
}
108+
},
104109
"mappings": {
105110
"_source": {
106111
"mode": "stored"
@@ -112,9 +117,9 @@ public void testConfigureStoredSource() throws IOException {
112117
Exception e = assertThrows(ResponseException.class, () -> putComponentTemplate(client, "logs@custom", storedSourceMapping));
113118
assertThat(
114119
e.getMessage(),
115-
containsString("updating component template [logs@custom] results in invalid composable template [logs]")
120+
containsString("Failed to parse mapping: Indices with with index mode [logsdb] only support synthetic source")
116121
);
117-
assertThat(e.getMessage(), containsString("Indices with with index mode [logsdb] only support synthetic source"));
122+
assertThat(e.getMessage(), containsString("mapper_parsing_exception"));
118123

119124
assertOK(createDataStream(client, "logs-custom-dev"));
120125

@@ -123,6 +128,23 @@ public void testConfigureStoredSource() throws IOException {
123128
assertThat(sourceMode, equalTo("synthetic"));
124129
}
125130

131+
public void testConfigureStoredSourceWhenIndexIsCreated() throws IOException {
132+
var storedSourceMapping = """
133+
{
134+
"template": {
135+
"mappings": {
136+
"_source": {
137+
"mode": "stored"
138+
}
139+
}
140+
}
141+
}""";
142+
143+
assertOK(putComponentTemplate(client, "logs@custom", storedSourceMapping));
144+
ResponseException e = expectThrows(ResponseException.class, () -> createDataStream(client, "logs-custom-dev"));
145+
assertThat(e.getMessage(), containsString("Indices with with index mode [logsdb] only support synthetic source"));
146+
}
147+
126148
public void testOverrideIndexCodec() throws IOException {
127149
var indexCodecOverrideTemplate = """
128150
{

x-pack/plugin/core/src/main/java/module-info.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@
228228
exports org.elasticsearch.xpack.core.watcher.trigger;
229229
exports org.elasticsearch.xpack.core.watcher.watch;
230230
exports org.elasticsearch.xpack.core.watcher;
231-
exports org.elasticsearch.xpack.cluster.settings;
232231

233232
provides org.elasticsearch.action.admin.cluster.node.info.ComponentVersionNumber
234233
with

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/cluster/settings/ClusterSettings.java

Lines changed: 0 additions & 19 deletions
This file was deleted.

x-pack/plugin/core/template-resources/src/main/resources/logs@settings-logsdb.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

x-pack/plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/LogsDBPlugin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.util.Collection;
1818
import java.util.List;
1919

20-
import static org.elasticsearch.xpack.cluster.settings.ClusterSettings.CLUSTER_LOGSDB_ENABLED;
20+
import static org.elasticsearch.xpack.logsdb.LogsdbIndexModeSettingsProvider.CLUSTER_LOGSDB_ENABLED;
2121
import static org.elasticsearch.xpack.logsdb.SyntheticSourceLicenseService.FALLBACK_SETTING;
2222

2323
public class LogsDBPlugin extends Plugin {

x-pack/plugin/logsdb/src/main/java/org/elasticsearch/xpack/logsdb/LogsdbIndexModeSettingsProvider.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.elasticsearch.cluster.metadata.Metadata;
1111
import org.elasticsearch.common.compress.CompressedXContent;
1212
import org.elasticsearch.common.regex.Regex;
13+
import org.elasticsearch.common.settings.Setting;
1314
import org.elasticsearch.common.settings.Settings;
1415
import org.elasticsearch.index.IndexMode;
1516
import org.elasticsearch.index.IndexSettingProvider;
@@ -19,9 +20,13 @@
1920
import java.util.List;
2021
import java.util.Locale;
2122

22-
import static org.elasticsearch.xpack.cluster.settings.ClusterSettings.CLUSTER_LOGSDB_ENABLED;
23-
2423
final class LogsdbIndexModeSettingsProvider implements IndexSettingProvider {
24+
static final Setting<Boolean> CLUSTER_LOGSDB_ENABLED = Setting.boolSetting(
25+
"cluster.logsdb.enabled",
26+
false,
27+
Setting.Property.Dynamic,
28+
Setting.Property.NodeScope
29+
);
2530
private static final String LOGS_PATTERN = "logs-*-*";
2631
private volatile boolean isLogsdbEnabled;
2732

x-pack/plugin/stack/src/main/java/org/elasticsearch/xpack/stack/StackTemplateRegistry.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@
3535
import java.util.List;
3636
import java.util.Map;
3737

38-
import static org.elasticsearch.xpack.cluster.settings.ClusterSettings.CLUSTER_LOGSDB_ENABLED;
39-
4038
public class StackTemplateRegistry extends IndexTemplateRegistry {
4139
private static final Logger logger = LogManager.getLogger(StackTemplateRegistry.class);
4240

@@ -130,10 +128,10 @@ public StackTemplateRegistry(
130128
this.clusterService = clusterService;
131129
this.featureService = featureService;
132130
this.stackTemplateEnabled = STACK_TEMPLATES_ENABLED.get(nodeSettings);
133-
this.componentTemplateConfigs = loadComponentTemplateConfigs(CLUSTER_LOGSDB_ENABLED.get(nodeSettings));
131+
this.componentTemplateConfigs = loadComponentTemplateConfigs();
134132
}
135133

136-
private Map<String, ComponentTemplate> loadComponentTemplateConfigs(boolean logsDbEnabled) {
134+
private Map<String, ComponentTemplate> loadComponentTemplateConfigs() {
137135
final Map<String, ComponentTemplate> componentTemplates = new HashMap<>();
138136
for (IndexTemplateConfig config : List.of(
139137
new IndexTemplateConfig(
@@ -159,7 +157,7 @@ private Map<String, ComponentTemplate> loadComponentTemplateConfigs(boolean logs
159157
),
160158
new IndexTemplateConfig(
161159
LOGS_SETTINGS_COMPONENT_TEMPLATE_NAME,
162-
logsDbEnabled ? "/logs@settings-logsdb.json" : "/logs@settings.json",
160+
"/logs@settings.json",
163161
REGISTRY_VERSION,
164162
TEMPLATE_VERSION_VARIABLE,
165163
Map.of("xpack.stack.template.deprecated", "false")

0 commit comments

Comments
 (0)