Skip to content

Change default value of action.destructive_requires_name to True. #66908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d12d008
Changed default setting
YashJipkate Jan 2, 2021
714bb7f
Make changes in the codebase accordingly
YashJipkate Jan 5, 2021
9e7b911
Restore deleted section
YashJipkate Jan 8, 2021
e604fb6
Rephrase to reflect default behaviour
YashJipkate Jan 8, 2021
8c7204b
Set action.destructive_requires_name to false
YashJipkate Jan 8, 2021
ccaec94
Restore missing line
YashJipkate Jan 8, 2021
875998b
Rephrase some more sections
YashJipkate Jan 8, 2021
07a200b
Update docs/reference/indices/close.asciidoc
YashJipkate Jan 11, 2021
70bf4f9
Apply suggestions from code review
YashJipkate Jan 11, 2021
311248d
Add REQUIRES_NAME_SETTING setting in ESSingleNodeTestCase
YashJipkate Jan 11, 2021
40666fd
Merge branch 'set-default-destructive' of https://github.com/YashJipk…
YashJipkate Jan 11, 2021
129dabb
Merge branch 'master' into set-default-destructive
elasticmachine Jan 12, 2021
ac7227e
Try fixing tests
YashJipkate Jan 13, 2021
2d9054f
Update restClientSettings
YashJipkate Jan 13, 2021
caf78ae
Update super restClientSettings
YashJipkate Jan 13, 2021
09b0e61
Revert updates in restClientSettings
YashJipkate Jan 13, 2021
b212bcb
Try fixing tests
YashJipkate Jan 13, 2021
5de3c6b
Merge branch 'master' of https://github.com/elastic/elasticsearch int…
YashJipkate Jan 13, 2021
3221cd1
Merge branch 'master' into set-default-destructive
williamrandolph Jan 28, 2021
05cd436
Merge branch 'master' into set-default-destructive
elasticmachine Jan 28, 2021
7eb6f8a
Merge branch 'master' into set-default-destructive
williamrandolph Mar 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,8 @@ private void createConfiguration() {
baseConfig.put("cluster.service.slow_master_task_logging_threshold", "5s");
}

baseConfig.put("action.destructive_requires_name", "false");

HashSet<String> overriden = new HashSet<>(baseConfig.keySet());
overriden.retainAll(settings.keySet());
overriden.removeAll(OVERRIDABLE_SETTINGS);
Expand Down
2 changes: 2 additions & 0 deletions distribution/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
- xpack.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=trial
- action.destructive_requires_name=false
volumes:
- ./build/repo:/tmp/es-repo
- ./build/certs/testnode.pem:/usr/share/elasticsearch/config/testnode.pem
Expand Down Expand Up @@ -81,6 +82,7 @@ services:
- xpack.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=trial
- action.destructive_requires_name=false
volumes:
- ./build/repo:/tmp/es-repo
- ./build/certs/testnode.pem:/usr/share/elasticsearch/config/testnode.pem
Expand Down
4 changes: 2 additions & 2 deletions distribution/src/config/elasticsearch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ ${path.logs}
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
# Allow wildcard deletion of indices:
#
#action.destructive_requires_name: true
#action.destructive_requires_name: false
6 changes: 3 additions & 3 deletions docs/reference/index-modules/blocks.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ PUT /my-index-000001/_block/write

include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
+
To add blocks to all indices, use `_all` or `*`. To disallow the adding
of blocks to indices with `_all` or wildcard expressions,
change the `action.destructive_requires_name` cluster setting to `true`.
By default, you must explicitly name the indices you are adding blocks to.
To allow the adding of blocks to indices with `_all`, `*``, or other wildcard
expressions, change the `action.destructive_requires_name` setting to `false`.
You can update this setting in the `elasticsearch.yml` file
or using the <<cluster-update-settings,cluster update settings>> API.
`<block>`::
Expand Down
5 changes: 3 additions & 2 deletions docs/reference/indices/close.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ include::{es-repo-dir}/indices/open-close.asciidoc[tag=closed-index]
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
+
To close all indices, use `_all` or `*`.
To disallow the closing of indices with `_all` or wildcard expressions,
change the `action.destructive_requires_name` cluster setting to `true`.
By default, you must explicitly name the indices you are closing.
To specify indices to close with `_all`, `*``, or other wildcard
expressions, change the `action.destructive_requires_name` setting to `false`.
You can update this setting in the `elasticsearch.yml` file
or using the <<cluster-update-settings,cluster update settings>> API.

