[7.x] Deprecation of transient cluster settings (#78794) (#79288)

This PR changes uses of transient cluster settings to
persistent cluster settings.

The PR also deprecates the transient settings usage.

Relates to #49540
This commit is contained in:
Nikola Grcevski 2021-10-15 19:06:33 -04:00 committed by GitHub
parent 4a9e95bbc0
commit 8512037aaa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
27 changed files with 225 additions and 90 deletions

View file

@ -75,9 +75,10 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
ClusterUpdateSettingsRequest setRequest = new ClusterUpdateSettingsRequest(); ClusterUpdateSettingsRequest setRequest = new ClusterUpdateSettingsRequest();
setRequest.transientSettings(transientSettings); setRequest.transientSettings(transientSettings);
setRequest.persistentSettings(map); setRequest.persistentSettings(map);
RequestOptions options = RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build();
ClusterUpdateSettingsResponse setResponse = execute(setRequest, highLevelClient().cluster()::putSettings, ClusterUpdateSettingsResponse setResponse = execute(setRequest, highLevelClient().cluster()::putSettings,
highLevelClient().cluster()::putSettingsAsync); highLevelClient().cluster()::putSettingsAsync, options);
assertAcked(setResponse); assertAcked(setResponse);
assertThat(setResponse.getTransientSettings().get(transientSettingKey), notNullValue()); assertThat(setResponse.getTransientSettings().get(transientSettingKey), notNullValue());
@ -99,7 +100,7 @@ public class ClusterClientIT extends ESRestHighLevelClientTestCase {
resetRequest.persistentSettings("{\"" + persistentSettingKey + "\": null }", XContentType.JSON); resetRequest.persistentSettings("{\"" + persistentSettingKey + "\": null }", XContentType.JSON);
ClusterUpdateSettingsResponse resetResponse = execute(resetRequest, highLevelClient().cluster()::putSettings, ClusterUpdateSettingsResponse resetResponse = execute(resetRequest, highLevelClient().cluster()::putSettings,
highLevelClient().cluster()::putSettingsAsync); highLevelClient().cluster()::putSettingsAsync, options);
assertThat(resetResponse.getTransientSettings().get(transientSettingKey), equalTo(null)); assertThat(resetResponse.getTransientSettings().get(transientSettingKey), equalTo(null));
assertThat(resetResponse.getPersistentSettings().get(persistentSettingKey), equalTo(null)); assertThat(resetResponse.getPersistentSettings().get(persistentSettingKey), equalTo(null));

View file

@ -221,8 +221,9 @@ public abstract class ESRestHighLevelClientTestCase extends ESRestTestCase {
ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest(); ClusterUpdateSettingsRequest request = new ClusterUpdateSettingsRequest();
request.persistentSettings(persistentSettings); request.persistentSettings(persistentSettings);
request.transientSettings(transientSettings); request.transientSettings(transientSettings);
RequestOptions options = RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build();
assertTrue(execute( assertTrue(execute(
request, highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync).isAcknowledged()); request, highLevelClient().cluster()::putSettings, highLevelClient().cluster()::putSettingsAsync, options).isAcknowledged());
} }
protected void putConflictPipeline() throws IOException { protected void putConflictPipeline() throws IOException {
@ -298,8 +299,9 @@ public abstract class ESRestHighLevelClientTestCase extends ESRestTestCase {
ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest(); ClusterUpdateSettingsRequest updateSettingsRequest = new ClusterUpdateSettingsRequest();
updateSettingsRequest.persistentSettings(singletonMap("cluster.remote." + remoteClusterName + ".seeds", transportAddress)); updateSettingsRequest.persistentSettings(singletonMap("cluster.remote." + remoteClusterName + ".seeds", transportAddress));
RequestOptions options = RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build();
ClusterUpdateSettingsResponse updateSettingsResponse = ClusterUpdateSettingsResponse updateSettingsResponse =
restHighLevelClient.cluster().putSettings(updateSettingsRequest, RequestOptions.DEFAULT); restHighLevelClient.cluster().putSettings(updateSettingsRequest, options);
assertThat(updateSettingsResponse.isAcknowledged(), is(true)); assertThat(updateSettingsResponse.isAcknowledged(), is(true));
assertBusy(() -> { assertBusy(() -> {

View file

@ -21,6 +21,7 @@ import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.ESRestHighLevelClientTestCase; import org.elasticsearch.client.ESRestHighLevelClientTestCase;
import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.WarningsHandler;
import org.elasticsearch.client.cluster.RemoteConnectionInfo; import org.elasticsearch.client.cluster.RemoteConnectionInfo;
import org.elasticsearch.client.cluster.RemoteInfoRequest; import org.elasticsearch.client.cluster.RemoteInfoRequest;
import org.elasticsearch.client.cluster.RemoteInfoResponse; import org.elasticsearch.client.cluster.RemoteInfoResponse;
@ -127,8 +128,9 @@ public class ClusterClientDocumentationIT extends ESRestHighLevelClientTestCase
request.masterNodeTimeout("1m"); // <2> request.masterNodeTimeout("1m"); // <2>
// end::put-settings-request-masterTimeout // end::put-settings-request-masterTimeout
RequestOptions options = RequestOptions.DEFAULT.toBuilder().setWarningsHandler(WarningsHandler.PERMISSIVE).build();
// tag::put-settings-execute // tag::put-settings-execute
ClusterUpdateSettingsResponse response = client.cluster().putSettings(request, RequestOptions.DEFAULT); ClusterUpdateSettingsResponse response = client.cluster().putSettings(request, options);
// end::put-settings-execute // end::put-settings-execute
// tag::put-settings-response // tag::put-settings-response
@ -144,7 +146,7 @@ public class ClusterClientDocumentationIT extends ESRestHighLevelClientTestCase
request.transientSettings(Settings.builder().putNull(transientSettingKey).build()); // <1> request.transientSettings(Settings.builder().putNull(transientSettingKey).build()); // <1>
// tag::put-settings-request-reset-transient // tag::put-settings-request-reset-transient
request.persistentSettings(Settings.builder().putNull(persistentSettingKey)); request.persistentSettings(Settings.builder().putNull(persistentSettingKey));
ClusterUpdateSettingsResponse resetResponse = client.cluster().putSettings(request, RequestOptions.DEFAULT); ClusterUpdateSettingsResponse resetResponse = client.cluster().putSettings(request, options);
assertTrue(resetResponse.isAcknowledged()); assertTrue(resetResponse.isAcknowledged());
} }

View file

@ -45,6 +45,8 @@ the setting is the same on all nodes. If, on the other hand, you define differen
settings on different nodes by accident using the configuration file, it is very settings on different nodes by accident using the configuration file, it is very
difficult to notice these discrepancies. difficult to notice these discrepancies.
NOTE: Transient settings are deprecated and will be removed in a future release.
Prefer using persistent cluster settings instead.
[[cluster-update-settings-api-query-params]] [[cluster-update-settings-api-query-params]]
==== {api-query-parms-title} ==== {api-query-parms-title}
@ -85,7 +87,7 @@ PUT /_cluster/settings?flat_settings=true
} }
} }
-------------------------------------------------- --------------------------------------------------
// TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]
The response to an update returns the changed setting, as in this response to The response to an update returns the changed setting, as in this response to
the transient example: the transient example:
@ -114,6 +116,7 @@ PUT /_cluster/settings
} }
} }
-------------------------------------------------- --------------------------------------------------
// TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]
The response does not include settings that have been reset: The response does not include settings that have been reset:
@ -141,3 +144,4 @@ PUT /_cluster/settings
} }
} }
-------------------------------------------------- --------------------------------------------------
// TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]

