Skip to content

Commit 1f4d879

Browse files
Change setting's deprecation message wording (#120718) (#124340)
Depending on whether a message is critical or warning a message should indicate to check breaking changes documentation (critical level) or deprecation changes documentation (warn level) relates #79666
1 parent 1332412 commit 1f4d879

File tree

34 files changed

+187
-114
lines changed

34 files changed

+187
-114
lines changed

modules/repository-s3/src/test/java/org/elasticsearch/repositories/s3/RepositoryCredentialsTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,10 @@ public void testRepositoryCredentialsOverrideSecureCredentials() {
107107
assertThat(credentials.getAWSSecretKey(), is("insecure_aws_secret"));
108108

109109
assertCriticalWarnings(
110-
"[access_key] setting was deprecated in Elasticsearch and will be removed in a future release.",
111-
"[secret_key] setting was deprecated in Elasticsearch and will be removed in a future release.",
110+
"[access_key] setting was deprecated in Elasticsearch and will be removed in a future release. "
111+
+ "See the breaking changes documentation for the next major version.",
112+
"[secret_key] setting was deprecated in Elasticsearch and will be removed in a future release. "
113+
+ "See the breaking changes documentation for the next major version.",
112114
S3Repository.INSECURE_CREDENTIALS_DEPRECATION_WARNING
113115
);
114116
}
@@ -193,8 +195,10 @@ public void testReinitSecureCredentials() {
193195

194196
if (hasInsecureSettings) {
195197
assertCriticalWarnings(
196-
"[access_key] setting was deprecated in Elasticsearch and will be removed in a future release.",
197-
"[secret_key] setting was deprecated in Elasticsearch and will be removed in a future release.",
198+
"[access_key] setting was deprecated in Elasticsearch and will be removed in a future release. "
199+
+ "See the breaking changes documentation for the next major version.",
200+
"[secret_key] setting was deprecated in Elasticsearch and will be removed in a future release. "
201+
+ "See the breaking changes documentation for the next major version.",
198202
S3Repository.INSECURE_CREDENTIALS_DEPRECATION_WARNING
199203
);
200204
}

server/src/main/java/org/elasticsearch/common/settings/Setting.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.elasticsearch.core.TimeValue;
2626
import org.elasticsearch.core.Tuple;
2727
import org.elasticsearch.core.UpdateForV10;
28-
import org.elasticsearch.core.UpdateForV9;
2928
import org.elasticsearch.index.mapper.DateFieldMapper;
3029
import org.elasticsearch.xcontent.ToXContentObject;
3130
import org.elasticsearch.xcontent.XContentBuilder;
@@ -83,6 +82,11 @@
8382
* </pre>
8483
*/
8584
public class Setting<T> implements ToXContentObject {
85+
private static final String DEPRECATED_MESSAGE_TEMPLATE =
86+
"[{}] setting was deprecated in Elasticsearch and will be removed in a future release. "
87+
+ "See the %s documentation for the next major version.";
88+
private static final String DEPRECATED_WARN_MESSAGE = Strings.format(DEPRECATED_MESSAGE_TEMPLATE, "deprecation");
89+
private static final String DEPRECATED_CRITICAL_MESSAGE = Strings.format(DEPRECATED_MESSAGE_TEMPLATE, "breaking changes");
8690

8791
public enum Property {
8892
/**
@@ -651,10 +655,8 @@ void checkDeprecation(Settings settings) {
651655
if (this.isDeprecated() && this.exists(settings)) {
652656
// It would be convenient to show its replacement key, but replacement is often not so simple
653657
final String key = getKey();
654-
@UpdateForV9(owner = UpdateForV9.Owner.CORE_INFRA) // https://github.com/elastic/elasticsearch/issues/79666
655-
String message = "[{}] setting was deprecated in Elasticsearch and will be removed in a future release.";
656658
if (this.isDeprecatedWarningOnly()) {
657-
Settings.DeprecationLoggerHolder.deprecationLogger.warn(DeprecationCategory.SETTINGS, key, message, key);
659+
Settings.DeprecationLoggerHolder.deprecationLogger.warn(DeprecationCategory.SETTINGS, key, DEPRECATED_WARN_MESSAGE, key);
658660
} else if (this.isDeprecatedAndRemoved()) {
659661
Settings.DeprecationLoggerHolder.deprecationLogger.critical(
660662
DeprecationCategory.SETTINGS,
@@ -663,7 +665,12 @@ void checkDeprecation(Settings settings) {
663665
key
664666
);
665667
} else {
666-
Settings.DeprecationLoggerHolder.deprecationLogger.critical(DeprecationCategory.SETTINGS, key, message, key);
668+
Settings.DeprecationLoggerHolder.deprecationLogger.critical(
669+
DeprecationCategory.SETTINGS,
670+
key,
671+
DEPRECATED_CRITICAL_MESSAGE,
672+
key
673+
);
667674
}
668675
}
669676
}

server/src/test/java/org/elasticsearch/cluster/ClusterModuleTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ public void testRegisterShardsAllocator() {
189189
ClusterModule module = newClusterModuleWithShardsAllocator(settings, "custom", FakeShardsAllocator::new);
190190
assertEquals(FakeShardsAllocator.class, module.shardsAllocator.getClass());
191191
assertCriticalWarnings(
192-
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release."
192+
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release. "
193+
+ "See the breaking changes documentation for the next major version."
193194
);
194195
}
195196

@@ -219,15 +220,17 @@ public void testUnknownShardsAllocator() {
219220
);
220221
assertEquals("Unknown ShardsAllocator [dne]", e.getMessage());
221222
assertCriticalWarnings(
222-
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release."
223+
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release. "
224+
+ "See the breaking changes documentation for the next major version."
223225
);
224226
}
225227

226228
public void testShardsAllocatorFactoryNull() {
227229
Settings settings = Settings.builder().put(ClusterModule.SHARDS_ALLOCATOR_TYPE_SETTING.getKey(), "bad").build();
228230
expectThrows(NullPointerException.class, () -> newClusterModuleWithShardsAllocator(settings, "bad", () -> null));
229231
assertCriticalWarnings(
230-
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release."
232+
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release. "
233+
+ "See the breaking changes documentation for the next major version."
231234
);
232235
}
233236

server/src/test/java/org/elasticsearch/cluster/routing/allocation/ClusterRebalanceRoutingTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,8 @@ public void beforeAllocation(RoutingAllocation allocation) {
704704
}
705705
);
706706
assertCriticalWarnings(
707-
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release."
707+
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release. "
708+
+ "See the breaking changes documentation for the next major version."
708709
);
709710

710711
Metadata metadata = Metadata.builder()

server/src/test/java/org/elasticsearch/cluster/routing/allocation/IndexBalanceTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,8 @@ public void testRebalanceShouldNotPerformUnnecessaryMovesWithMultipleConcurrentR
449449

450450
final var allocationService = createAllocationService(settings);
451451
assertCriticalWarnings(
452-
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release."
452+
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release. "
453+
+ "See the breaking changes documentation for the next major version."
453454
);
454455

455456
assertTrue(

server/src/test/java/org/elasticsearch/cluster/routing/allocation/ThrottlingAllocationTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,8 @@ public void testThrottleIncomingAndOutgoing() {
200200
snapshotsInfoService
201201
);
202202
assertCriticalWarnings(
203-
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release."
203+
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release. "
204+
+ "See the breaking changes documentation for the next major version."
204205
);
205206
logger.info("Building initial routing table");
206207

server/src/test/java/org/elasticsearch/index/codec/PerFieldMapperCodecTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ public void testUseBloomFilterWithTimestampFieldEnabled_disableBloomFilter() thr
112112
assertThat(perFieldMapperCodec.useBloomFilter("_id"), is(false));
113113
assertThat(perFieldMapperCodec.getPostingsFormatForField("_id"), instanceOf(ES812PostingsFormat.class));
114114
assertWarnings(
115-
"[index.bloom_filter_for_id_field.enabled] setting was deprecated in Elasticsearch and will be removed in a future release."
115+
"[index.bloom_filter_for_id_field.enabled] setting was deprecated in Elasticsearch and will be removed in a future release. "
116+
+ "See the deprecation documentation for the next major version."
116117
);
117118
}
118119

server/src/test/java/org/elasticsearch/snapshots/InternalSnapshotsInfoServiceTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,8 @@ public IndexShardSnapshotStatus.Copy getShardSnapshotStatus(SnapshotId snapshotI
362362
snapshotsInfoService
363363
);
364364
assertCriticalWarnings(
365-
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release."
365+
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release. "
366+
+ "See the breaking changes documentation for the next major version."
366367
);
367368
applyClusterState(
368369
"starting shards for " + indexName,

server/src/test/java/org/elasticsearch/snapshots/SnapshotResiliencyTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2202,7 +2202,8 @@ public RecyclerBytesStreamOutput newNetworkBytesStream() {
22022202
snapshotsInfoService
22032203
);
22042204
assertCriticalWarnings(
2205-
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release."
2205+
"[cluster.routing.allocation.type] setting was deprecated in Elasticsearch and will be removed in a future release. "
2206+
+ "See the breaking changes documentation for the next major version."
22062207
);
22072208
rerouteService = new BatchedRerouteService(clusterService, allocationService::reroute);
22082209
rerouteServiceSetOnce.set(rerouteService);

server/src/test/java/org/elasticsearch/transport/TransportServiceLifecycleTests.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ public void testInternalSendExceptionForksToGenericIfHandlerDoesNotForkAndStackO
171171
assertEquals("simulated exception in sendRequest", getSendRequestException(future, IOException.class).getMessage());
172172
}
173173
assertWarnings(
174-
"[transport.enable_stack_protection] setting was deprecated in Elasticsearch and will be removed in a future release."
174+
"[transport.enable_stack_protection] setting was deprecated in Elasticsearch and will be removed in a future release. "
175+
+ "See the breaking changes documentation for the next major version."
175176
);
176177
}
177178

@@ -264,7 +265,8 @@ public void testOnConnectionClosedUsesHandlerExecutor() {
264265
onConnectionClosedUsesHandlerExecutor(settings, executorName, expectedExecutor);
265266
if (withSetting) {
266267
assertWarnings(
267-
"[transport.enable_stack_protection] setting was deprecated in Elasticsearch and will be removed in a future release."
268+
"[transport.enable_stack_protection] setting was deprecated in Elasticsearch and will be removed in a future release. "
269+
+ "See the breaking changes documentation for the next major version."
268270
);
269271
}
270272
}
@@ -276,7 +278,8 @@ public void testOnConnectionCloseStackOverflowAvoidance() {
276278
ThreadPool.Names.GENERIC
277279
);
278280
assertWarnings(
279-
"[transport.enable_stack_protection] setting was deprecated in Elasticsearch and will be removed in a future release."
281+
"[transport.enable_stack_protection] setting was deprecated in Elasticsearch and will be removed in a future release. "
282+
+ "See the breaking changes documentation for the next major version."
280283
);
281284
}
282285

0 commit comments

Comments
 (0)