Skip to content

Commit

Permalink
[Fleet] Remove ILM policy from fleet files indices and make them hidd…
Browse files Browse the repository at this point in the history
…en (elastic#94651) (elastic#94668)

* Remove ILM policy from files indices and make them hidden

* use correct setting for hidden and auto_expand

* fix tests

* remove unused imports
  • Loading branch information
hop-dev authored Mar 23, 2023
1 parent 93ba778 commit ec80f78
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 24 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugin/core/src/main/resources/fleet-file-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"template" : {
"settings": {
"index.lifecycle.name": ".fleet-file-data-ilm-policy",
"auto_expand_replicas": "0-1"
"index.auto_expand_replicas": "0-1",
"index.hidden": true
},
"mappings": {
"_doc": {
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugin/core/src/main/resources/fleet-files.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"template": {
"settings": {
"index.lifecycle.name": ".fleet-files-ilm-policy",
"index.auto_expand_replicas": "0-1"
"index.auto_expand_replicas": "0-1",
"index.hidden": true
},
"mappings": {
"_doc": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import org.apache.http.util.EntityUtils;
import org.elasticsearch.client.Request;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.Response;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.ThreadContext;
Expand All @@ -18,7 +17,6 @@
import org.elasticsearch.test.rest.ESRestTestCase;
import org.elasticsearch.xcontent.XContentType;

import java.util.List;
import java.util.Map;

import static org.hamcrest.Matchers.containsString;
Expand All @@ -40,22 +38,6 @@ protected Settings restClientSettings() {
.build();
}

private void expectSystemIndexWarning(Request request, String indexName) {
String warningMsg = "index name ["
+ indexName
+ "] starts with a dot '.', in the next major version, "
+ "index names starting with a dot are reserved for hidden indices and system indices";

List<String> expectedWarnings = List.of(warningMsg);

logger.info("expecting warnings: " + expectedWarnings.toString());
RequestOptions consumeSystemIndicesWarningsOptions = RequestOptions.DEFAULT.toBuilder()
.setWarningsHandler(warnings -> expectedWarnings.equals(warnings) == false)
.build();

request.setOptions(consumeSystemIndicesWarningsOptions);
}

public void testSearchWithoutIndexCreatedIsAllowed() throws Exception {
Request request = new Request("GET", ".fleet-agents/_search");
request.setJsonEntity("{ \"query\": { \"match_all\": {} } }");
Expand Down Expand Up @@ -98,7 +80,6 @@ public void testCreationOfFleetActions() throws Exception {

public void testCreationOfFleetFiles() throws Exception {
Request request = new Request("PUT", ".fleet-files-agent-00001");
expectSystemIndexWarning(request, ".fleet-files-agent-00001");
Response response = client().performRequest(request);
assertEquals(200, response.getStatusLine().getStatusCode());

Expand All @@ -111,7 +92,6 @@ public void testCreationOfFleetFiles() throws Exception {

public void testCreationOfFleetFileData() throws Exception {
Request request = new Request("PUT", ".fleet-file-data-agent-00001");
expectSystemIndexWarning(request, ".fleet-file-data-agent-00001");
Response response = client().performRequest(request);
assertEquals(200, response.getStatusLine().getStatusCode());

Expand Down

0 comments on commit ec80f78

Please sign in to comment.