View file

@ -521,7 +521,7 @@ lowers the `indices.lifecycle.poll_interval` setting to `1m` (one minute).
---- ----
PUT /_cluster/settings PUT /_cluster/settings
{ {
"transient": { "persistent": {
"indices.lifecycle.poll_interval": "1m" "indices.lifecycle.poll_interval": "1m"
} }
} }
@ -657,7 +657,7 @@ The following update cluster settings API request resets the
---- ----
PUT /_cluster/settings PUT /_cluster/settings
{ {
"transient": { "persistent": {
"indices.lifecycle.poll_interval": null "indices.lifecycle.poll_interval": null
} }
} }

View file

@ -49,7 +49,7 @@ watermarks and remove the write block.
---- ----
PUT _cluster/settings PUT _cluster/settings
{ {
"transient": { "persistent": {
"cluster.routing.allocation.disk.watermark.low": "90%", "cluster.routing.allocation.disk.watermark.low": "90%",
"cluster.routing.allocation.disk.watermark.high": "95%", "cluster.routing.allocation.disk.watermark.high": "95%",
"cluster.routing.allocation.disk.watermark.flood_stage": "97%" "cluster.routing.allocation.disk.watermark.flood_stage": "97%"
@ -80,7 +80,7 @@ When a long-term solution is in place, reset or reconfigure the disk watermarks.
---- ----
PUT _cluster/settings PUT _cluster/settings
{ {
"transient": { "persistent": {
"cluster.routing.allocation.disk.watermark.low": null, "cluster.routing.allocation.disk.watermark.low": null,
"cluster.routing.allocation.disk.watermark.high": null, "cluster.routing.allocation.disk.watermark.high": null,
"cluster.routing.allocation.disk.watermark.flood_stage": null "cluster.routing.allocation.disk.watermark.flood_stage": null

View file

@ -329,7 +329,7 @@ cluster settings API>> and retry the action.
---- ----
PUT _cluster/settings PUT _cluster/settings
{ {
"transient" : { "persistent" : {
"cluster.max_shards_per_node": 1200 "cluster.max_shards_per_node": 1200
} }
} }
@ -353,7 +353,7 @@ When a long-term solution is in place, we recommend you reset the
---- ----
PUT _cluster/settings PUT _cluster/settings
{ {
"transient" : { "persistent" : {
"cluster.max_shards_per_node": null "cluster.max_shards_per_node": null
} }
} }

View file

@ -75,7 +75,7 @@ By default, {ilm-init} checks to see what actions need to be taken every 10 minu
----------------------- -----------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient": { "persistent": {
"indices.lifecycle.poll_interval": "1m" <1> "indices.lifecycle.poll_interval": "1m" <1>
} }
} }
@ -186,7 +186,7 @@ prevent unnecessary load on the master node:
----------------------- -----------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient": { "persistent": {
"indices.lifecycle.poll_interval": null "indices.lifecycle.poll_interval": null
} }
} }

