Skip to content

Commit

Permalink
Remove cluster.logsdb.enabled from StackPlugin (#113616)
Browse files Browse the repository at this point in the history
After introducing #113505 we need to remove `cluster.logsdb.enabled` from
`StackPlugin` and `StackTemplateRegistry`.
  • Loading branch information
salvatore-campagna committed Sep 30, 2024
1 parent a1a46d4 commit 487c556
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,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 @@ -111,9 +116,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 @@ -122,6 +127,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 @@ -12,6 +12,7 @@
import org.elasticsearch.cluster.metadata.MetadataIndexTemplateService;
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 @@ -21,9 +22,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 ? "/[email protected]" : "/[email protected]",
"/[email protected]",
REGISTRY_VERSION,
TEMPLATE_VERSION_VARIABLE,
Map.of("xpack.stack.template.deprecated", "false")
Expand Down

0 comments on commit 487c556

Please sign in to comment.