Expand Down
8 changes: 4 additions & 4 deletions docs/reference/indices/delete-index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ delete.
In this parameter, wildcard expressions match only open, concrete indices. You
cannot delete an index using an <<indices-aliases,alias>>.

To delete all indices, use `_all` or `*` . To disallow the deletion of indices
with `_all` or wildcard expressions, change the
`action.destructive_requires_name` cluster setting to `true`. You can update
this setting in the `elasticsearch.yml` file or using the
By default, you must explicitly name the indices you are deleting.
To specify indices to delete with `_all`, `*``, or other wildcard
expressions, change the `action.destructive_requires_name` setting to `false`.
You can update this setting in the `elasticsearch.yml` file or using the
<<cluster-update-settings,cluster update settings>> API.

NOTE: You cannot delete the current write index of a data stream. To delete the
Expand Down
13 changes: 6 additions & 7 deletions docs/reference/indices/open-close.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,10 @@ You can open and close multiple indices. An error is thrown
if the request explicitly refers to a missing index. This behaviour can be
disabled using the `ignore_unavailable=true` parameter.

All indices can be opened or closed at once using `_all` as the index name
or specifying patterns that identify them all (e.g. `*`).

Identifying indices via wildcards or `_all` can be disabled by setting the
`action.destructive_requires_name` flag in the config file to `true`.
By default, you must explicitly name the indices you are opening or closing.
To open or close indices with `_all`, `*``, or other wildcard
expressions, change the `action.destructive_requires_name` setting to `false`.
This setting can also be changed via the cluster update settings api.

