From 330718b55b4e1bbb002c811b9d702413c89db228 Mon Sep 17 00:00:00 2001 From: Anton Ebel Date: Wed, 31 Jan 2024 15:49:53 +0100 Subject: [PATCH] fix data tiering in default index set config migration (#18109) --- .../IndexSetsDefaultConfiguration.java | 13 ++++++- .../PlaceholderDataTieringConfig.java | 39 +++++++++++++++++++ ...1200_CreateDefaultIndexDefaultsConfig.java | 6 +-- 3 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 graylog2-server/src/main/java/org/graylog2/datatiering/fallback/PlaceholderDataTieringConfig.java diff --git a/graylog2-server/src/main/java/org/graylog2/configuration/IndexSetsDefaultConfiguration.java b/graylog2-server/src/main/java/org/graylog2/configuration/IndexSetsDefaultConfiguration.java index 217b8e6c03be..36bf1b76a449 100644 --- a/graylog2-server/src/main/java/org/graylog2/configuration/IndexSetsDefaultConfiguration.java +++ b/graylog2-server/src/main/java/org/graylog2/configuration/IndexSetsDefaultConfiguration.java @@ -17,6 +17,7 @@ package org.graylog2.configuration; import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.google.auto.value.AutoValue; @@ -24,6 +25,7 @@ import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; import org.graylog2.datatiering.DataTieringConfig; +import org.graylog2.datatiering.fallback.PlaceholderDataTieringConfig; import org.graylog2.plugin.PluginConfigBean; import org.graylog2.plugin.indexer.retention.RetentionStrategyConfig; import org.graylog2.plugin.indexer.rotation.RotationStrategyConfig; @@ -39,7 +41,7 @@ */ @JsonAutoDetect @AutoValue -@JsonDeserialize(builder = AutoValue_IndexSetsDefaultConfiguration.Builder.class) +@JsonDeserialize(builder = IndexSetsDefaultConfiguration.Builder.class) public abstract class IndexSetsDefaultConfiguration implements PluginConfigBean { public static final String INDEX_ANALYZER = "index_analyzer"; @@ -57,7 +59,7 @@ public abstract class IndexSetsDefaultConfiguration implements PluginConfigBean public static final String RETENTION_STRATEGY = "retention_strategy"; // alias for retention_strategy_config public static Builder builder() { - return new AutoValue_IndexSetsDefaultConfiguration.Builder(); + return Builder.create(); } @NotBlank @@ -128,6 +130,13 @@ public RetentionStrategyConfig retentionStrategy() { @AutoValue.Builder public abstract static class Builder { + + @JsonCreator + public static Builder create() { + return new AutoValue_IndexSetsDefaultConfiguration.Builder() + .dataTiering(new PlaceholderDataTieringConfig()); + } + @JsonProperty(INDEX_ANALYZER) public abstract Builder indexAnalyzer(String indexAnalyzer); diff --git a/graylog2-server/src/main/java/org/graylog2/datatiering/fallback/PlaceholderDataTieringConfig.java b/graylog2-server/src/main/java/org/graylog2/datatiering/fallback/PlaceholderDataTieringConfig.java new file mode 100644 index 000000000000..e0447b616dc0 --- /dev/null +++ b/graylog2-server/src/main/java/org/graylog2/datatiering/fallback/PlaceholderDataTieringConfig.java @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2020 Graylog, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the Server Side Public License, version 1, + * as published by MongoDB, Inc. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * Server Side Public License for more details. + * + * You should have received a copy of the Server Side Public License + * along with this program. If not, see + * . + */ +package org.graylog2.datatiering.fallback; + +import org.graylog2.datatiering.DataTieringConfig; +import org.joda.time.Period; + + +public class PlaceholderDataTieringConfig implements DataTieringConfig { + + @Override + public String type() { + return "placeholder"; + } + + @Override + public Period indexLifetimeMin() { + return Period.ZERO; + } + + @Override + public Period indexLifetimeMax() { + return Period.ZERO; + } +} diff --git a/graylog2-server/src/main/java/org/graylog2/migrations/V202211021200_CreateDefaultIndexDefaultsConfig.java b/graylog2-server/src/main/java/org/graylog2/migrations/V202211021200_CreateDefaultIndexDefaultsConfig.java index c6b612a89b1c..7836e0f84d60 100644 --- a/graylog2-server/src/main/java/org/graylog2/migrations/V202211021200_CreateDefaultIndexDefaultsConfig.java +++ b/graylog2-server/src/main/java/org/graylog2/migrations/V202211021200_CreateDefaultIndexDefaultsConfig.java @@ -16,15 +16,15 @@ */ package org.graylog2.migrations; +import jakarta.inject.Inject; import org.graylog2.configuration.ElasticsearchConfiguration; import org.graylog2.configuration.IndexSetsDefaultConfiguration; import org.graylog2.configuration.IndexSetsDefaultConfigurationFactory; +import org.graylog2.datatiering.fallback.PlaceholderDataTieringConfig; import org.graylog2.plugin.cluster.ClusterConfigService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import jakarta.inject.Inject; - import java.time.ZonedDateTime; /** @@ -54,7 +54,7 @@ public void upgrade() { if (indexSetsDefaultConfiguration == null) { indexSetsDefaultConfiguration = factory.create(); - } else if (indexSetsDefaultConfiguration.dataTiering() == null) { + } else if (indexSetsDefaultConfiguration.dataTiering() instanceof PlaceholderDataTieringConfig) { LOG.info("Applying data tiering to Indexset defaults"); indexSetsDefaultConfiguration = factory.addDataTieringDefaults(indexSetsDefaultConfiguration); } else {