Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -97,10 +97,15 @@ public void testOverrideIndexSorting() throws IOException {
assertThat(type, equalTo("date"));
}

public void testConfigureStoredSource() throws IOException {
public void testConfigureStoredSourceBeforeIndexCreation() throws IOException {
var storedSourceMapping = """
{
"template": {
"settings": {
"index": {
"mode": "logsdb"
}
},
"mappings": {
"_source": {
"mode": "stored"
Expand All @@ -112,9 +117,9 @@ public void testConfigureStoredSource() throws IOException {
Exception e = assertThrows(ResponseException.class, () -> putComponentTemplate(client, "logs@custom", storedSourceMapping));
assertThat(
e.getMessage(),
containsString("updating component template [logs@custom] results in invalid composable template [logs]")
containsString("Failed to parse mapping: Indices with with index mode [logsdb] only support synthetic source")
);
assertThat(e.getMessage(), containsString("Indices with with index mode [logsdb] only support synthetic source"));
assertThat(e.getMessage(), containsString("mapper_parsing_exception"));

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

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

public void testConfigureStoredSourceWhenIndexIsCreated() throws IOException {
var storedSourceMapping = """
{
"template": {
"mappings": {
"_source": {
"mode": "stored"
}
}
}
}""";

assertOK(putComponentTemplate(client, "logs@custom", storedSourceMapping));
ResponseException e = expectThrows(ResponseException.class, () -> createDataStream(client, "logs-custom-dev"));
assertThat(e.getMessage(), containsString("Indices with with index mode [logsdb] only support synthetic source"));
}

public void testOverrideIndexCodec() throws IOException {
var indexCodecOverrideTemplate = """
{
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugin/core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@
exports org.elasticsearch.xpack.core.watcher.trigger;
exports org.elasticsearch.xpack.core.watcher.watch;
exports org.elasticsearch.xpack.core.watcher;
exports org.elasticsearch.xpack.cluster.settings;

provides org.elasticsearch.action.admin.cluster.node.info.ComponentVersionNumber
with
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import java.util.Collection;
import java.util.List;

import static org.elasticsearch.xpack.cluster.settings.ClusterSettings.CLUSTER_LOGSDB_ENABLED;
import static org.elasticsearch.xpack.logsdb.LogsdbIndexModeSettingsProvider.CLUSTER_LOGSDB_ENABLED;
import static org.elasticsearch.xpack.logsdb.SyntheticSourceLicenseService.FALLBACK_SETTING;

public class LogsDBPlugin extends Plugin {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.elasticsearch.cluster.metadata.Metadata;
import org.elasticsearch.common.compress.CompressedXContent;
import org.elasticsearch.common.regex.Regex;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.index.IndexMode;
import org.elasticsearch.index.IndexSettingProvider;
Expand All @@ -19,9 +20,13 @@
import java.util.List;
import java.util.Locale;

import static org.elasticsearch.xpack.cluster.settings.ClusterSettings.CLUSTER_LOGSDB_ENABLED;

final class LogsdbIndexModeSettingsProvider implements IndexSettingProvider {
static final Setting<Boolean> CLUSTER_LOGSDB_ENABLED = Setting.boolSetting(
"cluster.logsdb.enabled",
false,
Setting.Property.Dynamic,
Setting.Property.NodeScope
);
private static final String LOGS_PATTERN = "logs-*-*";
private volatile boolean isLogsdbEnabled;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
import java.util.List;
import java.util.Map;

import static org.elasticsearch.xpack.cluster.settings.ClusterSettings.CLUSTER_LOGSDB_ENABLED;

public class StackTemplateRegistry extends IndexTemplateRegistry {
private static final Logger logger = LogManager.getLogger(StackTemplateRegistry.class);

Expand Down Expand Up @@ -130,10 +128,10 @@ public StackTemplateRegistry(
this.clusterService = clusterService;
this.featureService = featureService;
this.stackTemplateEnabled = STACK_TEMPLATES_ENABLED.get(nodeSettings);
this.componentTemplateConfigs = loadComponentTemplateConfigs(CLUSTER_LOGSDB_ENABLED.get(nodeSettings));
this.componentTemplateConfigs = loadComponentTemplateConfigs();
}

private Map<String, ComponentTemplate> loadComponentTemplateConfigs(boolean logsDbEnabled) {
private Map<String, ComponentTemplate> loadComponentTemplateConfigs() {
final Map<String, ComponentTemplate> componentTemplates = new HashMap<>();
for (IndexTemplateConfig config : List.of(
new IndexTemplateConfig(
Expand All @@ -159,7 +157,7 @@ private Map<String, ComponentTemplate> loadComponentTemplateConfigs(boolean logs
),
new IndexTemplateConfig(
LOGS_SETTINGS_COMPONENT_TEMPLATE_NAME,
logsDbEnabled ? "/logs@settings-logsdb.json" : "/logs@settings.json",
"/logs@settings.json",
REGISTRY_VERSION,
TEMPLATE_VERSION_VARIABLE,
Map.of("xpack.stack.template.deprecated", "false")
Expand Down