View file

@ -331,7 +331,7 @@ server log.
-------------------------------------------------- --------------------------------------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient": { "persistent": {
"logger.org.elasticsearch.ingest.common.GrokProcessor": "debug" "logger.org.elasticsearch.ingest.common.GrokProcessor": "debug"
} }
} }

View file

@ -74,6 +74,7 @@ PUT /_cluster/settings
} }
} }
-------------------------------------------------- --------------------------------------------------
// TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]
[discrete] [discrete]

View file

@ -188,6 +188,7 @@ PUT _cluster/settings
} }
} }
-------------------------------------------------- --------------------------------------------------
// TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]
+ +
You can use the {ref}/cat-allocation.html[cat allocation API] to track progress You can use the {ref}/cat-allocation.html[cat allocation API] to track progress
of this data migration. If some shards do not migrate then the of this data migration. If some shards do not migrate then the
@ -212,6 +213,7 @@ PUT _cluster/settings
} }
} }
-------------------------------------------------- --------------------------------------------------
// TEST[warning:[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.]
6. Discard the data held by the stopped node by deleting the contents of its 6. Discard the data held by the stopped node by deleting the contents of its
data paths. data paths.

View file

@ -22,7 +22,7 @@ it down, you could create a filter that excludes the node by its IP address:
-------------------------------------------------- --------------------------------------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient" : { "persistent" : {
"cluster.routing.allocation.exclude._ip" : "10.0.0.1" "cluster.routing.allocation.exclude._ip" : "10.0.0.1"
} }
} }
@ -70,7 +70,7 @@ You can use wildcards when specifying attribute values, for example:
------------------------ ------------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient": { "persistent": {
"cluster.routing.allocation.exclude._ip": "192.168.2.*" "cluster.routing.allocation.exclude._ip": "192.168.2.*"
} }
} }