Closed indices consume a significant amount of disk-space which can cause
Expand Down Expand Up @@ -93,10 +92,10 @@ index creation applies to the `_open` and `_close` index actions as well.
Comma-separated list of data streams, indices, and index aliases used to limit
the request. Wildcard (`*`) expressions are supported.
+
To target all data streams and indices, use `_all` or `*`.
+
To disallow use of `_all` or wildcard expressions,
change the `action.destructive_requires_name` cluster setting to `true`.
By default, you must explicitly name the indices you using to limit the request.
To limit a request using `_all`, `*``, or other wildcard
expressions, change the `action.destructive_requires_name` setting to `false`.
You can update this setting in the `elasticsearch.yml` file
or using the <<cluster-update-settings,cluster update settings>> API.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public static void runElasticsearchTests() throws Exception {
String count = makeRequest(Request.Get("http://localhost:9200/_count?pretty"));
assertThat(count, containsString("\"count\" : 2"));

makeRequest(Request.Delete("http://localhost:9200/_all"));
makeRequest(Request.Delete("http://localhost:9200/library"));
}

public static String makeRequest(Request request) throws Exception {
Expand Down
2 changes: 2 additions & 0 deletions qa/remote-clusters/docker-compose-oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
- cluster.routing.allocation.disk.watermark.high=1b
- cluster.routing.allocation.disk.watermark.flood_stage=1b
- node.store.allow_mmap=false
- action.destructive_requires_name=false
volumes:
- ./build/oss-repo:/tmp/es-repo
- ./build/logs/oss-1:/usr/share/elasticsearch/logs
Expand Down Expand Up @@ -50,6 +51,7 @@ services:
- cluster.routing.allocation.disk.watermark.high=1b
- cluster.routing.allocation.disk.watermark.flood_stage=1b
- node.store.allow_mmap=false
- action.destructive_requires_name=false
volumes:
- ./build/oss-repo:/tmp/es-repo
- ./build/logs/oss-2:/usr/share/elasticsearch/logs
Expand Down
2 changes: 2 additions & 0 deletions qa/remote-clusters/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ services:
- xpack.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=trial
- action.destructive_requires_name=false
volumes:
- ./build/repo:/tmp/es-repo
- ./build/certs/testnode.pem:/usr/share/elasticsearch/config/testnode.pem
Expand Down Expand Up @@ -82,6 +83,7 @@ services:
- xpack.http.ssl.verification_mode=certificate
- xpack.security.transport.ssl.verification_mode=certificate
- xpack.license.self_generated.type=trial
- action.destructive_requires_name=false
volumes:
- ./build/repo:/tmp/es-repo
- ./build/certs/testnode.pem:/usr/share/elasticsearch/config/testnode.pem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public final class DestructiveOperations {
* Setting which controls whether wildcard usage (*, prefix*, _all) is allowed.
*/
public static final Setting<Boolean> REQUIRES_NAME_SETTING =
Setting.boolSetting("action.destructive_requires_name", false, Property.Dynamic, Property.NodeScope);
Setting.boolSetting("action.destructive_requires_name", true, Property.Dynamic, Property.NodeScope);

/**
* The "match none" pattern, "*,-*", will never actually be destructive
* because it operates on no indices. If plugins or other components add
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import org.elasticsearch.action.search.ClearScrollResponse;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.DefaultShardOperationFailedException;
import org.elasticsearch.action.support.DestructiveOperations;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.AdminClient;
import org.elasticsearch.client.Client;
Expand Down Expand Up @@ -1734,6 +1735,7 @@ private int getNumClientNodes() {
*/
protected Settings nodeSettings(int nodeOrdinal) {
Settings.Builder builder = Settings.builder()
.put(DestructiveOperations.REQUIRES_NAME_SETTING.getKey(), false)
// Default the watermarks to absurdly low to prevent the tests
// from failing on nodes without enough disk space
.put(DiskThresholdSettings.CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING.getKey(), "1b")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
import org.elasticsearch.action.support.DestructiveOperations;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.Requests;
Expand Down Expand Up @@ -188,6 +189,7 @@ private Node newNode() {

Settings settings = Settings.builder()
.put(ClusterName.CLUSTER_NAME_SETTING.getKey(), InternalTestCluster.clusterName("single-node-cluster", random().nextLong()))
.put(DestructiveOperations.REQUIRES_NAME_SETTING.getKey(), false)
.put(Environment.PATH_HOME_SETTING.getKey(), tempDir)
.put(Environment.PATH_REPO_SETTING.getKey(), tempDir.resolve("repo"))
// TODO: use a consistent data path for custom paths
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.elasticsearch.action.admin.cluster.node.stats.NodeStats;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags;
import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags.Flag;
import org.elasticsearch.action.support.DestructiveOperations;
import org.elasticsearch.action.support.replication.TransportReplicationAction;
import org.elasticsearch.client.Client;
import org.elasticsearch.cluster.ClusterName;
Expand Down Expand Up @@ -387,6 +388,7 @@ public InternalTestCluster(
// TODO: currently we only randomize "cluster.no_master_block" between "write" and "metadata_write", as "all" is fragile
// and fails shards when a master abdicates, which breaks many tests.
builder.put(NoMasterBlockService.NO_MASTER_BLOCK_SETTING.getKey(), randomFrom(random,"write", "metadata_write"));
builder.put(DestructiveOperations.REQUIRES_NAME_SETTING.getKey(), false);
defaultSettings = builder.build();
executor = EsExecutors.newScaling("internal_test_cluster_executor", 0, Integer.MAX_VALUE, 0, TimeUnit.SECONDS,
EsExecutors.daemonThreadFactory("test_" + clusterName), new ThreadContext(Settings.EMPTY));
Expand Down