Skip to content

Commit

Permalink
Deprecate index soft delete enabled setting (#4411)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
russcam authored Feb 21, 2020
1 parent bfd4221 commit d86e258
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,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);
}

Expand Down Expand Up @@ -265,7 +267,9 @@ private static void SetKnownIndexSettings(ref JsonReader reader, IJsonFormatterR
Set<bool?>(s, settings, QueriesCacheEnabled, v => queriesCache.Enabled = v, formatterResolver);

var softDeletes = s.SoftDeletes = new SoftDeleteSettings();
#pragma warning disable 618
Set<bool?>(s, settings, SoftDeletesEnabled, v => softDeletes.Enabled = v, formatterResolver);
#pragma warning restore 618
var softDeletesRetention = s.SoftDeletes.Retention = new SoftDeleteRetentionSettings();
Set<long?>(s, settings, SoftDeletesEnabled, v => softDeletesRetention.Operations = v, formatterResolver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'")]
/// <summary> Enables soft deletes on the index</summary>
bool? Enabled { get; set; }
/// <summary> Configure the retention of soft deletes on the index</summary>
Expand All @@ -15,6 +16,7 @@ public class SoftDeleteSettings : ISoftDeleteSettings
/// <inheritdoc see cref="ISoftDeleteSettings.Retention"/>
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'")]
/// <inheritdoc see cref="ISoftDeleteSettings.Enabled"/>
public bool? Enabled { get; set; }
}
Expand All @@ -28,6 +30,7 @@ public class SoftDeleteSettingsDescriptor : DescriptorBase<SoftDeleteSettingsDes
public SoftDeleteSettingsDescriptor Retention(Func<SoftDeleteRetentionSettingsDescriptor, ISoftDeleteRetentionSettings> 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'")]
/// <inheritdoc see cref="ISoftDeleteSettings.Enabled"/>
public SoftDeleteSettingsDescriptor Enabled(bool? enabled = true) => Assign(enabled, (a, v) => a.Enabled = v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public CrossClusterReplicationFollowTests(XPackCluster cluster, EndpointUsage us
NumberOfReplicas = 0,
SoftDeletes = new SoftDeleteSettings
{
Enabled = true,
Retention = new SoftDeleteRetentionSettings { Operations = 1024 }
}
}
Expand All @@ -63,7 +62,6 @@ public CrossClusterReplicationFollowTests(XPackCluster cluster, EndpointUsage us
.NumberOfShards(1)
.NumberOfReplicas(0)
.SoftDeletes(sd => sd
.Enabled()
.Retention(r => r.Operations(1024))
)
),
Expand Down

0 comments on commit d86e258

Please sign in to comment.