From 9a18e273a258541ffd5894a1279ad2c78b4ff2bf Mon Sep 17 00:00:00 2001 From: Russ Cam Date: Fri, 21 Feb 2020 20:16:48 +1100 Subject: [PATCH] Deprecate index soft delete enabled setting (#4411) Relates: #4341, elastic/elasticsearch#50502 This commit marks the enabled setting on soft delete index settings as obsolete, as setting enabled to false is deprecated. --- .../IndexSettings/Settings/IndexSettingsFormatter.cs | 4 ++++ .../IndexSettings/SoftDeletes/ISoftDeleteSettings.cs | 3 +++ .../CrossClusterReplicationFollowTests.cs | 2 -- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Nest/IndexModules/IndexSettings/Settings/IndexSettingsFormatter.cs b/src/Nest/IndexModules/IndexSettings/Settings/IndexSettingsFormatter.cs index ecc94ca3bb7..33e28a4813e 100644 --- a/src/Nest/IndexModules/IndexSettings/Settings/IndexSettingsFormatter.cs +++ b/src/Nest/IndexModules/IndexSettings/Settings/IndexSettingsFormatter.cs @@ -123,7 +123,9 @@ void Set(string knownKey, object newValue) Set(RoutingPartitionSize, indexSettings.RoutingPartitionSize); if (indexSettings.SoftDeletes != null) { +#pragma warning disable 618 Set(SoftDeletesEnabled, indexSettings.SoftDeletes.Enabled); +#pragma warning restore 618 Set(SoftDeletesRetentionOperations, indexSettings.SoftDeletes.Retention?.Operations); } @@ -259,7 +261,9 @@ private static void SetKnownIndexSettings(ref JsonReader reader, IJsonFormatterR Set(s, settings, QueriesCacheEnabled, v => queriesCache.Enabled = v, formatterResolver); var softDeletes = s.SoftDeletes = new SoftDeleteSettings(); +#pragma warning disable 618 Set(s, settings, SoftDeletesEnabled, v => softDeletes.Enabled = v, formatterResolver); +#pragma warning restore 618 var softDeletesRetention = s.SoftDeletes.Retention = new SoftDeleteRetentionSettings(); Set(s, settings, SoftDeletesEnabled, v => softDeletesRetention.Operations = v, formatterResolver); diff --git a/src/Nest/IndexModules/IndexSettings/SoftDeletes/ISoftDeleteSettings.cs b/src/Nest/IndexModules/IndexSettings/SoftDeletes/ISoftDeleteSettings.cs index 1a1f1239dd5..7508f941cde 100644 --- a/src/Nest/IndexModules/IndexSettings/SoftDeletes/ISoftDeleteSettings.cs +++ b/src/Nest/IndexModules/IndexSettings/SoftDeletes/ISoftDeleteSettings.cs @@ -4,6 +4,7 @@ namespace Nest { public interface ISoftDeleteSettings { + [Obsolete("Creating indices with soft-deletes disabled is deprecated and will be removed in future Elasticsearch versions. Do not set a value of 'false'")] /// Enables soft deletes on the index bool? Enabled { get; set; } /// Configure the retention of soft deletes on the index @@ -15,6 +16,7 @@ public class SoftDeleteSettings : ISoftDeleteSettings /// public ISoftDeleteRetentionSettings Retention { get; set; } + [Obsolete("Creating indices with soft-deletes disabled is deprecated and will be removed in future Elasticsearch versions. Do not set a value of 'false'")] /// public bool? Enabled { get; set; } } @@ -28,6 +30,7 @@ public class SoftDeleteSettingsDescriptor : DescriptorBase selector) => Assign(selector.Invoke(new SoftDeleteRetentionSettingsDescriptor()), (a, v) => a.Retention = v); + [Obsolete("Creating indices with soft-deletes disabled is deprecated and will be removed in future Elasticsearch versions. Do not set a value of 'false'")] /// public SoftDeleteSettingsDescriptor Enabled(bool? enabled = true) => Assign(enabled, (a, v) => a.Enabled = v); } diff --git a/tests/Tests/XPack/CrossClusterReplication/CrossClusterReplicationFollowTests.cs b/tests/Tests/XPack/CrossClusterReplication/CrossClusterReplicationFollowTests.cs index 84722501f6b..4bb60dc92ba 100644 --- a/tests/Tests/XPack/CrossClusterReplication/CrossClusterReplicationFollowTests.cs +++ b/tests/Tests/XPack/CrossClusterReplication/CrossClusterReplicationFollowTests.cs @@ -54,7 +54,6 @@ public CrossClusterReplicationFollowTests(XPackCluster cluster, EndpointUsage us NumberOfReplicas = 0, SoftDeletes = new SoftDeleteSettings { - Enabled = true, Retention = new SoftDeleteRetentionSettings { Operations = 1024 } } } @@ -63,7 +62,6 @@ public CrossClusterReplicationFollowTests(XPackCluster cluster, EndpointUsage us .NumberOfShards(1) .NumberOfReplicas(0) .SoftDeletes(sd => sd - .Enabled() .Retention(r => r.Operations(1024)) ) ),