View file

@ -157,7 +157,7 @@ gigabytes free, and updating the information about the cluster every minute:
-------------------------------------------------- --------------------------------------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient": { "persistent": {
"cluster.routing.allocation.disk.watermark.low": "100gb", "cluster.routing.allocation.disk.watermark.low": "100gb",
"cluster.routing.allocation.disk.watermark.high": "50gb", "cluster.routing.allocation.disk.watermark.high": "50gb",
"cluster.routing.allocation.disk.watermark.flood_stage": "10gb", "cluster.routing.allocation.disk.watermark.flood_stage": "10gb",

View file

@ -159,7 +159,7 @@ The settings which control logging can be updated <<dynamic-cluster-setting,dyna
------------------------------- -------------------------------
PUT /_cluster/settings PUT /_cluster/settings
{ {
"transient": { "persistent": {
"logger.org.elasticsearch.indices.recovery": "DEBUG" "logger.org.elasticsearch.indices.recovery": "DEBUG"
} }
} }

View file

@ -16,7 +16,7 @@ the `org.elasticsearch.http.HttpTracer` logger to `TRACE`:
-------------------------------------------------- --------------------------------------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient" : { "persistent" : {
"logger.org.elasticsearch.http.HttpTracer" : "TRACE" "logger.org.elasticsearch.http.HttpTracer" : "TRACE"
} }
} }
@ -29,7 +29,7 @@ exclude wildcard patterns. By default every request will be traced.
-------------------------------------------------- --------------------------------------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient" : { "persistent" : {
"http.tracer.include" : "*", "http.tracer.include" : "*",
"http.tracer.exclude" : "" "http.tracer.exclude" : ""
} }
@ -47,7 +47,7 @@ requests and responses. Activate the tracer by setting the level of the
-------------------------------------------------- --------------------------------------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient" : { "persistent" : {
"logger.org.elasticsearch.transport.TransportService.tracer" : "TRACE" "logger.org.elasticsearch.transport.TransportService.tracer" : "TRACE"
} }
} }
@ -61,7 +61,7 @@ fault detection pings:
-------------------------------------------------- --------------------------------------------------
PUT _cluster/settings PUT _cluster/settings
{ {
"transient" : { "persistent" : {
"transport.tracer.include" : "*", "transport.tracer.include" : "*",
"transport.tracer.exclude" : "internal:coordination/fault_detection/*" "transport.tracer.exclude" : "internal:coordination/fault_detection/*"
} }

View file

@ -140,6 +140,9 @@ settings API and use `elasticsearch.yml` only for local configurations. Using
the cluster update settings API ensures the setting is the same on all nodes. If the cluster update settings API ensures the setting is the same on all nodes. If
you accidentally configure different settings in `elasticsearch.yml` on you accidentally configure different settings in `elasticsearch.yml` on
different nodes, it can be difficult to notice discrepancies. different nodes, it can be difficult to notice discrepancies.
NOTE: Transient settings are deprecated and will be removed in a future release.
Prefer using persistent cluster settings instead.
-- --
[[static-cluster-setting]] [[static-cluster-setting]]

View file

@ -155,7 +155,7 @@ only intended for expert use.
---- ----
PUT /_cluster/settings PUT /_cluster/settings
{ {
"transient": { "persistent": {
"logger.org.elasticsearch.discovery": "DEBUG" "logger.org.elasticsearch.discovery": "DEBUG"
} }
} }

View file

@ -1,6 +1,13 @@
--- ---
"Test put and reset transient settings": "Test put and reset transient settings":
- skip:
version: " - 7.15.99"
reason: "transient settings deprecation"
features: "warnings"
- do: - do:
warnings:
- "[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead."
cluster.put_settings: cluster.put_settings:
body: body:
transient: transient:
@ -16,6 +23,8 @@
- match: {transient: {cluster.routing.allocation.enable: "none"}} - match: {transient: {cluster.routing.allocation.enable: "none"}}
- do: - do:
warnings:
- "[transient settings removal] Updating cluster settings through transientSettings is deprecated. Use persistent settings instead."
cluster.put_settings: cluster.put_settings:
body: body:
transient: transient:

View file

@ -64,6 +64,11 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
return validationException; return validationException;
} }
/**
* @deprecated Transient settings are in the process of being removed. Use
* persistent settings to update your cluster settings instead.
*/
@Deprecated
public Settings transientSettings() { public Settings transientSettings() {
return transientSettings; return transientSettings;
} }
@ -74,7 +79,11 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
/** /**
* Sets the transient settings to be updated. They will not survive a full cluster restart * Sets the transient settings to be updated. They will not survive a full cluster restart
*
* @deprecated Transient settings are in the process of being removed. Use
* persistent settings to update your cluster settings instead.
*/ */
@Deprecated
public ClusterUpdateSettingsRequest transientSettings(Settings settings) { public ClusterUpdateSettingsRequest transientSettings(Settings settings) {
this.transientSettings = settings; this.transientSettings = settings;
return this; return this;
@ -82,7 +91,11 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
/** /**
* Sets the transient settings to be updated. They will not survive a full cluster restart * Sets the transient settings to be updated. They will not survive a full cluster restart
*
* @deprecated Transient settings are in the process of being removed. Use
* persistent settings to update your cluster settings instead.
*/ */
@Deprecated
public ClusterUpdateSettingsRequest transientSettings(Settings.Builder settings) { public ClusterUpdateSettingsRequest transientSettings(Settings.Builder settings) {
this.transientSettings = settings.build(); this.transientSettings = settings.build();
return this; return this;
@ -90,7 +103,11 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
/** /**
* Sets the source containing the transient settings to be updated. They will not survive a full cluster restart * Sets the source containing the transient settings to be updated. They will not survive a full cluster restart
*
* @deprecated Transient settings are in the process of being removed. Use
* persistent settings to update your cluster settings instead.
*/ */
@Deprecated
public ClusterUpdateSettingsRequest transientSettings(String source, XContentType xContentType) { public ClusterUpdateSettingsRequest transientSettings(String source, XContentType xContentType) {
this.transientSettings = Settings.builder().loadFromSource(source, xContentType).build(); this.transientSettings = Settings.builder().loadFromSource(source, xContentType).build();
return this; return this;
@ -98,7 +115,11 @@ public class ClusterUpdateSettingsRequest extends AcknowledgedRequest<ClusterUpd
/** /**
* Sets the transient settings to be updated. They will not survive a full cluster restart * Sets the transient settings to be updated. They will not survive a full cluster restart
*
* @deprecated Transient settings are in the process of being removed. Use
* persistent settings to update your cluster settings instead.
*/ */
@Deprecated
public ClusterUpdateSettingsRequest transientSettings(Map<String, ?> source) { public ClusterUpdateSettingsRequest transientSettings(Map<String, ?> source) {
this.transientSettings = Settings.builder().loadFromMap(source).build(); this.transientSettings = Settings.builder().loadFromMap(source).build();
return this; return this;

View file

@ -11,6 +11,8 @@ package org.elasticsearch.rest.action.admin.cluster;
import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest; import org.elasticsearch.action.admin.cluster.settings.ClusterUpdateSettingsRequest;
import org.elasticsearch.client.Requests; import org.elasticsearch.client.Requests;
import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.xcontent.XContentParser; import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.rest.BaseRestHandler; import org.elasticsearch.rest.BaseRestHandler;
@ -26,6 +28,9 @@ import static java.util.Collections.singletonList;
import static org.elasticsearch.rest.RestRequest.Method.PUT; import static org.elasticsearch.rest.RestRequest.Method.PUT;
public class RestClusterUpdateSettingsAction extends BaseRestHandler { public class RestClusterUpdateSettingsAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestClusterUpdateSettingsAction.class);
static final String TRANSIENT_SETTINGS_DEPRECATION_MESSAGE = "[transient settings removal]" +
" Updating cluster settings through transientSettings is deprecated. Use persistent settings instead.";
private static final String PERSISTENT = "persistent"; private static final String PERSISTENT = "persistent";
private static final String TRANSIENT = "transient"; private static final String TRANSIENT = "transient";
@ -52,7 +57,15 @@ public class RestClusterUpdateSettingsAction extends BaseRestHandler {
source = parser.map(); source = parser.map();
} }
if (source.containsKey(TRANSIENT)) { if (source.containsKey(TRANSIENT)) {
clusterUpdateSettingsRequest.transientSettings((Map<String, ?>) source.get(TRANSIENT)); Map<String, ?> transientSettings = (Map<String, ?>) source.get(TRANSIENT);
// We check for empty transient settings map because ClusterUpdateSettingsRequest initializes
// each of the settings to an empty collection. When the RestClient is used, we'll get an empty
// transient settings map, even if we never set any transient settings.
if (transientSettings.isEmpty() == false) {
deprecationLogger.warn(DeprecationCategory.SETTINGS, "transient_settings", TRANSIENT_SETTINGS_DEPRECATION_MESSAGE);
}
clusterUpdateSettingsRequest.transientSettings(transientSettings);
} }
if (source.containsKey(PERSISTENT)) { if (source.containsKey(PERSISTENT)) {
clusterUpdateSettingsRequest.persistentSettings((Map<String, ?>) source.get(PERSISTENT)); clusterUpdateSettingsRequest.persistentSettings((Map<String, ?>) source.get(PERSISTENT));

View file

@ -189,8 +189,8 @@ public class ShardPathTests extends ESTestCase {
public void testShardPathSelection() throws IOException { public void testShardPathSelection() throws IOException {
try (NodeEnvironment env = newNodeEnvironment(Settings.builder().build())) { try (NodeEnvironment env = newNodeEnvironment(Settings.builder().build())) {
NodeEnvironment.NodePath path = env.nodePaths()[0]; NodeEnvironment.NodePath[] paths = env.nodePaths();
assertEquals(path, ShardPath.getPathWithMostFreeSpace(env)); assertThat(org.elasticsearch.core.List.of(paths), hasItem(ShardPath.getPathWithMostFreeSpace(env)));
ShardId shardId = new ShardId("foo", "0xDEADBEEF", 0); ShardId shardId = new ShardId("foo", "0xDEADBEEF", 0);
Settings indexSettings = Settings.builder() Settings indexSettings = Settings.builder()
@ -199,7 +199,13 @@ public class ShardPathTests extends ESTestCase {
ShardPath shardPath = ShardPath.selectNewPathForShard(env, shardId, idxSettings, 1L, new HashMap<>()); ShardPath shardPath = ShardPath.selectNewPathForShard(env, shardId, idxSettings, 1L, new HashMap<>());
assertNotNull(shardPath.getDataPath()); assertNotNull(shardPath.getDataPath());
assertEquals(path.indicesPath.resolve("0xDEADBEEF").resolve("0"), shardPath.getDataPath());
List<Path> indexPaths = new ArrayList<>();
for (NodeEnvironment.NodePath nodePath : paths) {
indexPaths.add(nodePath.indicesPath.resolve("0xDEADBEEF").resolve("0"));
}
assertThat(indexPaths, hasItem(shardPath.getDataPath()));
assertEquals("0xDEADBEEF", shardPath.getShardId().getIndex().getUUID()); assertEquals("0xDEADBEEF", shardPath.getShardId().getIndex().getUUID());
assertEquals("foo", shardPath.getShardId().getIndexName()); assertEquals("foo", shardPath.getShardId().getIndexName());
assertFalse(shardPath.isCustomDataPath()); assertFalse(shardPath.isCustomDataPath());

View file

@ -920,6 +920,17 @@ public abstract class ESRestTestCase extends ESTestCase {
if (mustClear) { if (mustClear) {
Request request = new Request("PUT", "/_cluster/settings"); Request request = new Request("PUT", "/_cluster/settings");
request.setOptions(RequestOptions.DEFAULT.toBuilder().setWarningsHandler(warnings -> {
if (warnings.isEmpty()) {
return false;
} else if (warnings.size() > 1) {
return true;
} else {
return warnings.get(0).startsWith("[transient settings removal]") == false;
}
}));
request.setJsonEntity(Strings.toString(clearCommand)); request.setJsonEntity(Strings.toString(clearCommand));
adminClient().performRequest(request); adminClient().performRequest(request);
} }

View file

@ -684,13 +684,13 @@ the `basic` `authProvider` in {kib}. The process is documented in the
If the previous resolutions do not solve your issue, enable additional If the previous resolutions do not solve your issue, enable additional
logging for the SAML realm to troubleshoot further. You can enable debug logging for the SAML realm to troubleshoot further. You can enable debug
logging by configuring the following transient setting: logging by configuring the following persistent setting:
[source, console] [source, console]
---- ----
PUT /_cluster/settings PUT /_cluster/settings
{ {
"transient": { "persistent": {
"logger.org.elasticsearch.xpack.security.authc.saml": "debug" "logger.org.elasticsearch.xpack.security.authc.saml": "debug"
} }
} }

View file

@ -361,7 +361,7 @@ public class DeprecationHttpIT extends ESRestTestCase {
List<Map<String, Object>> documents = getIndexedDeprecations(); List<Map<String, Object>> documents = getIndexedDeprecations();
logger.warn(documents); logger.warn(documents);
assertThat(documents, hasSize(2)); assertThat(documents, hasSize(3));
assertThat( assertThat(
documents, documents,
@ -373,6 +373,14 @@ public class DeprecationHttpIT extends ESRestTestCase {
allOf( allOf(
hasEntry("event.code", "deprecated_settings"), hasEntry("event.code", "deprecated_settings"),
hasEntry("message", "[deprecated_settings] usage is deprecated. use [settings] instead") hasEntry("message", "[deprecated_settings] usage is deprecated. use [settings] instead")
),
allOf(
hasEntry("event.code", "transient_settings"),
hasEntry(
"message",
"[transient settings removal] Updating cluster settings through transientSettings"
+ " is deprecated. Use persistent settings instead."
)
) )
) )
); );

View file

@ -413,4 +413,16 @@ public class ClusterDeprecationChecks {
} }
return null; return null;
} }
static DeprecationIssue checkTransientSettingsExistence(ClusterState state) {
if (state.metadata().transientSettings().isEmpty() == false) {
return new DeprecationIssue(DeprecationIssue.Level.WARNING,
"Transient cluster settings are in the process of being removed.",
"https://ela.st/es-deprecation-7-transient-cluster-settings",
"Use persistent settings to define your cluster settings instead.",
false,
null);
}
return null;
}
} }

View file

@ -53,7 +53,8 @@ public class DeprecationChecks {
ClusterDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting, ClusterDeprecationChecks::checkClusterRoutingAllocationIncludeRelocationsSetting,
ClusterDeprecationChecks::checkGeoShapeTemplates, ClusterDeprecationChecks::checkGeoShapeTemplates,
ClusterDeprecationChecks::checkSparseVectorTemplates, ClusterDeprecationChecks::checkSparseVectorTemplates,
ClusterDeprecationChecks::checkILMFreezeActions ClusterDeprecationChecks::checkILMFreezeActions,
ClusterDeprecationChecks::checkTransientSettingsExistence
)); ));
static final List<NodeDeprecationCheck<Settings, PluginsAndModules, ClusterState, XPackLicenseState, DeprecationIssue>> static final List<NodeDeprecationCheck<Settings, PluginsAndModules, ClusterState, XPackLicenseState, DeprecationIssue>>

View file

@ -48,6 +48,7 @@ import static org.elasticsearch.xpack.core.ilm.LifecycleSettings.LIFECYCLE_POLL_
import static org.elasticsearch.xpack.deprecation.DeprecationChecks.CLUSTER_SETTINGS_CHECKS; import static org.elasticsearch.xpack.deprecation.DeprecationChecks.CLUSTER_SETTINGS_CHECKS;
import static org.elasticsearch.xpack.deprecation.IndexDeprecationChecksTests.addRandomFields; import static org.elasticsearch.xpack.deprecation.IndexDeprecationChecksTests.addRandomFields;
import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasSize;
public class ClusterDeprecationChecksTests extends ESTestCase { public class ClusterDeprecationChecksTests extends ESTestCase {
@ -355,9 +356,17 @@ public class ClusterDeprecationChecksTests extends ESTestCase {
null null
); );
final DeprecationIssue otherExpectedIssue = new DeprecationIssue(DeprecationIssue.Level.WARNING,
"Transient cluster settings are in the process of being removed.",
"https://ela.st/es-deprecation-7-transient-cluster-settings",
"Use persistent settings to define your cluster settings instead.",
false, null);
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(CLUSTER_SETTINGS_CHECKS, c -> c.apply(clusterState)); List<DeprecationIssue> issues = DeprecationChecks.filterChecks(CLUSTER_SETTINGS_CHECKS, c -> c.apply(clusterState));
assertThat(issues, hasSize(1));
assertThat(issues.get(0), equalTo(expectedIssue)); assertThat(issues, hasSize(2));
assertThat(issues, hasItem(expectedIssue));
assertThat(issues, hasItem(otherExpectedIssue));
final String expectedWarning = String.format(Locale.ROOT, final String expectedWarning = String.format(Locale.ROOT,
"[%s] setting was deprecated in Elasticsearch and will be removed in a future release! " + "[%s] setting was deprecated in Elasticsearch and will be removed in a future release! " +
@ -553,4 +562,34 @@ public class ClusterDeprecationChecksTests extends ESTestCase {
"remove freeze action from the following ilm policies: [policy1,policy2]", false, null) "remove freeze action from the following ilm policies: [policy1,policy2]", false, null)
)); ));
} }
public void testCheckTransientSettingsExistence() {
Settings transientSettings = Settings.builder()
.put("indices.recovery.max_bytes_per_sec", "20mb")
.build();
Metadata metadataWithTransientSettings = Metadata.builder()
.transientSettings(transientSettings)
.build();
ClusterState badState = ClusterState.builder(new ClusterName("test")).metadata(metadataWithTransientSettings).build();
DeprecationIssue issue = ClusterDeprecationChecks.checkTransientSettingsExistence(badState);
assertThat(issue, equalTo(
new DeprecationIssue(DeprecationIssue.Level.WARNING,
"Transient cluster settings are in the process of being removed.",
"https://ela.st/es-deprecation-7-transient-cluster-settings",
"Use persistent settings to define your cluster settings instead.",
false, null)
));
Settings persistentSettings = Settings.builder()
.put("indices.recovery.max_bytes_per_sec", "20mb")
.build();
Metadata metadataWithoutTransientSettings = Metadata.builder()
.persistentSettings(persistentSettings)
.build();
ClusterState okState = ClusterState.builder(new ClusterName("test")).metadata(metadataWithoutTransientSettings).build();
issue = ClusterDeprecationChecks.checkTransientSettingsExistence(okState);
assertNull(issue);
}
} }