Skip to content
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

All system indices are hidden indices #79512

Merged
merged 64 commits into from
Dec 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8920c6c
Force system indices to be hidden in IndexMetadata
williamrandolph Oct 19, 2021
4c1925d
Hide system data streams
williamrandolph Oct 19, 2021
90790f8
Fix some tests
williamrandolph Oct 19, 2021
21a4958
Merge branch 'master' into si/hide-them-all
williamrandolph Oct 19, 2021
9813241
Merge branch 'master' into si/hide-them-all
williamrandolph Oct 20, 2021
63ebe5d
Merge branch 'master' into si/hide-them-all
williamrandolph Oct 20, 2021
e7c100b
Update feature migration tests
williamrandolph Oct 20, 2021
9909b95
Roll back unintended change
williamrandolph Oct 20, 2021
f193d83
ML datafeed config defaults to searching hidden indices
williamrandolph Oct 21, 2021
d376412
Merge branch 'master' into si/hide-them-all
williamrandolph Oct 21, 2021
00de706
Prevent unmanaged system indices from becoming visible
williamrandolph Oct 21, 2021
b4a3ab9
Fix watcher test
williamrandolph Oct 21, 2021
7758928
checkstyle
williamrandolph Oct 22, 2021
f00c70e
Use expectThrows instead of try/catch
williamrandolph Oct 22, 2021
a09d572
Change validation in TransportUpdateSettingsAction
williamrandolph Oct 22, 2021
1c99c35
Remove change to data stream index abstraction
williamrandolph Oct 22, 2021
e0c85b2
Back out bad assertion in IndexMetadata
williamrandolph Oct 22, 2021
a47f12f
Remove validation from service in favor of transport action
williamrandolph Oct 22, 2021
a978c38
Fix logic in tests
williamrandolph Oct 22, 2021
be652fa
Validate index creation settings in transport action
williamrandolph Oct 22, 2021
e2432d3
Remove metadata create index service validation
williamrandolph Oct 22, 2021
dd9ea2f
Fix cluster info service test
williamrandolph Oct 22, 2021
5489fa5
Formatting and renaming
williamrandolph Oct 22, 2021
9cee8a1
Fix test
williamrandolph Oct 22, 2021
067e63f
Fix test setup issue for index name expression resolver
williamrandolph Oct 22, 2021
d8291ca
Make sure system data stream backing indices are hidden
williamrandolph Oct 22, 2021
6d552a2
Make sure transport request adds hidden index setting if missing
williamrandolph Oct 22, 2021
c8d8c93
Validate and set default for autocreated system indices
williamrandolph Oct 22, 2021
813a8aa
Don't test 'non-hidden' system indices
williamrandolph Oct 23, 2021
8dac8c5
Skip some reindex rest compat tests
williamrandolph Oct 23, 2021
1084036
Merge branch 'master' into si/hide-them-all
williamrandolph Oct 23, 2021
a5890ae
Apply spotless everywhere
williamrandolph Nov 3, 2021
17e6f23
Merge branch 'master' into si/hide-them-all
williamrandolph Nov 3, 2021
45d5911
Checkstyle and spotless
williamrandolph Nov 3, 2021
4217651
Merge branch 'master' into si/hide-them-all
williamrandolph Nov 4, 2021
c47de88
Add some code to hide system aliases
williamrandolph Nov 9, 2021
2f5b5fc
Add failing tests and do spotless cleanup
williamrandolph Nov 10, 2021
2be29e8
Merge branch 'master' into si/hide-them-all
williamrandolph Nov 10, 2021
48ef4f6
Fix up some tests where behavior changed
williamrandolph Nov 10, 2021
fcbab57
Hide system aliases in create index service
williamrandolph Nov 10, 2021
bd1edae
Watch out for null Booleans
williamrandolph Nov 11, 2021
b3b272a
Handle the null Boolean take 2
williamrandolph Nov 11, 2021
7b6d3f9
Merge branch 'master' into si/hide-them-all
williamrandolph Nov 11, 2021
2141100
Expand hidden indices in snapshot test
williamrandolph Nov 11, 2021
514ea37
Merge branch 'master' into si/hide-them-all
williamrandolph Nov 11, 2021
c1a249c
Fix up tests for v1 aliases
williamrandolph Nov 11, 2021
ac7897c
Add composable v2 template create test
williamrandolph Nov 11, 2021
cd0146c
Clean up tests, add autocreate v2 alias test
williamrandolph Nov 11, 2021
680667e
Hide system aliases when adding them via alias endpoints
williamrandolph Nov 12, 2021
8650426
Refactoring and cleanup
williamrandolph Nov 16, 2021
dc85975
Merge branch 'master' into si/hide-them-all
williamrandolph Nov 16, 2021
a9af5d7
remove todos
williamrandolph Nov 16, 2021
178b456
Merge branch 'master' into si/hide-them-all
williamrandolph Nov 30, 2021
5b95212
Check system indices when simulating and validating templates
williamrandolph Nov 30, 2021
6f93f86
Restore test coverage for hidden indices
williamrandolph Nov 30, 2021
62744ca
Handle non normalized strings
williamrandolph Nov 30, 2021
33fa6fc
Fix typo, remove unneeded header
williamrandolph Nov 30, 2021
6dd476d
Use system index default settings in tests
williamrandolph Nov 30, 2021
65dea59
Rename method for clarity
williamrandolph Nov 30, 2021
adfd04f
apply spotless
williamrandolph Nov 30, 2021
841ffd4
Add known issue for reenabling tests
williamrandolph Nov 30, 2021
5dfdade
Merge branch 'master' into si/hide-them-all
williamrandolph Dec 1, 2021
e20b545
Merge branch 'master' into si/hide-them-all
williamrandolph Dec 6, 2021
d62a275
Update docs/changelog/79512.yaml
williamrandolph Dec 6, 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
5 changes: 5 additions & 0 deletions docs/changelog/79512.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 79512
summary: All system indices are hidden indices
area: Infra/Core
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.common.xcontent.XContentHelper;
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.xcontent.json.JsonXContent;
Expand Down Expand Up @@ -218,6 +219,27 @@ public void testUpdateIndexSettings() throws IOException {
assertThat(response.getStatusLine().getStatusCode(), is(200));
}

public void testCannotCreateVisibleSystemIndex() {
Request request = request("PUT", "/" + indexName);
request.setJsonEntity("{\"settings\": {\"index.hidden\":\"false\"}}");
ResponseException exception = expectThrows(ResponseException.class, () -> client().performRequest(request));
assertThat(
exception.getMessage(),
containsString("Cannot create system index [" + indexName + "] with [index.hidden] set to 'false'")
);
}

public void testCannotSetVisible() throws IOException {
Request putIndexRequest = request("PUT", "/" + indexName);
Response response = client().performRequest(putIndexRequest);
assertThat(response.getStatusLine().getStatusCode(), is(200));

Request putSettingsRequest = request("PUT", "/" + indexName + "/_settings");
putSettingsRequest.setJsonEntity("{ \"index.hidden\" : false }");
ResponseException exception = expectThrows(ResponseException.class, () -> client().performRequest(putSettingsRequest));
assertThat(exception.getMessage(), containsString("Cannot set [index.hidden] to 'false' on system indices: [" + indexName + "]"));
}

public void testGetIndex() throws IOException {
Request request = request("PUT", "/" + indexName);
Response response = client().performRequest(request);
Expand Down
12 changes: 12 additions & 0 deletions modules/reindex/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,18 @@ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
tasks.named("yamlRestTestV7CompatTransform").configure { task ->
task.skipTest("reindex/20_validation/reindex without source gives useful error message", "exception with a type. Not much benefit adding _doc there.")
task.skipTest("update_by_query/20_validation/update_by_query without source gives useful error message", "exception with a type. Not much benefit adding _doc there.")

// these tests are all relying on a call to refresh all indices, when they could easily be changed
// in 7.x to call the specific index they want to refresh.
// See https://github.com/elastic/elasticsearch/issues/81188
task.skipTest("delete_by_query/70_throttle/Rethrottle to -1 which turns off throttling", "test relies on system index being non-hidden")
task.skipTest("delete_by_query/80_slices/Multiple slices with rethrottle", "test relies on system index being non-hidden")
task.skipTest("delete_by_query/80_slices/Multiple slices with wait_for_completion=false", "test relies on system index being non-hidden")
task.skipTest("reindex/80_slices/Multiple slices with rethrottle", "test relies on system index being non-hidden")
task.skipTest("reindex/80_slices/Multiple slices with wait_for_completion=false", "test relies on system index being non-hidden")
task.skipTest("update_by_query/70_slices/Multiple slices with rethrottle", "test relies on system index being non-hidden")
task.skipTest("update_by_query/70_slices/Multiple slices with wait_for_completion=false", "test relies on system index being non-hidden")
gwbrown marked this conversation as resolved.
Show resolved Hide resolved

task.addAllowedWarningRegex("\\[types removal\\].*")
}

Original file line number Diff line number Diff line change
Expand Up @@ -299,20 +299,22 @@ public void createSystemIndexForDescriptor(SystemIndexDescriptor descriptor) thr
String indexName = Optional.ofNullable(descriptor.getPrimaryIndex()).orElse(descriptor.getIndexPattern().replace("*", "old"));
CreateIndexRequestBuilder createRequest = prepareCreate(indexName);
createRequest.setWaitForActiveShards(ActiveShardCount.ALL);
if (descriptor.getSettings() != null) {
createRequest.setSettings(
Settings.builder()
.put("index.version.created", Version.CURRENT)
.put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0)
.build()
);
} else {
if (SystemIndexDescriptor.DEFAULT_SETTINGS.equals(descriptor.getSettings())) {
// unmanaged
createRequest.setSettings(
createSimpleSettings(
NEEDS_UPGRADE_VERSION,
descriptor.isInternal() ? INTERNAL_UNMANAGED_FLAG_VALUE : EXTERNAL_UNMANAGED_FLAG_VALUE
)
);
} else {
// managed
createRequest.setSettings(
Settings.builder()
.put("index.version.created", Version.CURRENT)
.put(IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0)
.build()
);
}
if (descriptor.getMappings() == null) {
createRequest.setMapping(createSimpleMapping(false, descriptor.isInternal()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,6 @@
task_id: $task

- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
indices.refresh: {}

- do:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
indices.refresh: {}
indices.refresh:
expand_wildcards: "open,hidden"
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
Expand Down Expand Up @@ -270,7 +271,8 @@
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
indices.refresh: {}
indices.refresh:
expand_wildcards: "open,hidden"
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
indices.refresh: {}
indices.refresh:
expand_wildcards: "open,hidden"
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
Expand Down Expand Up @@ -282,7 +283,8 @@
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
indices.refresh: {}
indices.refresh:
expand_wildcards: "open,hidden"
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
indices.refresh: {}
indices.refresh:
expand_wildcards: "open,hidden"
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
Expand Down Expand Up @@ -256,7 +257,8 @@
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
indices.refresh: {}
indices.refresh:
expand_wildcards: "open,hidden"
- do:
warnings:
- "this request accesses system indices: [.tasks], but in a future major version, direct access to system indices will be prevented by default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.ResponseException;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.cluster.metadata.IndexMetadata;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
Expand Down Expand Up @@ -45,6 +46,7 @@
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.test.rest.ESRestTestCase.entityAsMap;
import static org.elasticsearch.xcontent.XContentFactory.jsonBuilder;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasKey;
import static org.hamcrest.Matchers.is;
Expand Down Expand Up @@ -92,6 +94,17 @@ public void testSystemIndexAccessBlockedByDefault() throws Exception {
// And with a total wildcard
assertDeprecationWarningOnAccess(randomFrom("*", "_all"), SystemIndexTestPlugin.SYSTEM_INDEX_NAME);

// If we're not expanding wildcards, we don't get anything
{
Request searchRequest = new Request("GET", "/" + randomFrom("*", "_all") + randomFrom("/_count", "/_search"));
searchRequest.setJsonEntity("{\"query\": {\"match\": {\"some_field\": \"some_value\"}}}");
searchRequest.addParameter("allow_no_indices", "false");

ResponseException exception = expectThrows(ResponseException.class, () -> getRestClient().performRequest(searchRequest));
assertThat(exception.getResponse().getStatusLine().getStatusCode(), equalTo(404));
assertThat(exception.getMessage(), containsString("no such index"));
}

// Try to index a doc directly
{
String expectedWarning = "this request accesses system indices: ["
Expand All @@ -115,6 +128,7 @@ private void assertDeprecationWarningOnAccess(String queryPattern, String warnin
searchRequest.setJsonEntity("{\"query\": {\"match\": {\"some_field\": \"some_value\"}}}");
// Disallow no indices to cause an exception if this resolves to zero indices, so that we're sure it resolved the index
searchRequest.addParameter("allow_no_indices", "false");
searchRequest.addParameter("expand_wildcards", "open,hidden");
searchRequest.setOptions(expectWarnings(expectedWarning));

Response response = getRestClient().performRequest(searchRequest);
Expand Down
Loading