Browse Source

Revert "Introduce system index APIs for Kibana (#52385)" (#53912)

This reverts commit 4c0e8f12cbc078c1b85a67af76ed8a4be11a6f01.

It should be re-added once #53909 is addressed.
Ryan Ernst 5 years ago
parent
commit
8264bdd36a
42 changed files with 116 additions and 950 deletions
  1. 2 2
      build.gradle
  2. 0 31
      modules/kibana/build.gradle
  3. 0 145
      modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java
  4. 0 46
      modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java
  5. 0 249
      modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java
  6. 1 2
      modules/tasks/src/main/java/org/elasticsearch/tasksplugin/TasksPlugin.java
  7. 1 2
      modules/tasks/src/test/java/org/elasticsearch/tasksplugin/TasksPluginTests.java
  8. 7 4
      server/src/main/java/org/elasticsearch/action/ActionModule.java
  9. 3 3
      server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java
  10. 2 7
      server/src/main/java/org/elasticsearch/common/compress/DeflateCompressor.java
  11. 0 11
      server/src/main/java/org/elasticsearch/common/io/Streams.java
  12. 2 16
      server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
  13. 14 73
      server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java
  14. 2 2
      server/src/main/java/org/elasticsearch/node/Node.java
  15. 1 3
      server/src/main/java/org/elasticsearch/plugins/SystemIndexPlugin.java
  16. 0 53
      server/src/main/java/org/elasticsearch/rest/BaseRestHandler.java
  17. 1 16
      server/src/main/java/org/elasticsearch/rest/RestController.java
  18. 19 33
      server/src/main/java/org/elasticsearch/rest/action/RestCancellableNodeClient.java
  19. 5 6
      server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java
  20. 0 11
      server/src/main/java/org/elasticsearch/transport/CompressibleBytesOutputStream.java
  21. 15 20
      server/src/main/java/org/elasticsearch/transport/InboundMessage.java
  22. 1 2
      server/src/main/java/org/elasticsearch/transport/OutboundMessage.java
  23. 3 13
      server/src/main/java/org/elasticsearch/transport/TransportLogger.java
  24. 3 3
      server/src/test/java/org/elasticsearch/action/ActionModuleTests.java
  25. 0 7
      server/src/test/java/org/elasticsearch/common/compress/DeflateCompressTests.java
  26. 3 130
      server/src/test/java/org/elasticsearch/common/util/concurrent/ThreadContextTests.java
  27. 7 26
      server/src/test/java/org/elasticsearch/rest/RestControllerTests.java
  28. 1 1
      server/src/test/java/org/elasticsearch/rest/RestHttpResponseHeadersTests.java
  29. 1 1
      server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryActionTests.java
  30. 1 1
      server/src/test/java/org/elasticsearch/rest/action/cat/RestCatRecoveryActionTests.java
  31. 1 2
      server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java
  32. 6 1
      server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java
  33. 0 13
      server/src/test/java/org/elasticsearch/transport/CompressibleBytesOutputStreamTests.java
  34. 1 1
      test/framework/src/main/java/org/elasticsearch/test/rest/RestActionTestCase.java
  35. 6 6
      test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java
  36. 1 1
      x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java
  37. 1 2
      x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java
  38. 1 1
      x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java
  39. 1 1
      x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java
  40. 1 1
      x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java
  41. 1 1
      x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java
  42. 1 1
      x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java

+ 2 - 2
build.gradle

@@ -222,8 +222,8 @@ task verifyVersions {
  * after the backport of the backcompat code is complete.
  */
 
-boolean bwc_tests_enabled = true
-final String bwc_tests_disabled_issue = "" /* place a PR link here when committing bwc changes */
+boolean bwc_tests_enabled = false
+final String bwc_tests_disabled_issue = "https://github.com/elastic/elasticsearch/pull/53912" /* place a PR link here when committing bwc changes */
 if (bwc_tests_enabled == false) {
   if (bwc_tests_disabled_issue.isEmpty()) {
     throw new GradleException("bwc_tests_disabled_issue must be set when bwc_tests_enabled == false")

+ 0 - 31
modules/kibana/build.gradle

@@ -1,31 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-esplugin {
-  description 'Plugin exposing APIs for Kibana system indices'
-  classname 'org.elasticsearch.kibana.KibanaPlugin'
-}
-
-dependencies {
-  compile project(path: ':modules:reindex', configuration: 'runtime')
-}
-
-testClusters.integTest {
-  module file(project(':modules:reindex').tasks.bundlePlugin.archiveFile)
-}

+ 0 - 145
modules/kibana/src/main/java/org/elasticsearch/kibana/KibanaPlugin.java

@@ -1,145 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.kibana;
-
-import org.elasticsearch.client.node.NodeClient;
-import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
-import org.elasticsearch.cluster.node.DiscoveryNodes;
-import org.elasticsearch.common.settings.ClusterSettings;
-import org.elasticsearch.common.settings.IndexScopedSettings;
-import org.elasticsearch.common.settings.Setting;
-import org.elasticsearch.common.settings.Setting.Property;
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.common.settings.SettingsFilter;
-import org.elasticsearch.index.reindex.RestDeleteByQueryAction;
-import org.elasticsearch.indices.SystemIndexDescriptor;
-import org.elasticsearch.plugins.Plugin;
-import org.elasticsearch.plugins.SystemIndexPlugin;
-import org.elasticsearch.rest.BaseRestHandler;
-import org.elasticsearch.rest.RestController;
-import org.elasticsearch.rest.RestHandler;
-import org.elasticsearch.rest.RestRequest;
-import org.elasticsearch.rest.action.admin.indices.RestCreateIndexAction;
-import org.elasticsearch.rest.action.admin.indices.RestGetAliasesAction;
-import org.elasticsearch.rest.action.admin.indices.RestGetIndicesAction;
-import org.elasticsearch.rest.action.admin.indices.RestIndexPutAliasAction;
-import org.elasticsearch.rest.action.admin.indices.RestRefreshAction;
-import org.elasticsearch.rest.action.admin.indices.RestUpdateSettingsAction;
-import org.elasticsearch.rest.action.document.RestBulkAction;
-import org.elasticsearch.rest.action.document.RestDeleteAction;
-import org.elasticsearch.rest.action.document.RestGetAction;
-import org.elasticsearch.rest.action.document.RestIndexAction;
-import org.elasticsearch.rest.action.document.RestIndexAction.AutoIdHandler;
-import org.elasticsearch.rest.action.document.RestIndexAction.CreateHandler;
-import org.elasticsearch.rest.action.document.RestMultiGetAction;
-import org.elasticsearch.rest.action.document.RestUpdateAction;
-import org.elasticsearch.rest.action.search.RestClearScrollAction;
-import org.elasticsearch.rest.action.search.RestSearchAction;
-import org.elasticsearch.rest.action.search.RestSearchScrollAction;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.List;
-import java.util.function.Function;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-
-public class KibanaPlugin extends Plugin implements SystemIndexPlugin {
-
-    public static final Setting<List<String>> KIBANA_INDEX_NAMES_SETTING = Setting.listSetting("kibana.system_indices",
-        List.of(".kibana*", ".reporting"), Function.identity(), Property.NodeScope);
-
-    @Override
-    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
-        return KIBANA_INDEX_NAMES_SETTING.get(settings).stream()
-            .map(pattern -> new SystemIndexDescriptor(pattern, "System index used by kibana"))
-            .collect(Collectors.toUnmodifiableList());
-    }
-
-    @Override
-    public List<RestHandler> getRestHandlers(Settings settings, RestController restController, ClusterSettings clusterSettings,
-                                             IndexScopedSettings indexScopedSettings, SettingsFilter settingsFilter,
-                                             IndexNameExpressionResolver indexNameExpressionResolver,
-                                             Supplier<DiscoveryNodes> nodesInCluster) {
-        // TODO need to figure out what subset of system indices Kibana should have access to via these APIs
-        final List<String> allowedIndexPatterns = List.of();
-        return List.of(
-            // Based on https://github.com/elastic/kibana/issues/49764
-            // apis needed to perform migrations... ideally these will go away
-            new KibanaWrappedRestHandler(new RestCreateIndexAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestGetAliasesAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestIndexPutAliasAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestRefreshAction(), allowedIndexPatterns),
-
-            // apis needed to access saved objects
-            new KibanaWrappedRestHandler(new RestGetAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestMultiGetAction(settings), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestSearchAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestBulkAction(settings), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestDeleteAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestDeleteByQueryAction(), allowedIndexPatterns),
-
-            // api used for testing
-            new KibanaWrappedRestHandler(new RestUpdateSettingsAction(), allowedIndexPatterns),
-
-            // apis used specifically by reporting
-            new KibanaWrappedRestHandler(new RestGetIndicesAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestIndexAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new CreateHandler(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new AutoIdHandler(nodesInCluster), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestUpdateAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestSearchScrollAction(), allowedIndexPatterns),
-            new KibanaWrappedRestHandler(new RestClearScrollAction(), allowedIndexPatterns)
-        );
-
-    }
-
-    @Override
-    public List<Setting<?>> getSettings() {
-        return List.of(KIBANA_INDEX_NAMES_SETTING);
-    }
-
-    static class KibanaWrappedRestHandler extends BaseRestHandler.Wrapper {
-
-        private final List<String> allowedIndexPatterns;
-
-        KibanaWrappedRestHandler(BaseRestHandler delegate, List<String> allowedIndexPatterns) {
-            super(delegate);
-            this.allowedIndexPatterns = allowedIndexPatterns;
-        }
-
-        @Override
-        public String getName() {
-            return "kibana_" + super.getName();
-        }
-
-        @Override
-        public List<Route> routes() {
-            return super.routes().stream().map(route -> new Route(route.getMethod(), "/_kibana" + route.getPath()))
-                .collect(Collectors.toUnmodifiableList());
-        }
-
-        @Override
-        protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
-            client.threadPool().getThreadContext().allowSystemIndexAccess(allowedIndexPatterns);
-            return super.prepareRequest(request, client);
-        }
-    }
-}

+ 0 - 46
modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaPluginTests.java

@@ -1,46 +0,0 @@
-
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.kibana;
-
-import org.elasticsearch.common.settings.Settings;
-import org.elasticsearch.indices.SystemIndexDescriptor;
-import org.elasticsearch.test.ESTestCase;
-
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static org.hamcrest.Matchers.contains;
-import static org.hamcrest.Matchers.is;
-
-public class KibanaPluginTests extends ESTestCase {
-
-    public void testKibanaIndexNames() {
-        assertThat(new KibanaPlugin().getSettings(), contains(KibanaPlugin.KIBANA_INDEX_NAMES_SETTING));
-        assertThat(new KibanaPlugin().getSystemIndexDescriptors(Settings.EMPTY).stream()
-            .map(SystemIndexDescriptor::getIndexPattern).collect(Collectors.toUnmodifiableList()),
-            contains(".kibana*", ".reporting"));
-        final List<String> names = List.of("." + randomAlphaOfLength(4), "." + randomAlphaOfLength(6));
-        final List<String> namesFromDescriptors = new KibanaPlugin().getSystemIndexDescriptors(
-                Settings.builder().putList(KibanaPlugin.KIBANA_INDEX_NAMES_SETTING.getKey(), names).build()
-            ).stream().map(SystemIndexDescriptor::getIndexPattern).collect(Collectors.toUnmodifiableList());
-        assertThat(namesFromDescriptors, is(names));
-    }
-}

+ 0 - 249
modules/kibana/src/test/java/org/elasticsearch/kibana/KibanaSystemIndexIT.java

@@ -1,249 +0,0 @@
-/*
- * Licensed to Elasticsearch under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *    http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.elasticsearch.kibana;
-
-import org.apache.http.util.EntityUtils;
-import org.elasticsearch.client.Request;
-import org.elasticsearch.client.Response;
-import org.elasticsearch.common.xcontent.XContentHelper;
-import org.elasticsearch.common.xcontent.json.JsonXContent;
-import org.elasticsearch.test.rest.ESRestTestCase;
-
-import java.io.IOException;
-import java.util.Map;
-
-import static org.hamcrest.Matchers.containsString;
-import static org.hamcrest.Matchers.is;
-
-public class KibanaSystemIndexIT extends ESRestTestCase {
-
-    public void testCreateIndex() throws IOException {
-        Request request = new Request("PUT", "/_kibana/.kibana-1");
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-    }
-
-    public void testAliases() throws IOException {
-        Request request = new Request("PUT", "/_kibana/.kibana-1");
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        request = new Request("PUT", "/_kibana/.kibana-1/_alias/.kibana");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        request = new Request("GET", "/_kibana/_aliases");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-        assertThat(EntityUtils.toString(response.getEntity()), containsString(".kibana"));
-    }
-
-    public void testBulkToKibanaIndex() throws IOException {
-        Request request = new Request("POST", "/_kibana/_bulk");
-        request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n");
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-    }
-
-    public void testRefresh() throws IOException {
-        Request request = new Request("POST", "/_kibana/_bulk");
-        request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n");
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        request = new Request("GET", "/_kibana/.kibana/_refresh");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        Request getRequest = new Request("GET", "/_kibana/.kibana/_doc/1");
-        Response getResponse = client().performRequest(getRequest);
-        assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
-        String responseBody = EntityUtils.toString(getResponse.getEntity());
-        assertThat(responseBody, containsString("foo"));
-        assertThat(responseBody, containsString("bar"));
-    }
-
-    public void testGetFromKibanaIndex() throws IOException {
-        Request request = new Request("POST", "/_kibana/_bulk");
-        request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n");
-        request.addParameter("refresh", "true");
-
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        Request getRequest = new Request("GET", "/_kibana/.kibana/_doc/1");
-        Response getResponse = client().performRequest(getRequest);
-        assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
-        String responseBody = EntityUtils.toString(getResponse.getEntity());
-        assertThat(responseBody, containsString("foo"));
-        assertThat(responseBody, containsString("bar"));
-    }
-
-    public void testMultiGetFromKibanaIndex() throws IOException {
-        Request request = new Request("POST", "/_kibana/_bulk");
-        request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
-            "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n");
-        request.addParameter("refresh", "true");
-
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        Request getRequest = new Request("GET", "/_kibana/_mget");
-        getRequest.setJsonEntity("{ \"docs\" : [ { \"_index\" : \".kibana\", \"_id\" : \"1\" }, " +
-            "{ \"_index\" : \".kibana\", \"_id\" : \"2\" } ] }\n");
-        Response getResponse = client().performRequest(getRequest);
-        assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
-        String responseBody = EntityUtils.toString(getResponse.getEntity());
-        assertThat(responseBody, containsString("foo"));
-        assertThat(responseBody, containsString("bar"));
-        assertThat(responseBody, containsString("baz"));
-        assertThat(responseBody, containsString("tag"));
-    }
-
-    public void testSearchFromKibanaIndex() throws IOException {
-        Request request = new Request("POST", "/_kibana/_bulk");
-        request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
-            "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n");
-        request.addParameter("refresh", "true");
-
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        Request searchRequest = new Request("GET", "/_kibana/.kibana/_search");
-        searchRequest.setJsonEntity("{ \"query\" : { \"match_all\" : {} } }\n");
-        Response getResponse = client().performRequest(searchRequest);
-        assertThat(getResponse.getStatusLine().getStatusCode(), is(200));
-        String responseBody = EntityUtils.toString(getResponse.getEntity());
-        assertThat(responseBody, containsString("foo"));
-        assertThat(responseBody, containsString("bar"));
-        assertThat(responseBody, containsString("baz"));
-        assertThat(responseBody, containsString("tag"));
-    }
-
-    public void testDeleteFromKibanaIndex() throws IOException {
-        Request request = new Request("POST", "/_kibana/_bulk");
-        request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
-            "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n");
-        request.addParameter("refresh", "true");
-
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        Request deleteRequest = new Request("DELETE", "/_kibana/.kibana/_doc/1");
-        Response deleteResponse = client().performRequest(deleteRequest);
-        assertThat(deleteResponse.getStatusLine().getStatusCode(), is(200));
-    }
-
-    public void testDeleteByQueryFromKibanaIndex() throws IOException {
-        Request request = new Request("POST", "/_kibana/_bulk");
-        request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
-            "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n");
-        request.addParameter("refresh", "true");
-
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        Request dbqRequest = new Request("POST", "/_kibana/.kibana/_delete_by_query");
-        dbqRequest.setJsonEntity("{ \"query\" : { \"match_all\" : {} } }\n");
-        Response dbqResponse = client().performRequest(dbqRequest);
-        assertThat(dbqResponse.getStatusLine().getStatusCode(), is(200));
-    }
-
-    public void testUpdateIndexSettings() throws IOException {
-        Request request = new Request("PUT", "/_kibana/.kibana-1");
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        request = new Request("PUT", "/_kibana/.kibana-1/_settings");
-        request.setJsonEntity("{ \"index.blocks.read_only\" : false }");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-    }
-
-    public void testGetIndex() throws IOException {
-        Request request = new Request("PUT", "/_kibana/.kibana-1");
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        request = new Request("GET", "/_kibana/.kibana-1");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-        assertThat(EntityUtils.toString(response.getEntity()), containsString(".kibana-1"));
-    }
-
-    public void testIndexingAndUpdatingDocs() throws IOException {
-        Request request = new Request("PUT", "/_kibana/.kibana-1/_doc/1");
-        request.setJsonEntity("{ \"foo\" : \"bar\" }");
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(201));
-
-        request = new Request("PUT", "/_kibana/.kibana-1/_create/2");
-        request.setJsonEntity("{ \"foo\" : \"bar\" }");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(201));
-
-        request = new Request("POST", "/_kibana/.kibana-1/_doc");
-        request.setJsonEntity("{ \"foo\" : \"bar\" }");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(201));
-
-        request = new Request("GET", "/_kibana/.kibana-1/_refresh");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        request = new Request("POST", "/_kibana/.kibana-1/_update/1");
-        request.setJsonEntity("{ \"doc\" : { \"foo\" : \"baz\" } }");
-        response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-    }
-
-    public void testScrollingDocs() throws IOException {
-        Request request = new Request("POST", "/_kibana/_bulk");
-        request.setJsonEntity("{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"1\" } }\n{ \"foo\" : \"bar\" }\n" +
-            "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"2\" } }\n{ \"baz\" : \"tag\" }\n" +
-            "{ \"index\" : { \"_index\" : \".kibana\", \"_id\" : \"3\" } }\n{ \"baz\" : \"tag\" }\n");
-        request.addParameter("refresh", "true");
-        Response response = client().performRequest(request);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-
-        Request searchRequest = new Request("GET", "/_kibana/.kibana/_search");
-        searchRequest.setJsonEntity("{ \"size\" : 1,\n\"query\" : { \"match_all\" : {} } }\n");
-        searchRequest.addParameter("scroll", "1m");
-        response = client().performRequest(searchRequest);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-        Map<String, Object> map = XContentHelper.convertToMap(JsonXContent.jsonXContent, EntityUtils.toString(response.getEntity()), false);
-        assertNotNull(map.get("_scroll_id"));
-        String scrollId = (String) map.get("_scroll_id");
-
-        Request scrollRequest = new Request("POST", "/_kibana/_search/scroll");
-        scrollRequest.addParameter("scroll_id", scrollId);
-        scrollRequest.addParameter("scroll", "1m");
-        response = client().performRequest(scrollRequest);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-        map = XContentHelper.convertToMap(JsonXContent.jsonXContent, EntityUtils.toString(response.getEntity()), false);
-        assertNotNull(map.get("_scroll_id"));
-        scrollId = (String) map.get("_scroll_id");
-
-        Request clearScrollRequest = new Request("DELETE", "/_kibana/_search/scroll");
-        clearScrollRequest.addParameter("scroll_id", scrollId);
-        response = client().performRequest(clearScrollRequest);
-        assertThat(response.getStatusLine().getStatusCode(), is(200));
-    }
-}

+ 1 - 2
modules/tasks/src/main/java/org/elasticsearch/tasksplugin/TasksPlugin.java

@@ -19,7 +19,6 @@
 
 package org.elasticsearch.tasksplugin;
 
-import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.indices.SystemIndexDescriptor;
 import org.elasticsearch.plugins.Plugin;
 import org.elasticsearch.plugins.SystemIndexPlugin;
@@ -35,7 +34,7 @@ import static org.elasticsearch.tasks.TaskResultsService.TASK_INDEX;
 public class TasksPlugin extends Plugin implements SystemIndexPlugin {
 
     @Override
-    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
+    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors() {
         return Collections.singletonList(new SystemIndexDescriptor(TASK_INDEX, this.getClass().getSimpleName()));
     }
 }

+ 1 - 2
modules/tasks/src/test/java/org/elasticsearch/tasksplugin/TasksPluginTests.java

@@ -19,7 +19,6 @@
 
 package org.elasticsearch.tasksplugin;
 
-import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.test.ESTestCase;
 import org.hamcrest.Matchers;
 
@@ -28,6 +27,6 @@ public class TasksPluginTests extends ESTestCase {
     public void testDummy() {
         // This is a dummy test case to satisfy the conventions
         TasksPlugin plugin = new TasksPlugin();
-        assertThat(plugin.getSystemIndexDescriptors(Settings.EMPTY), Matchers.hasSize(1));
+        assertThat(plugin.getSystemIndexDescriptors(), Matchers.hasSize(1));
     }
 }

+ 7 - 4
server/src/main/java/org/elasticsearch/action/ActionModule.java

@@ -215,6 +215,7 @@ import org.elasticsearch.action.update.UpdateAction;
 import org.elasticsearch.client.node.NodeClient;
 import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
+import org.elasticsearch.cluster.service.ClusterService;
 import org.elasticsearch.common.NamedRegistry;
 import org.elasticsearch.common.inject.AbstractModule;
 import org.elasticsearch.common.inject.TypeLiteral;
@@ -419,17 +420,19 @@ public class ActionModule extends AbstractModule {
     private final RestController restController;
     private final RequestValidators<PutMappingRequest> mappingRequestValidators;
     private final RequestValidators<IndicesAliasesRequest> indicesAliasesRequestRequestValidators;
+    private final ClusterService clusterService;
 
     public ActionModule(Settings settings, IndexNameExpressionResolver indexNameExpressionResolver,
                         IndexScopedSettings indexScopedSettings, ClusterSettings clusterSettings, SettingsFilter settingsFilter,
                         ThreadPool threadPool, List<ActionPlugin> actionPlugins, NodeClient nodeClient,
-                        CircuitBreakerService circuitBreakerService, UsageService usageService) {
+                        CircuitBreakerService circuitBreakerService, UsageService usageService, ClusterService clusterService) {
         this.settings = settings;
         this.indexNameExpressionResolver = indexNameExpressionResolver;
         this.indexScopedSettings = indexScopedSettings;
         this.clusterSettings = clusterSettings;
         this.settingsFilter = settingsFilter;
         this.actionPlugins = actionPlugins;
+        this.clusterService = clusterService;
         actions = setupActions(actionPlugins);
         actionFilters = setupActionFilters(actionPlugins);
         autoCreateIndex = new AutoCreateIndex(settings, clusterSettings, indexNameExpressionResolver);
@@ -454,10 +457,10 @@ public class ActionModule extends AbstractModule {
         indicesAliasesRequestRequestValidators = new RequestValidators<>(
                 actionPlugins.stream().flatMap(p -> p.indicesAliasesRequestValidators().stream()).collect(Collectors.toList()));
 
-        final boolean restrictSystemIndices = RestController.RESTRICT_SYSTEM_INDICES.get(settings);
-        restController = new RestController(headers, restWrapper, nodeClient, circuitBreakerService, usageService, restrictSystemIndices);
+        restController = new RestController(headers, restWrapper, nodeClient, circuitBreakerService, usageService);
     }
 
+
     public Map<String, ActionHandler<?, ?>> getActions() {
         return actions;
     }
@@ -698,7 +701,7 @@ public class ActionModule extends AbstractModule {
 
         registerHandler.accept(new RestIndexAction());
         registerHandler.accept(new CreateHandler());
-        registerHandler.accept(new AutoIdHandler(nodesInCluster));
+        registerHandler.accept(new AutoIdHandler(clusterService));
         registerHandler.accept(new RestGetAction());
         registerHandler.accept(new RestGetSourceAction());
         registerHandler.accept(new RestMultiGetAction(settings));

+ 3 - 3
server/src/main/java/org/elasticsearch/cluster/coordination/PublicationTransportHandler.java

@@ -321,8 +321,8 @@ public class PublicationTransportHandler {
 
     public static BytesReference serializeFullClusterState(ClusterState clusterState, Version nodeVersion) throws IOException {
         final BytesStreamOutput bStream = new BytesStreamOutput();
-        bStream.setVersion(nodeVersion);
         try (StreamOutput stream = CompressorFactory.COMPRESSOR.streamOutput(bStream)) {
+            stream.setVersion(nodeVersion);
             stream.writeBoolean(true);
             clusterState.writeTo(stream);
         }
@@ -331,8 +331,8 @@ public class PublicationTransportHandler {
 
     public static BytesReference serializeDiffClusterState(Diff diff, Version nodeVersion) throws IOException {
         final BytesStreamOutput bStream = new BytesStreamOutput();
-        bStream.setVersion(nodeVersion);
         try (StreamOutput stream = CompressorFactory.COMPRESSOR.streamOutput(bStream)) {
+            stream.setVersion(nodeVersion);
             stream.writeBoolean(false);
             diff.writeTo(stream);
         }
@@ -342,12 +342,12 @@ public class PublicationTransportHandler {
     private PublishWithJoinResponse handleIncomingPublishRequest(BytesTransportRequest request) throws IOException {
         final Compressor compressor = CompressorFactory.compressor(request.bytes());
         StreamInput in = request.bytes().streamInput();
-        in.setVersion(request.version());
         try {
             if (compressor != null) {
                 in = compressor.streamInput(in);
             }
             in = new NamedWriteableAwareStreamInput(in, namedWriteableRegistry);
+            in.setVersion(request.version());
             // If true we received full cluster state - otherwise diffs
             if (in.readBoolean()) {
                 final ClusterState incomingState;

+ 2 - 7
server/src/main/java/org/elasticsearch/common/compress/DeflateCompressor.java

@@ -85,7 +85,7 @@ public class DeflateCompressor implements Compressor {
         final Inflater inflater = new Inflater(nowrap);
         InputStream decompressedIn = new InflaterInputStream(in, inflater, BUFFER_SIZE);
         decompressedIn = new BufferedInputStream(decompressedIn, BUFFER_SIZE);
-        final InputStreamStreamInput inputStreamStreamInput = new InputStreamStreamInput(decompressedIn) {
+        return new InputStreamStreamInput(decompressedIn) {
             final AtomicBoolean closed = new AtomicBoolean(false);
 
             public void close() throws IOException {
@@ -99,9 +99,6 @@ public class DeflateCompressor implements Compressor {
                 }
             }
         };
-
-        inputStreamStreamInput.setVersion(in.getVersion());
-        return inputStreamStreamInput;
     }
 
     @Override
@@ -112,7 +109,7 @@ public class DeflateCompressor implements Compressor {
         final boolean syncFlush = true;
         DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(out, deflater, BUFFER_SIZE, syncFlush);
         OutputStream compressedOut = new BufferedOutputStream(deflaterOutputStream, BUFFER_SIZE);
-        final OutputStreamStreamOutput outputStreamStreamOutput = new OutputStreamStreamOutput(compressedOut) {
+        return new OutputStreamStreamOutput(compressedOut) {
             final AtomicBoolean closed = new AtomicBoolean(false);
 
             public void close() throws IOException {
@@ -126,7 +123,5 @@ public class DeflateCompressor implements Compressor {
                 }
             }
         };
-        outputStreamStreamOutput.setVersion(out.getVersion());
-        return outputStreamStreamOutput;
     }
 }

+ 0 - 11
server/src/main/java/org/elasticsearch/common/io/Streams.java

@@ -19,7 +19,6 @@
 
 package org.elasticsearch.common.io;
 
-import org.elasticsearch.Version;
 import org.elasticsearch.common.bytes.BytesReference;
 import org.elasticsearch.common.io.stream.BytesStream;
 import org.elasticsearch.common.io.stream.BytesStreamOutput;
@@ -297,15 +296,5 @@ public abstract class Streams {
         public BytesReference bytes() {
             return delegate.bytes();
         }
-
-        @Override
-        public Version getVersion() {
-            return delegate.getVersion();
-        }
-
-        @Override
-        public void setVersion(Version version) {
-            delegate.setVersion(version);
-        }
     }
 }

+ 2 - 16
server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java

@@ -19,7 +19,6 @@
 package org.elasticsearch.common.settings;
 
 import org.apache.logging.log4j.LogManager;
-import org.elasticsearch.Build;
 import org.elasticsearch.action.admin.cluster.configuration.TransportAddVotingConfigExclusionsAction;
 import org.elasticsearch.action.admin.indices.close.TransportCloseIndexAction;
 import org.elasticsearch.action.search.TransportSearchAction;
@@ -98,7 +97,6 @@ import org.elasticsearch.persistent.decider.EnableAssignmentDecider;
 import org.elasticsearch.plugins.PluginsService;
 import org.elasticsearch.repositories.fs.FsRepository;
 import org.elasticsearch.rest.BaseRestHandler;
-import org.elasticsearch.rest.RestController;
 import org.elasticsearch.script.ScriptService;
 import org.elasticsearch.search.SearchModule;
 import org.elasticsearch.search.SearchService;
@@ -113,7 +111,6 @@ import org.elasticsearch.transport.TransportSettings;
 import org.elasticsearch.watcher.ResourceWatcherService;
 
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 import java.util.function.Predicate;
@@ -183,9 +180,7 @@ public final class ClusterSettings extends AbstractScopedSettings {
         }
     }
 
-    public static final Set<Setting<?>> BUILT_IN_CLUSTER_SETTINGS;
-    static {
-        final Set<Setting<?>> alwaysEnabled = Set.of(
+    public static Set<Setting<?>> BUILT_IN_CLUSTER_SETTINGS = Set.of(
             AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_ATTRIBUTE_SETTING,
             AwarenessAllocationDecider.CLUSTER_ROUTING_ALLOCATION_AWARENESS_FORCE_GROUP_SETTING,
             BalancedShardsAllocator.INDEX_BALANCE_FACTOR_SETTING,
@@ -482,15 +477,6 @@ public final class ClusterSettings extends AbstractScopedSettings {
             HandshakingTransportAddressConnector.PROBE_CONNECT_TIMEOUT_SETTING,
             HandshakingTransportAddressConnector.PROBE_HANDSHAKE_TIMEOUT_SETTING);
 
-        if (Build.CURRENT.isSnapshot()) {
-            Set<Setting<?>> modifiable = new HashSet<>(alwaysEnabled);
-            modifiable.add(RestController.RESTRICT_SYSTEM_INDICES);
-            BUILT_IN_CLUSTER_SETTINGS = Set.copyOf(modifiable);
-        } else {
-            BUILT_IN_CLUSTER_SETTINGS = alwaysEnabled;
-        }
-    }
-
-    static final List<SettingUpgrader<?>> BUILT_IN_SETTING_UPGRADERS = Collections.emptyList();
+    static List<SettingUpgrader<?>> BUILT_IN_SETTING_UPGRADERS = Collections.emptyList();
 
 }

+ 14 - 73
server/src/main/java/org/elasticsearch/common/util/concurrent/ThreadContext.java

@@ -20,10 +20,8 @@ package org.elasticsearch.common.util.concurrent;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
-import org.elasticsearch.Version;
 import org.elasticsearch.action.support.ContextPreservingActionListener;
 import org.elasticsearch.client.OriginSettingClient;
-import org.elasticsearch.common.Nullable;
 import org.elasticsearch.common.collect.Tuple;
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.io.stream.StreamOutput;
@@ -50,7 +48,6 @@ import java.util.function.Supplier;
 import java.util.stream.Collector;
 import java.util.stream.Stream;
 
-import static java.util.Collections.emptyList;
 import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_COUNT;
 import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_MAX_WARNING_HEADER_SIZE;
 
@@ -65,7 +62,7 @@ import static org.elasticsearch.http.HttpTransportSettings.SETTING_HTTP_MAX_WARN
  * Consumers of ThreadContext usually don't need to interact with adding or stashing contexts. Every elasticsearch thread is managed by
  * a thread pool or executor being responsible for stashing and restoring the threads context. For instance if a network request is
  * received, all headers are deserialized from the network and directly added as the headers of the threads {@link ThreadContext}
- * (see {@link #readFrom(StreamInput)}. In order to not modify the context that is currently active on this thread the network code
+ * (see {@link #readHeaders(StreamInput)}. In order to not modify the context that is currently active on this thread the network code
  * uses a try/with pattern to stash it's current context, read headers into a fresh one and once the request is handled or a handler thread
  * is forked (which in turn inherits the context) it restores the previous context. For instance:
  * </p>
@@ -233,18 +230,17 @@ public final class ThreadContext implements Writeable {
     }
 
     /**
-     * Reads the values from the stream into the current context
+     * Reads the headers from the stream into the current context
      */
-    public void readFrom(StreamInput in) throws IOException {
+    public void readHeaders(StreamInput in) throws IOException {
         final Tuple<Map<String, String>, Map<String, Set<String>>> streamTuple = readHeadersFromStream(in);
         final Map<String, String>  requestHeaders = streamTuple.v1();
         final Map<String, Set<String>> responseHeaders = streamTuple.v2();
-        final List<String> allowedSystemIndices = readAllowedSystemIndices(in);
         final ThreadContextStruct struct;
-        if (requestHeaders.isEmpty() && responseHeaders.isEmpty() && allowedSystemIndices.isEmpty()) {
+        if (requestHeaders.isEmpty() && responseHeaders.isEmpty()) {
             struct = ThreadContextStruct.EMPTY;
         } else {
-            struct = new ThreadContextStruct(requestHeaders, responseHeaders, Collections.emptyMap(), allowedSystemIndices, false, 0L);
+            struct = new ThreadContextStruct(requestHeaders, responseHeaders, Collections.emptyMap(), false);
         }
         threadLocal.set(struct);
     }
@@ -271,14 +267,6 @@ public final class ThreadContext implements Writeable {
         return new Tuple<>(requestHeaders, responseHeaders);
     }
 
-    public static List<String> readAllowedSystemIndices(StreamInput in) throws IOException {
-        if (in.getVersion().onOrAfter(Version.V_7_7_0)) {
-            return in.readOptionalStringList();
-        } else {
-            return emptyList();
-        }
-    }
-
     /**
      * Returns the header for the given key or <code>null</code> if not present
      */
@@ -422,36 +410,6 @@ public final class ThreadContext implements Writeable {
         return threadLocal.get().isSystemContext;
     }
 
-    /**
-     * Returns <code>true</code> if a request made within this context can access system indices
-     */
-    public boolean isSystemIndexAccessAllowed() {
-        return threadLocal.get().allowedSystemIndexPatterns != null;
-    }
-
-    /**
-     * Sets the context to disallow access to system indices
-     */
-    public void disallowSystemIndexAccess() {
-        threadLocal.set(threadLocal.get().setAllowSystemIndices(null));
-    }
-
-    /**
-     * Sets the context to allow access to system indices
-     */
-    public void allowSystemIndexAccess(List<String> patterns) {
-        threadLocal.set(threadLocal.get().setAllowSystemIndices(patterns));
-    }
-
-    /**
-     * Returns the list of allowed system index patterns or {@code null} if none are allowed. An
-     * empty list indicates that all system indices are allowed to be accessed.
-     */
-    @Nullable
-    public List<String> allowedSystemIndexPatterns() {
-        return threadLocal.get().allowedSystemIndexPatterns;
-    }
-
     @FunctionalInterface
     public interface StoredContext extends AutoCloseable {
         @Override
@@ -483,7 +441,6 @@ public final class ThreadContext implements Writeable {
         private final Map<String, String> requestHeaders;
         private final Map<String, Object> transientHeaders;
         private final Map<String, Set<String>> responseHeaders;
-        private final List<String> allowedSystemIndexPatterns;
         private final boolean isSystemContext;
         //saving current warning headers' size not to recalculate the size with every new warning header
         private final long warningHeadersSize;
@@ -498,40 +455,29 @@ public final class ThreadContext implements Writeable {
         private ThreadContextStruct(Map<String, String> requestHeaders,
                                     Map<String, Set<String>> responseHeaders,
                                     Map<String, Object> transientHeaders, boolean isSystemContext) {
-            this(requestHeaders, responseHeaders, transientHeaders, emptyList(), isSystemContext, 0L);
+            this.requestHeaders = requestHeaders;
+            this.responseHeaders = responseHeaders;
+            this.transientHeaders = transientHeaders;
+            this.isSystemContext = isSystemContext;
+            this.warningHeadersSize = 0L;
         }
 
         private ThreadContextStruct(Map<String, String> requestHeaders,
                                     Map<String, Set<String>> responseHeaders,
                                     Map<String, Object> transientHeaders, boolean isSystemContext,
                                     long warningHeadersSize) {
-            this(requestHeaders, responseHeaders, transientHeaders, emptyList(), isSystemContext, warningHeadersSize);
-        }
-
-        private ThreadContextStruct(Map<String, String> requestHeaders,
-                                    Map<String, Set<String>> responseHeaders,
-                                    Map<String, Object> transientHeaders,
-                                    List<String> allowedSystemIndexPatterns,
-                                    boolean isSystemContext,
-                                    long warningHeadersSize) {
             this.requestHeaders = requestHeaders;
             this.responseHeaders = responseHeaders;
             this.transientHeaders = transientHeaders;
             this.isSystemContext = isSystemContext;
             this.warningHeadersSize = warningHeadersSize;
-            this.allowedSystemIndexPatterns = allowedSystemIndexPatterns;
         }
 
         /**
          * This represents the default context and it should only ever be called by {@link #DEFAULT_CONTEXT}.
          */
         private ThreadContextStruct() {
-            this(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), emptyList(), false, 0L);
-        }
-
-        private ThreadContextStruct setAllowSystemIndices(List<String> allowedSystemIndexPatterns) {
-            final List<String> copy = allowedSystemIndexPatterns == null ? null : List.copyOf(allowedSystemIndexPatterns);
-            return new ThreadContextStruct(requestHeaders, responseHeaders, transientHeaders, copy, isSystemContext, warningHeadersSize);
+            this(Collections.emptyMap(), Collections.emptyMap(), Collections.emptyMap(), false);
         }
 
         private ThreadContextStruct putRequest(String key, String value) {
@@ -575,8 +521,7 @@ public final class ThreadContext implements Writeable {
                     newResponseHeaders.put(key, entry.getValue());
                 }
             }
-            return new ThreadContextStruct(requestHeaders, newResponseHeaders, transientHeaders, allowedSystemIndexPatterns,
-                isSystemContext, 0L);
+            return new ThreadContextStruct(requestHeaders, newResponseHeaders, transientHeaders, isSystemContext);
         }
 
         private ThreadContextStruct putResponse(final String key, final String value, final Function<String, String> uniqueValue,
@@ -626,8 +571,7 @@ public final class ThreadContext implements Writeable {
                     return this;
                 }
             }
-            return new ThreadContextStruct(requestHeaders, newResponseHeaders, transientHeaders, allowedSystemIndexPatterns,
-                isSystemContext, newWarningHeaderSize);
+            return new ThreadContextStruct(requestHeaders, newResponseHeaders, transientHeaders, isSystemContext, newWarningHeaderSize);
         }
 
 
@@ -663,9 +607,6 @@ public final class ThreadContext implements Writeable {
             }
 
             out.writeMap(responseHeaders, StreamOutput::writeString, StreamOutput::writeStringCollection);
-            if (out.getVersion().onOrAfter(Version.V_7_7_0)) {
-                out.writeOptionalStringCollection(allowedSystemIndexPatterns);
-            }
         }
     }
 
@@ -683,7 +624,7 @@ public final class ThreadContext implements Writeable {
 
         @Override
         public void run() {
-            try (ThreadContext.StoredContext ignore = stashContext()) {
+            try (ThreadContext.StoredContext ignore = stashContext()){
                 ctx.restore();
                 in.run();
             }

+ 2 - 2
server/src/main/java/org/elasticsearch/node/Node.java

@@ -440,7 +440,7 @@ public class Node implements Closeable {
                 .stream()
                 .collect(Collectors.toUnmodifiableMap(
                     plugin -> plugin.getClass().getSimpleName(),
-                    plugin -> plugin.getSystemIndexDescriptors(settings)));
+                    plugin -> plugin.getSystemIndexDescriptors()));
             SystemIndexDescriptor.checkForOverlappingPatterns(systemIndexDescriptorMap);
 
             final List<SystemIndexDescriptor> systemIndexDescriptors = systemIndexDescriptorMap.values().stream()
@@ -476,7 +476,7 @@ public class Node implements Closeable {
 
             ActionModule actionModule = new ActionModule(settings, clusterModule.getIndexNameExpressionResolver(),
                 settingsModule.getIndexScopedSettings(), settingsModule.getClusterSettings(), settingsModule.getSettingsFilter(),
-                threadPool, pluginsService.filterPlugins(ActionPlugin.class), client, circuitBreakerService, usageService);
+                threadPool, pluginsService.filterPlugins(ActionPlugin.class), client, circuitBreakerService, usageService, clusterService);
             modules.add(actionModule);
 
             final RestController restController = actionModule.getRestController();

+ 1 - 3
server/src/main/java/org/elasticsearch/plugins/SystemIndexPlugin.java

@@ -19,7 +19,6 @@
 
 package org.elasticsearch.plugins;
 
-import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.indices.SystemIndexDescriptor;
 
 import java.util.Collection;
@@ -34,10 +33,9 @@ public interface SystemIndexPlugin extends ActionPlugin {
     /**
      * Returns a {@link Collection} of {@link SystemIndexDescriptor}s that describe this plugin's system indices, including
      * name, mapping, and settings.
-     * @param settings The node's settings
      * @return Descriptions of the system indices managed by this plugin.
      */
-    default Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
+    default Collection<SystemIndexDescriptor> getSystemIndexDescriptors() {
         return Collections.emptyList();
     }
 }

+ 0 - 53
server/src/main/java/org/elasticsearch/rest/BaseRestHandler.java

@@ -183,57 +183,4 @@ public abstract class BaseRestHandler implements RestHandler {
         return Collections.emptySet();
     }
 
-    public static class Wrapper extends BaseRestHandler {
-
-        protected final BaseRestHandler delegate;
-
-        public Wrapper(BaseRestHandler delegate) {
-            this.delegate = delegate;
-        }
-
-        @Override
-        public String getName() {
-            return delegate.getName();
-        }
-
-        @Override
-        public List<Route> routes() {
-            return delegate.routes();
-        }
-
-        @Override
-        public List<DeprecatedRoute> deprecatedRoutes() {
-            return delegate.deprecatedRoutes();
-        }
-
-        @Override
-        public List<ReplacedRoute> replacedRoutes() {
-            return delegate.replacedRoutes();
-        }
-
-        @Override
-        protected RestChannelConsumer prepareRequest(RestRequest request, NodeClient client) throws IOException {
-            return delegate.prepareRequest(request, client);
-        }
-
-        @Override
-        protected Set<String> responseParams() {
-            return delegate.responseParams();
-        }
-
-        @Override
-        public boolean canTripCircuitBreaker() {
-            return delegate.canTripCircuitBreaker();
-        }
-
-        @Override
-        public boolean supportsContentStream() {
-            return delegate.supportsContentStream();
-        }
-
-        @Override
-        public boolean allowsUnsafeBuffers() {
-            return delegate.allowsUnsafeBuffers();
-        }
-    }
 }

+ 1 - 16
server/src/main/java/org/elasticsearch/rest/RestController.java

@@ -31,8 +31,6 @@ import org.elasticsearch.common.bytes.BytesArray;
 import org.elasticsearch.common.io.stream.BytesStreamOutput;
 import org.elasticsearch.common.logging.DeprecationLogger;
 import org.elasticsearch.common.path.PathTrie;
-import org.elasticsearch.common.settings.Setting;
-import org.elasticsearch.common.settings.Setting.Property;
 import org.elasticsearch.common.util.concurrent.ThreadContext;
 import org.elasticsearch.common.xcontent.XContentBuilder;
 import org.elasticsearch.common.xcontent.XContentType;
@@ -66,10 +64,6 @@ public class RestController implements HttpServerTransport.Dispatcher {
     private static final Logger logger = LogManager.getLogger(RestController.class);
     private static final DeprecationLogger deprecationLogger = new DeprecationLogger(logger);
 
-    // TODO once we are ready, this should default to true
-    public static final Setting<Boolean> RESTRICT_SYSTEM_INDICES =
-        Setting.boolSetting("rest.restrict_system_indices", false, Property.NodeScope);
-
     private final PathTrie<MethodHandlers> handlers = new PathTrie<>(RestUtils.REST_DECODER);
 
     private final UnaryOperator<RestHandler> handlerWrapper;
@@ -81,10 +75,9 @@ public class RestController implements HttpServerTransport.Dispatcher {
     /** Rest headers that are copied to internal requests made during a rest request. */
     private final Set<RestHeaderDefinition> headersToCopy;
     private final UsageService usageService;
-    private final boolean restrictSystemIndices;
 
     public RestController(Set<RestHeaderDefinition> headersToCopy, UnaryOperator<RestHandler> handlerWrapper,
-            NodeClient client, CircuitBreakerService circuitBreakerService, UsageService usageService, boolean restrictSystemIndices) {
+            NodeClient client, CircuitBreakerService circuitBreakerService, UsageService usageService) {
         this.headersToCopy = headersToCopy;
         this.usageService = usageService;
         if (handlerWrapper == null) {
@@ -93,7 +86,6 @@ public class RestController implements HttpServerTransport.Dispatcher {
         this.handlerWrapper = handlerWrapper;
         this.client = client;
         this.circuitBreakerService = circuitBreakerService;
-        this.restrictSystemIndices = restrictSystemIndices;
     }
 
     /**
@@ -178,13 +170,6 @@ public class RestController implements HttpServerTransport.Dispatcher {
             handleFavicon(request.method(), request.uri(), channel);
             return;
         }
-
-        if (restrictSystemIndices) {
-            threadContext.disallowSystemIndexAccess();
-        } else {
-            assert threadContext.isSystemIndexAccessAllowed();
-        }
-
         try {
             tryAllHandlers(request, channel, threadContext);
         } catch (Exception e) {

+ 19 - 33
server/src/main/java/org/elasticsearch/rest/action/RestCancellableNodeClient.java

@@ -38,7 +38,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicReference;
 
 import static org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskAction.TASKS_ORIGIN;
@@ -86,41 +85,28 @@ public class RestCancellableNodeClient extends FilterClient {
     @Override
     public <Request extends ActionRequest, Response extends ActionResponse> void doExecute(
         ActionType<Response> action, Request request, ActionListener<Response> listener) {
-        final AtomicBoolean created = new AtomicBoolean(false);
-        CloseListener closeListener = httpChannels.computeIfAbsent(httpChannel, channel -> {
-            created.set(true);
-            return new CloseListener();
-        });
+        CloseListener closeListener = httpChannels.computeIfAbsent(httpChannel, channel -> new CloseListener());
         TaskHolder taskHolder = new TaskHolder();
-        final Task task;
-        boolean success = false;
-        try {
-            task = client.executeLocally(action, request,
-                new ActionListener<>() {
-                    @Override
-                    public void onResponse(Response response) {
-                        try {
-                            closeListener.unregisterTask(taskHolder);
-                        } finally {
-                            listener.onResponse(response);
-                        }
+        Task task = client.executeLocally(action, request,
+            new ActionListener<>() {
+                @Override
+                public void onResponse(Response response) {
+                    try {
+                        closeListener.unregisterTask(taskHolder);
+                    } finally {
+                        listener.onResponse(response);
                     }
-
-                    @Override
-                    public void onFailure(Exception e) {
-                        try {
-                            closeListener.unregisterTask(taskHolder);
-                        } finally {
-                            listener.onFailure(e);
-                        }
+                }
+
+                @Override
+                public void onFailure(Exception e) {
+                    try {
+                        closeListener.unregisterTask(taskHolder);
+                    } finally {
+                        listener.onFailure(e);
                     }
-                });
-            success = true;
-        } finally {
-            if (success == false && created.get()) {
-                httpChannels.remove(httpChannel);
-            }
-        }
+                }
+            });
         final TaskId taskId = new TaskId(client.getLocalNodeId(), task.getId());
         closeListener.registerTask(taskHolder, taskId);
         closeListener.maybeRegisterChannel(httpChannel);

+ 5 - 6
server/src/main/java/org/elasticsearch/rest/action/document/RestIndexAction.java

@@ -23,7 +23,7 @@ import org.elasticsearch.Version;
 import org.elasticsearch.action.index.IndexRequest;
 import org.elasticsearch.action.support.ActiveShardCount;
 import org.elasticsearch.client.node.NodeClient;
-import org.elasticsearch.cluster.node.DiscoveryNodes;
+import org.elasticsearch.cluster.service.ClusterService;
 import org.elasticsearch.index.VersionType;
 import org.elasticsearch.rest.BaseRestHandler;
 import org.elasticsearch.rest.RestRequest;
@@ -33,7 +33,6 @@ import org.elasticsearch.rest.action.RestStatusToXContentListener;
 import java.io.IOException;
 import java.util.List;
 import java.util.Locale;
-import java.util.function.Supplier;
 
 import static org.elasticsearch.rest.RestRequest.Method.POST;
 import static org.elasticsearch.rest.RestRequest.Method.PUT;
@@ -82,10 +81,10 @@ public class RestIndexAction extends BaseRestHandler {
 
     public static final class AutoIdHandler extends RestIndexAction {
 
-        private final Supplier<DiscoveryNodes> nodesInCluster;
+        private final ClusterService clusterService;
 
-        public AutoIdHandler(Supplier<DiscoveryNodes> nodesInCluster) {
-            this.nodesInCluster = nodesInCluster;
+        public AutoIdHandler(ClusterService clusterService) {
+            this.clusterService = clusterService;
         }
 
         @Override
@@ -101,7 +100,7 @@ public class RestIndexAction extends BaseRestHandler {
         @Override
         public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient client) throws IOException {
             assert request.params().get("id") == null : "non-null id: " + request.params().get("id");
-            if (request.params().get("op_type") == null && nodesInCluster.get().getMinNodeVersion().onOrAfter(Version.V_7_5_0)) {
+            if (request.params().get("op_type") == null && clusterService.state().nodes().getMinNodeVersion().onOrAfter(Version.V_7_5_0)) {
                 // default to op_type create
                 request.params().put("op_type", "create");
             }

+ 0 - 11
server/src/main/java/org/elasticsearch/transport/CompressibleBytesOutputStream.java

@@ -19,7 +19,6 @@
 
 package org.elasticsearch.transport;
 
-import org.elasticsearch.Version;
 import org.elasticsearch.core.internal.io.IOUtils;
 import org.elasticsearch.common.bytes.BytesReference;
 import org.elasticsearch.common.compress.CompressorFactory;
@@ -103,14 +102,4 @@ final class CompressibleBytesOutputStream extends StreamOutput {
     public void reset() throws IOException {
         throw new UnsupportedOperationException();
     }
-
-    @Override
-    public Version getVersion() {
-        return stream.getVersion();
-    }
-
-    @Override
-    public void setVersion(Version version) {
-        stream.setVersion(version);
-    }
 }

+ 15 - 20
server/src/main/java/org/elasticsearch/transport/InboundMessage.java

@@ -61,8 +61,7 @@ public abstract class InboundMessage extends NetworkMessage implements Closeable
             try (ThreadContext.StoredContext existing = threadContext.stashContext()) {
                 long requestId = streamInput.readLong();
                 byte status = streamInput.readByte();
-                final Version remoteVersion = Version.fromId(streamInput.readInt());
-                streamInput.setVersion(remoteVersion);
+                Version remoteVersion = Version.fromId(streamInput.readInt());
                 final boolean isHandshake = TransportStatus.isHandshake(status);
                 ensureVersionCompatibility(remoteVersion, version, isHandshake);
 
@@ -70,11 +69,10 @@ public abstract class InboundMessage extends NetworkMessage implements Closeable
                     // Consume the variable header size
                     streamInput.readInt();
                 } else {
-                    streamInput = decompressingStream(status, streamInput);
-                    assertRemoteVersion(streamInput, remoteVersion);
+                    streamInput = decompressingStream(status, remoteVersion, streamInput);
                 }
 
-                threadContext.readFrom(streamInput);
+                threadContext.readHeaders(streamInput);
 
                 InboundMessage message;
                 if (TransportStatus.isRequest(status)) {
@@ -85,18 +83,15 @@ public abstract class InboundMessage extends NetworkMessage implements Closeable
                     final String action = streamInput.readString();
 
                     if (remoteVersion.onOrAfter(TcpHeader.VERSION_WITH_HEADER_SIZE)) {
-                        streamInput = decompressingStream(status, streamInput);
-                        assertRemoteVersion(streamInput, remoteVersion);
+                        streamInput = decompressingStream(status, remoteVersion, streamInput);
                     }
-                    streamInput = namedWriteableStream(streamInput);
+                    streamInput = namedWriteableStream(streamInput, remoteVersion);
                     message = new Request(threadContext, remoteVersion, status, requestId, action, streamInput);
                 } else {
                     if (remoteVersion.onOrAfter(TcpHeader.VERSION_WITH_HEADER_SIZE)) {
-                        streamInput = decompressingStream(status, streamInput);
-                        assertRemoteVersion(streamInput, remoteVersion);
+                        streamInput = decompressingStream(status, remoteVersion, streamInput);
                     }
-                    streamInput = namedWriteableStream(streamInput);
-                    assertRemoteVersion(streamInput, remoteVersion);
+                    streamInput = namedWriteableStream(streamInput, remoteVersion);
                     message = new Response(threadContext, remoteVersion, status, requestId, streamInput);
                 }
                 success = true;
@@ -108,10 +103,12 @@ public abstract class InboundMessage extends NetworkMessage implements Closeable
             }
         }
 
-        static StreamInput decompressingStream(byte status, StreamInput streamInput) throws IOException {
+        static StreamInput decompressingStream(byte status, Version remoteVersion, StreamInput streamInput) throws IOException {
             if (TransportStatus.isCompress(status) && streamInput.available() > 0) {
                 try {
-                    return CompressorFactory.COMPRESSOR.streamInput(streamInput);
+                    StreamInput decompressor = CompressorFactory.COMPRESSOR.streamInput(streamInput);
+                    decompressor.setVersion(remoteVersion);
+                    return decompressor;
                 } catch (IllegalArgumentException e) {
                     throw new IllegalStateException("stream marked as compressed, but is missing deflate header");
                 }
@@ -120,12 +117,10 @@ public abstract class InboundMessage extends NetworkMessage implements Closeable
             }
         }
 
-        private StreamInput namedWriteableStream(StreamInput delegate) {
-            return new NamedWriteableAwareStreamInput(delegate, namedWriteableRegistry);
-        }
-
-        static void assertRemoteVersion(StreamInput in, Version version) {
-            assert version.equals(in.getVersion()) : "Stream version [" + in.getVersion() + "] does not match version [" + version + "]";
+        private StreamInput namedWriteableStream(StreamInput delegate, Version remoteVersion) {
+            NamedWriteableAwareStreamInput streamInput = new NamedWriteableAwareStreamInput(delegate, namedWriteableRegistry);
+            streamInput.setVersion(remoteVersion);
+            return streamInput;
         }
     }
 

+ 1 - 2
server/src/main/java/org/elasticsearch/transport/OutboundMessage.java

@@ -55,8 +55,7 @@ abstract class OutboundMessage extends NetworkMessage {
         }
 
         try (CompressibleBytesOutputStream stream = new CompressibleBytesOutputStream(bytesStream, TransportStatus.isCompress(status))) {
-            assert stream.getVersion().equals(version) :
-                "Stream version [" + stream.getVersion() + "] does not match version [" + version + "]";
+            stream.setVersion(version);
             if (variableHeaderLength == -1) {
                 writeVariableHeader(stream);
             }

+ 3 - 13
server/src/main/java/org/elasticsearch/transport/TransportLogger.java

@@ -28,8 +28,6 @@ import org.elasticsearch.core.internal.io.IOUtils;
 
 import java.io.IOException;
 
-import static org.elasticsearch.transport.InboundMessage.Reader.assertRemoteVersion;
-
 public final class TransportLogger {
 
     private static final Logger logger = LogManager.getLogger(TransportLogger.class);
@@ -77,8 +75,7 @@ public final class TransportLogger {
                 final byte status = streamInput.readByte();
                 final boolean isRequest = TransportStatus.isRequest(status);
                 final String type = isRequest ? "request" : "response";
-                final Version version = Version.fromId(streamInput.readInt());
-                streamInput.setVersion(version);
+                Version version = Version.fromId(streamInput.readInt());
                 sb.append(" [length: ").append(messageLengthWithHeader);
                 sb.append(", request id: ").append(requestId);
                 sb.append(", type: ").append(type);
@@ -87,18 +84,11 @@ public final class TransportLogger {
                 if (version.onOrAfter(TcpHeader.VERSION_WITH_HEADER_SIZE)) {
                     sb.append(", header size: ").append(streamInput.readInt()).append('B');
                 } else {
-                    streamInput = InboundMessage.Reader.decompressingStream(status, streamInput);
-                    assertRemoteVersion(streamInput, version);
+                    streamInput = InboundMessage.Reader.decompressingStream(status, version, streamInput);
                 }
 
-                // TODO (jaymode) Need a better way to deal with this. In one aspect,
-                // changes were made to ThreadContext to allocate less internally, yet we have this
-                // ugliness needed to move past the threadcontext data in the stream and discard it
-                // Could we have an alternative that essentially just seeks through the stream with
-                // minimal allocation?
-                // read and discard thread context data
+                // read and discard headers
                 ThreadContext.readHeadersFromStream(streamInput);
-                ThreadContext.readAllowedSystemIndices(streamInput);
 
                 if (isRequest) {
                     if (version.before(Version.V_8_0_0)) {

+ 3 - 3
server/src/test/java/org/elasticsearch/action/ActionModuleTests.java

@@ -109,7 +109,7 @@ public class ActionModuleTests extends ESTestCase {
         UsageService usageService = new UsageService();
         ActionModule actionModule = new ActionModule(settings.getSettings(), new IndexNameExpressionResolver(),
                 settings.getIndexScopedSettings(), settings.getClusterSettings(), settings.getSettingsFilter(), null, emptyList(), null,
-                null, usageService);
+                null, usageService, null);
         actionModule.initRestHandlers(null);
         // At this point the easiest way to confirm that a handler is loaded is to try to register another one on top of it and to fail
         Exception e = expectThrows(IllegalArgumentException.class, () ->
@@ -141,7 +141,7 @@ public class ActionModuleTests extends ESTestCase {
             UsageService usageService = new UsageService();
             ActionModule actionModule = new ActionModule(settings.getSettings(), new IndexNameExpressionResolver(),
                     settings.getIndexScopedSettings(), settings.getClusterSettings(), settings.getSettingsFilter(), threadPool,
-                    singletonList(dupsMainAction), null, null, usageService);
+                    singletonList(dupsMainAction), null, null, usageService, null);
             Exception e = expectThrows(IllegalArgumentException.class, () -> actionModule.initRestHandlers(null));
             assertThat(e.getMessage(), startsWith("Cannot replace existing handler for [/] for method: GET"));
         } finally {
@@ -175,7 +175,7 @@ public class ActionModuleTests extends ESTestCase {
             UsageService usageService = new UsageService();
             ActionModule actionModule = new ActionModule(settings.getSettings(), new IndexNameExpressionResolver(),
                     settings.getIndexScopedSettings(), settings.getClusterSettings(), settings.getSettingsFilter(), threadPool,
-                    singletonList(registersFakeHandler), null, null, usageService);
+                    singletonList(registersFakeHandler), null, null, usageService, null);
             actionModule.initRestHandlers(null);
             // At this point the easiest way to confirm that a handler is loaded is to try to register another one on top of it and to fail
             Exception e = expectThrows(IllegalArgumentException.class, () ->

+ 0 - 7
server/src/test/java/org/elasticsearch/common/compress/DeflateCompressTests.java

@@ -21,13 +21,11 @@ package org.elasticsearch.common.compress;
 
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.TestUtil;
-import org.elasticsearch.Version;
 import org.elasticsearch.common.io.stream.ByteBufferStreamInput;
 import org.elasticsearch.common.io.stream.OutputStreamStreamOutput;
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.io.stream.StreamOutput;
 import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.test.VersionUtils;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -390,12 +388,9 @@ public class DeflateCompressTests extends ESTestCase {
         StreamInput rawIn = new ByteBufferStreamInput(bb);
         Compressor c = compressor;
 
-        final Version version = VersionUtils.randomVersion(random());
         ByteArrayOutputStream bos = new ByteArrayOutputStream();
         OutputStreamStreamOutput rawOs = new OutputStreamStreamOutput(bos);
-        rawOs.setVersion(version);
         StreamOutput os = c.streamOutput(rawOs);
-        assertEquals(version, os.getVersion());
 
         Random r = random();
         int bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(random(), 1, 70000);
@@ -415,9 +410,7 @@ public class DeflateCompressTests extends ESTestCase {
         byte compressed[] = bos.toByteArray();
         ByteBuffer bb2 = ByteBuffer.wrap(compressed);
         StreamInput compressedIn = new ByteBufferStreamInput(bb2);
-        compressedIn.setVersion(version);
         StreamInput in = c.streamInput(compressedIn);
-        assertEquals(version, in.getVersion());
 
         // randomize constants again
         bufferSize = r.nextBoolean() ? 65535 : TestUtil.nextInt(random(), 1, 70000);

+ 3 - 130
server/src/test/java/org/elasticsearch/common/util/concurrent/ThreadContextTests.java

@@ -29,13 +29,9 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.function.Supplier;
-
-import static org.hamcrest.Matchers.empty;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.hasItem;
 import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.nullValue;
 import static org.hamcrest.Matchers.sameInstance;
 
 public class ThreadContextTests extends ESTestCase {
@@ -258,49 +254,6 @@ public class ThreadContextTests extends ESTestCase {
             threadContext.addResponseHeader("Warning", "123456");
         }
         threadContext.addResponseHeader("Warning", "234567");
-        threadContext.disallowSystemIndexAccess();
-
-        BytesStreamOutput out = new BytesStreamOutput();
-        threadContext.writeTo(out);
-        try (ThreadContext.StoredContext ctx = threadContext.stashContext()) {
-            assertNull(threadContext.getHeader("foo"));
-            assertNull(threadContext.getTransient("ctx.foo"));
-            assertTrue(threadContext.getResponseHeaders().isEmpty());
-            assertEquals("1", threadContext.getHeader("default"));
-            assertTrue(threadContext.isSystemIndexAccessAllowed());
-
-            threadContext.readFrom(out.bytes().streamInput());
-            assertEquals("bar", threadContext.getHeader("foo"));
-            assertNull(threadContext.getTransient("ctx.foo"));
-
-            final Map<String, List<String>> responseHeaders = threadContext.getResponseHeaders();
-            final List<String> warnings = responseHeaders.get("Warning");
-
-            assertThat(responseHeaders.keySet(), hasSize(1));
-            assertThat(warnings, hasSize(2));
-            assertThat(warnings, hasItem(equalTo("123456")));
-            assertThat(warnings, hasItem(equalTo("234567")));
-
-            assertFalse(threadContext.isSystemIndexAccessAllowed());
-        }
-        assertEquals("bar", threadContext.getHeader("foo"));
-        assertEquals(Integer.valueOf(1), threadContext.getTransient("ctx.foo"));
-        assertEquals("1", threadContext.getHeader("default"));
-        assertFalse(threadContext.isSystemIndexAccessAllowed());
-    }
-
-    public void testSerializeWithAllowedSystemIndexPatterns() throws IOException {
-        Settings build = Settings.builder().put("request.headers.default", "1").build();
-        ThreadContext threadContext = new ThreadContext(build);
-        threadContext.putHeader("foo", "bar");
-        threadContext.putTransient("ctx.foo", 1);
-        threadContext.addResponseHeader("Warning", "123456");
-        if (rarely()) {
-            threadContext.addResponseHeader("Warning", "123456");
-        }
-        threadContext.addResponseHeader("Warning", "234567");
-        final List<String> allowed = randomList(1, 8, () -> randomAlphaOfLengthBetween(2, 8));
-        threadContext.allowSystemIndexAccess(allowed);
 
         BytesStreamOutput out = new BytesStreamOutput();
         threadContext.writeTo(out);
@@ -309,9 +262,8 @@ public class ThreadContextTests extends ESTestCase {
             assertNull(threadContext.getTransient("ctx.foo"));
             assertTrue(threadContext.getResponseHeaders().isEmpty());
             assertEquals("1", threadContext.getHeader("default"));
-            assertTrue(threadContext.isSystemIndexAccessAllowed());
 
-            threadContext.readFrom(out.bytes().streamInput());
+            threadContext.readHeaders(out.bytes().streamInput());
             assertEquals("bar", threadContext.getHeader("foo"));
             assertNull(threadContext.getTransient("ctx.foo"));
 
@@ -322,15 +274,10 @@ public class ThreadContextTests extends ESTestCase {
             assertThat(warnings, hasSize(2));
             assertThat(warnings, hasItem(equalTo("123456")));
             assertThat(warnings, hasItem(equalTo("234567")));
-
-            assertTrue(threadContext.isSystemIndexAccessAllowed());
-            assertThat(threadContext.allowedSystemIndexPatterns(), equalTo(allowed));
         }
         assertEquals("bar", threadContext.getHeader("foo"));
         assertEquals(Integer.valueOf(1), threadContext.getTransient("ctx.foo"));
         assertEquals("1", threadContext.getHeader("default"));
-        assertTrue(threadContext.isSystemIndexAccessAllowed());
-        assertThat(threadContext.allowedSystemIndexPatterns(), equalTo(allowed));
     }
 
     public void testSerializeInDifferentContext() throws IOException {
@@ -345,63 +292,17 @@ public class ThreadContextTests extends ESTestCase {
                 threadContext.addResponseHeader("Warning", "123456");
             }
             threadContext.addResponseHeader("Warning", "234567");
-            threadContext.disallowSystemIndexAccess();
-
-            assertEquals("bar", threadContext.getHeader("foo"));
-            assertNotNull(threadContext.getTransient("ctx.foo"));
-            assertEquals("1", threadContext.getHeader("default"));
-            assertThat(threadContext.getResponseHeaders().keySet(), hasSize(1));
-            assertFalse(threadContext.isSystemIndexAccessAllowed());
-            threadContext.writeTo(out);
-        }
-        {
-            Settings otherSettings = Settings.builder().put("request.headers.default", "5").build();
-            ThreadContext otherThreadContext = new ThreadContext(otherSettings);
-            otherThreadContext.readFrom(out.bytes().streamInput());
-
-            assertEquals("bar", otherThreadContext.getHeader("foo"));
-            assertNull(otherThreadContext.getTransient("ctx.foo"));
-            assertEquals("1", otherThreadContext.getHeader("default"));
-
-            final Map<String, List<String>> responseHeaders = otherThreadContext.getResponseHeaders();
-            final List<String> warnings = responseHeaders.get("Warning");
-
-            assertThat(responseHeaders.keySet(), hasSize(1));
-            assertThat(warnings, hasSize(2));
-            assertThat(warnings, hasItem(equalTo("123456")));
-            assertThat(warnings, hasItem(equalTo("234567")));
-
-            assertFalse(otherThreadContext.isSystemIndexAccessAllowed());
-        }
-    }
-
-    public void testSerializeInDifferentContextWithAllowedSystemIndices() throws IOException {
-        final List<String> allowed = randomList(1, 8, () -> randomAlphaOfLengthBetween(2, 8));
-        BytesStreamOutput out = new BytesStreamOutput();
-        {
-            Settings build = Settings.builder().put("request.headers.default", "1").build();
-            ThreadContext threadContext = new ThreadContext(build);
-            threadContext.putHeader("foo", "bar");
-            threadContext.putTransient("ctx.foo", 1);
-            threadContext.addResponseHeader("Warning", "123456");
-            if (rarely()) {
-                threadContext.addResponseHeader("Warning", "123456");
-            }
-            threadContext.addResponseHeader("Warning", "234567");
-            threadContext.allowSystemIndexAccess(allowed);
 
             assertEquals("bar", threadContext.getHeader("foo"));
             assertNotNull(threadContext.getTransient("ctx.foo"));
             assertEquals("1", threadContext.getHeader("default"));
             assertThat(threadContext.getResponseHeaders().keySet(), hasSize(1));
-            assertTrue(threadContext.isSystemIndexAccessAllowed());
-            assertThat(threadContext.allowedSystemIndexPatterns(), equalTo(allowed));
             threadContext.writeTo(out);
         }
         {
             Settings otherSettings = Settings.builder().put("request.headers.default", "5").build();
             ThreadContext otherThreadContext = new ThreadContext(otherSettings);
-            otherThreadContext.readFrom(out.bytes().streamInput());
+            otherThreadContext.readHeaders(out.bytes().streamInput());
 
             assertEquals("bar", otherThreadContext.getHeader("foo"));
             assertNull(otherThreadContext.getTransient("ctx.foo"));
@@ -414,9 +315,6 @@ public class ThreadContextTests extends ESTestCase {
             assertThat(warnings, hasSize(2));
             assertThat(warnings, hasItem(equalTo("123456")));
             assertThat(warnings, hasItem(equalTo("234567")));
-
-            assertTrue(otherThreadContext.isSystemIndexAccessAllowed());
-            assertThat(otherThreadContext.allowedSystemIndexPatterns(), equalTo(allowed));
         }
     }
 
@@ -435,7 +333,7 @@ public class ThreadContextTests extends ESTestCase {
         {
             Settings otherSettings = Settings.builder().put("request.headers.default", "5").build();
             ThreadContext otherhreadContext = new ThreadContext(otherSettings);
-            otherhreadContext.readFrom(out.bytes().streamInput());
+            otherhreadContext.readHeaders(out.bytes().streamInput());
 
             assertEquals("bar", otherhreadContext.getHeader("foo"));
             assertNull(otherhreadContext.getTransient("ctx.foo"));
@@ -715,31 +613,6 @@ public class ThreadContextTests extends ESTestCase {
         assertEquals("value for key [foo] already present", e.getMessage());
     }
 
-    public void testSystemIndexAccessAllowed() {
-        ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
-        assertTrue(threadContext.isSystemIndexAccessAllowed());
-        assertThat(threadContext.allowedSystemIndexPatterns(), empty());
-        try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
-            assertTrue(threadContext.isSystemIndexAccessAllowed());
-            threadContext.disallowSystemIndexAccess();
-            assertFalse(threadContext.isSystemIndexAccessAllowed());
-            assertThat(threadContext.allowedSystemIndexPatterns(), nullValue());
-        }
-        assertTrue(threadContext.isSystemIndexAccessAllowed());
-        assertThat(threadContext.allowedSystemIndexPatterns(), empty());
-
-        try (ThreadContext.StoredContext ignore = threadContext.stashContext()) {
-            threadContext.disallowSystemIndexAccess();
-            final List<String> allowed = randomList(1, 8, () -> randomAlphaOfLengthBetween(2, 8));
-            threadContext.allowSystemIndexAccess(allowed);
-            assertTrue(threadContext.isSystemIndexAccessAllowed());
-            assertThat(threadContext.allowedSystemIndexPatterns(), not(sameInstance(allowed)));
-            assertThat(threadContext.allowedSystemIndexPatterns(), equalTo(allowed));
-        }
-        assertTrue(threadContext.isSystemIndexAccessAllowed());
-        assertThat(threadContext.allowedSystemIndexPatterns(), empty());
-    }
-
     /**
      * Sometimes wraps a Runnable in an AbstractRunnable.
      */

+ 7 - 26
server/src/test/java/org/elasticsearch/rest/RestControllerTests.java

@@ -91,7 +91,7 @@ public class RestControllerTests extends ESTestCase {
         inFlightRequestsBreaker = circuitBreakerService.getBreaker(CircuitBreaker.IN_FLIGHT_REQUESTS);
 
         HttpServerTransport httpServerTransport = new TestHttpServerTransport();
-        restController = new RestController(Collections.emptySet(), null, null, circuitBreakerService, usageService, randomBoolean());
+        restController = new RestController(Collections.emptySet(), null, null, circuitBreakerService, usageService);
         restController.registerHandler(RestRequest.Method.GET, "/",
             (request, channel, client) -> channel.sendResponse(
                 new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY)));
@@ -106,7 +106,7 @@ public class RestControllerTests extends ESTestCase {
         final ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
         Set<RestHeaderDefinition> headers = new HashSet<>(Arrays.asList(new RestHeaderDefinition("header.1", true),
             new RestHeaderDefinition("header.2", true)));
-        final RestController restController = new RestController(headers, null, null, circuitBreakerService, usageService, randomBoolean());
+        final RestController restController = new RestController(headers, null, null, circuitBreakerService, usageService);
         Map<String, List<String>> restHeaders = new HashMap<>();
         restHeaders.put("header.1", Collections.singletonList("true"));
         restHeaders.put("header.2", Collections.singletonList("true"));
@@ -142,7 +142,7 @@ public class RestControllerTests extends ESTestCase {
         final ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
         Set<RestHeaderDefinition> headers = new HashSet<>(Arrays.asList(new RestHeaderDefinition("header.1", true),
             new RestHeaderDefinition("header.2", false)));
-        final RestController restController = new RestController(headers, null, null, circuitBreakerService, usageService, randomBoolean());
+        final RestController restController = new RestController(headers, null, null, circuitBreakerService, usageService);
         Map<String, List<String>> restHeaders = new HashMap<>();
         restHeaders.put("header.1", Collections.singletonList("boo"));
         restHeaders.put("header.2", List.of("foo", "bar"));
@@ -156,7 +156,7 @@ public class RestControllerTests extends ESTestCase {
         final ThreadContext threadContext = new ThreadContext(Settings.EMPTY);
         Set<RestHeaderDefinition> headers = new HashSet<>(Arrays.asList(new RestHeaderDefinition("header.1", true),
             new RestHeaderDefinition("header.2", false)));
-        final RestController restController = new RestController(headers, null, null, circuitBreakerService, usageService, randomBoolean());
+        final RestController restController = new RestController(headers, null, null, circuitBreakerService, usageService);
         Map<String, List<String>> restHeaders = new HashMap<>();
         restHeaders.put("header.1", Collections.singletonList("boo"));
         restHeaders.put("header.2", List.of("foo", "foo"));
@@ -210,7 +210,7 @@ public class RestControllerTests extends ESTestCase {
     }
 
     public void testRegisterSecondMethodWithDifferentNamedWildcard() {
-        final RestController restController = new RestController(null, null, null, circuitBreakerService, usageService, randomBoolean());
+        final RestController restController = new RestController(null, null, null, circuitBreakerService, usageService);
 
         RestRequest.Method firstMethod = randomFrom(RestRequest.Method.values());
         RestRequest.Method secondMethod =
@@ -237,7 +237,7 @@ public class RestControllerTests extends ESTestCase {
                 h -> {
                     assertSame(handler, h);
                     return (RestRequest request, RestChannel channel, NodeClient client) -> wrapperCalled.set(true);
-                }, null, circuitBreakerService, usageService, randomBoolean());
+                }, null, circuitBreakerService, usageService);
         restController.registerHandler(RestRequest.Method.GET, "/wrapped", handler);
         RestRequest request = testRestRequest("/wrapped", "{}", XContentType.JSON);
         AssertingChannel channel = new AssertingChannel(request, true, RestStatus.BAD_REQUEST);
@@ -300,7 +300,7 @@ public class RestControllerTests extends ESTestCase {
         String content = randomAlphaOfLength((int) Math.round(BREAKER_LIMIT.getBytes() / inFlightRequestsBreaker.getOverhead()));
         RestRequest request = testRestRequest("/", content, null);
         AssertingChannel channel = new AssertingChannel(request, true, RestStatus.NOT_ACCEPTABLE);
-        restController = new RestController(Collections.emptySet(), null, null, circuitBreakerService, usageService, randomBoolean());
+        restController = new RestController(Collections.emptySet(), null, null, circuitBreakerService, usageService);
         restController.registerHandler(RestRequest.Method.GET, "/",
             (r, c, client) -> c.sendResponse(
                 new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY)));
@@ -603,25 +603,6 @@ public class RestControllerTests extends ESTestCase {
         assertThat(channel.getRestResponse().getHeaders().get("Allow"), hasItem(equalTo(RestRequest.Method.GET.toString())));
     }
 
-    public void testDispatchRestrictSystemIndices() {
-        restController = new RestController(Collections.emptySet(), null, null, circuitBreakerService, usageService, true);
-        restController.registerHandler(RestRequest.Method.GET, "/",
-            (request, channel, client) -> channel.sendResponse(
-                new BytesRestResponse(RestStatus.OK, BytesRestResponse.TEXT_CONTENT_TYPE, BytesArray.EMPTY)));
-        restController.registerHandler(RestRequest.Method.GET, "/error", (request, channel, client) -> {
-            throw new IllegalArgumentException("test error");
-        });
-
-        FakeRestRequest fakeRestRequest = new FakeRestRequest.Builder(NamedXContentRegistry.EMPTY).build();
-        AssertingChannel channel = new AssertingChannel(fakeRestRequest, true, RestStatus.OK);
-
-        assertFalse(channel.getSendResponseCalled());
-        ThreadContext context = new ThreadContext(Settings.EMPTY);
-        assertTrue(context.isSystemIndexAccessAllowed());
-        restController.dispatchRequest(fakeRestRequest, channel, context);
-        assertTrue(channel.getSendResponseCalled());
-        assertFalse(context.isSystemIndexAccessAllowed());
-    }
 
     private static final class TestHttpServerTransport extends AbstractLifecycleComponent implements
         HttpServerTransport {

+ 1 - 1
server/src/test/java/org/elasticsearch/rest/RestHttpResponseHeadersTests.java

@@ -89,7 +89,7 @@ public class RestHttpResponseHeadersTests extends ESTestCase {
         final Settings settings = Settings.EMPTY;
         UsageService usageService = new UsageService();
         RestController restController = new RestController(Collections.emptySet(),
-                null, null, circuitBreakerService, usageService, randomBoolean());
+                null, null, circuitBreakerService, usageService);
 
         // A basic RestHandler handles requests to the endpoint
         RestHandler restHandler = new RestHandler() {

+ 1 - 1
server/src/test/java/org/elasticsearch/rest/action/admin/indices/RestValidateQueryActionTests.java

@@ -58,7 +58,7 @@ public class RestValidateQueryActionTests extends AbstractSearchTestCase {
 
     private static UsageService usageService = new UsageService();
     private static RestController controller = new RestController(emptySet(), null, client,
-        new NoneCircuitBreakerService(), usageService, false);
+        new NoneCircuitBreakerService(), usageService);
     private static RestValidateQueryAction action = new RestValidateQueryAction();
 
     /**

+ 1 - 1
server/src/test/java/org/elasticsearch/rest/action/cat/RestCatRecoveryActionTests.java

@@ -56,7 +56,7 @@ public class RestCatRecoveryActionTests extends ESTestCase {
     public void testRestRecoveryAction() {
         final Settings settings = Settings.EMPTY;
         UsageService usageService = new UsageService();
-        final RestController restController = new RestController(Collections.emptySet(), null, null, null, usageService, randomBoolean());
+        final RestController restController = new RestController(Collections.emptySet(), null, null, null, usageService);
         final RestCatRecoveryAction action = new RestCatRecoveryAction();
         restController.registerHandler(action);
         final int totalShards = randomIntBetween(1, 32);

+ 1 - 2
server/src/test/java/org/elasticsearch/rest/action/cat/RestIndicesActionTests.java

@@ -127,8 +127,7 @@ public class RestIndicesActionTests extends ESTestCase {
             }
         }
 
-        final RestController restController =
-            new RestController(Collections.emptySet(), null, null, null, new UsageService(), randomBoolean());
+        final RestController restController = new RestController(Collections.emptySet(), null, null, null, new UsageService());
         final RestIndicesAction action = new RestIndicesAction();
         restController.registerHandler(action);
         final Table table = action.buildTable(new FakeRestRequest(), indicesSettings, indicesHealths, indicesStats, indicesMetaDatas);

+ 6 - 1
server/src/test/java/org/elasticsearch/rest/action/document/RestIndexActionTests.java

@@ -27,6 +27,7 @@ import org.elasticsearch.cluster.ClusterName;
 import org.elasticsearch.cluster.ClusterState;
 import org.elasticsearch.cluster.node.DiscoveryNode;
 import org.elasticsearch.cluster.node.DiscoveryNodes;
+import org.elasticsearch.cluster.service.ClusterService;
 import org.elasticsearch.common.bytes.BytesArray;
 import org.elasticsearch.common.xcontent.XContentType;
 import org.elasticsearch.rest.RestRequest;
@@ -42,7 +43,9 @@ import java.util.concurrent.atomic.AtomicReference;
 
 import static org.hamcrest.Matchers.equalTo;
 import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
 
 public class RestIndexActionTests extends RestActionTestCase {
 
@@ -50,9 +53,11 @@ public class RestIndexActionTests extends RestActionTestCase {
 
     @Before
     public void setUpAction() {
+        ClusterService clusterService = mock(ClusterService.class);
+        when(clusterService.state()).thenAnswer(invocationOnMock -> clusterStateSupplier.get());
         controller().registerHandler(new RestIndexAction());
         controller().registerHandler(new CreateHandler());
-        controller().registerHandler(new AutoIdHandler(() -> clusterStateSupplier.get().nodes()));
+        controller().registerHandler(new AutoIdHandler(clusterService));
     }
 
     public void testCreateOpTypeValidation() {

+ 0 - 13
server/src/test/java/org/elasticsearch/transport/CompressibleBytesOutputStreamTests.java

@@ -25,7 +25,6 @@ import org.elasticsearch.common.io.stream.BytesStream;
 import org.elasticsearch.common.io.stream.BytesStreamOutput;
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.test.ESTestCase;
-import org.elasticsearch.test.VersionUtils;
 
 import java.io.EOFException;
 import java.io.IOException;
@@ -34,11 +33,7 @@ public class CompressibleBytesOutputStreamTests extends ESTestCase {
 
     public void testStreamWithoutCompression() throws IOException {
         BytesStream bStream = new ZeroOutOnCloseStream();
-        if (randomBoolean()) {
-            bStream.setVersion(VersionUtils.randomVersion(random()));
-        }
         CompressibleBytesOutputStream stream = new CompressibleBytesOutputStream(bStream, false);
-        assertEquals(bStream.getVersion(), stream.getVersion());
 
         byte[] expectedBytes = randomBytes(randomInt(30));
         stream.write(expectedBytes);
@@ -66,11 +61,7 @@ public class CompressibleBytesOutputStreamTests extends ESTestCase {
 
     public void testStreamWithCompression() throws IOException {
         BytesStream bStream = new ZeroOutOnCloseStream();
-        if (randomBoolean()) {
-            bStream.setVersion(VersionUtils.randomVersion(random()));
-        }
         CompressibleBytesOutputStream stream = new CompressibleBytesOutputStream(bStream, true);
-        assertEquals(bStream.getVersion(), stream.getVersion());
 
         byte[] expectedBytes = randomBytes(randomInt(30));
         stream.write(expectedBytes);
@@ -97,11 +88,7 @@ public class CompressibleBytesOutputStreamTests extends ESTestCase {
 
     public void testCompressionWithCallingMaterializeFails() throws IOException {
         BytesStream bStream = new ZeroOutOnCloseStream();
-        if (randomBoolean()) {
-            bStream.setVersion(VersionUtils.randomVersion(random()));
-        }
         CompressibleBytesOutputStream stream = new CompressibleBytesOutputStream(bStream, true);
-        assertEquals(bStream.getVersion(), stream.getVersion());
 
         byte[] expectedBytes = randomBytes(between(1, 30));
         stream.write(expectedBytes);

+ 1 - 1
test/framework/src/main/java/org/elasticsearch/test/rest/RestActionTestCase.java

@@ -47,7 +47,7 @@ public abstract class RestActionTestCase extends ESTestCase {
         controller = new RestController(Collections.emptySet(), null,
             nodeClient,
             new NoneCircuitBreakerService(),
-            new UsageService(), randomBoolean());
+            new UsageService());
     }
 
     /**

+ 6 - 6
test/framework/src/main/java/org/elasticsearch/transport/AbstractSimpleTransportTestCase.java

@@ -2378,15 +2378,15 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
                 assertEquals(1, transportStats.getRxCount());
                 assertEquals(2, transportStats.getTxCount());
                 assertEquals(25, transportStats.getRxSize().getBytes());
-                assertEquals(113, transportStats.getTxSize().getBytes());
+                assertEquals(111, transportStats.getTxSize().getBytes());
             });
             sendResponseLatch.countDown();
             responseLatch.await();
             stats = serviceC.transport.getStats(); // response has been received
             assertEquals(2, stats.getRxCount());
             assertEquals(2, stats.getTxCount());
-            assertEquals(52, stats.getRxSize().getBytes());
-            assertEquals(113, stats.getTxSize().getBytes());
+            assertEquals(50, stats.getRxSize().getBytes());
+            assertEquals(111, stats.getTxSize().getBytes());
         } finally {
             serviceC.close();
         }
@@ -2493,7 +2493,7 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
                 assertEquals(1, transportStats.getRxCount());
                 assertEquals(2, transportStats.getTxCount());
                 assertEquals(25, transportStats.getRxSize().getBytes());
-                assertEquals(113, transportStats.getTxSize().getBytes());
+                assertEquals(111, transportStats.getTxSize().getBytes());
             });
             sendResponseLatch.countDown();
             responseLatch.await();
@@ -2507,8 +2507,8 @@ public abstract class AbstractSimpleTransportTestCase extends ESTestCase {
             String failedMessage = "Unexpected read bytes size. The transport exception that was received=" + exception;
             // 49 bytes are the non-exception message bytes that have been received. It should include the initial
             // handshake message and the header, version, etc bytes in the exception message.
-            assertEquals(failedMessage, 55 + streamOutput.bytes().length(), stats.getRxSize().getBytes());
-            assertEquals(113, stats.getTxSize().getBytes());
+            assertEquals(failedMessage, 53 + streamOutput.bytes().length(), stats.getRxSize().getBytes());
+            assertEquals(111, stats.getTxSize().getBytes());
         } finally {
             serviceC.close();
         }

+ 1 - 1
x-pack/plugin/enrich/src/main/java/org/elasticsearch/xpack/enrich/EnrichPlugin.java

@@ -246,7 +246,7 @@ public class EnrichPlugin extends Plugin implements SystemIndexPlugin, IngestPlu
     }
 
     @Override
-    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
+    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors() {
         return Collections.singletonList(
             new SystemIndexDescriptor(ENRICH_INDEX_PATTERN, "Contains data to support enrich ingest processors.")
         );

+ 1 - 2
x-pack/plugin/logstash/src/main/java/org/elasticsearch/xpack/logstash/Logstash.java

@@ -10,7 +10,6 @@ import org.elasticsearch.Version;
 import org.elasticsearch.action.ActionRequest;
 import org.elasticsearch.action.ActionResponse;
 import org.elasticsearch.cluster.metadata.IndexTemplateMetaData;
-import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.indices.SystemIndexDescriptor;
 import org.elasticsearch.plugins.Plugin;
 import org.elasticsearch.plugins.SystemIndexPlugin;
@@ -63,7 +62,7 @@ public class Logstash extends Plugin implements SystemIndexPlugin {
     }
 
     @Override
-    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
+    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors() {
         return Collections.singletonList(
             new SystemIndexDescriptor(LOGSTASH_CONCRETE_INDEX_NAME, "Contains data for Logstash Central Management")
         );

+ 1 - 1
x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/MachineLearning.java

@@ -982,7 +982,7 @@ public class MachineLearning extends Plugin implements SystemIndexPlugin, Analys
     }
 
     @Override
-    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
+    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors() {
         return List.of(
             new SystemIndexDescriptor(MlMetaIndex.INDEX_NAME, "Contains scheduling and anomaly tracking metadata"),
             new SystemIndexDescriptor(AnomalyDetectorsIndexFields.CONFIG_INDEX, "Contains ML configuration data"),

+ 1 - 1
x-pack/plugin/security/src/main/java/org/elasticsearch/xpack/security/Security.java

@@ -1088,7 +1088,7 @@ public class Security extends Plugin implements SystemIndexPlugin, IngestPlugin,
     }
 
     @Override
-    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
+    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors() {
         return List.of(
             new SystemIndexDescriptor(SECURITY_MAIN_ALIAS, "Contains Security configuration"),
             new SystemIndexDescriptor(RestrictedIndicesNames.INTERNAL_SECURITY_MAIN_INDEX_6, "Contains Security configuration"),

+ 1 - 1
x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authc/AuthenticationServiceTests.java

@@ -725,7 +725,7 @@ public class AuthenticationServiceTests extends ESTestCase {
                 threadContext2.writeTo(output);
                 StreamInput input = output.bytes().streamInput();
                 threadContext2 = new ThreadContext(Settings.EMPTY);
-                threadContext2.readFrom(input);
+                threadContext2.readHeaders(input);
                 header = threadContext2.getHeader(AuthenticationField.AUTHENTICATION_KEY);
             }
 

+ 1 - 1
x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/Transform.java

@@ -393,7 +393,7 @@ public class Transform extends Plugin implements SystemIndexPlugin, PersistentTa
     }
 
     @Override
-    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
+    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors() {
         return Collections.singletonList(
             new SystemIndexDescriptor(TransformInternalIndexConstants.INDEX_NAME_PATTERN, "Contains Transform configuration data")
         );

+ 1 - 1
x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/Watcher.java

@@ -690,7 +690,7 @@ public class Watcher extends Plugin implements SystemIndexPlugin, ScriptPlugin,
     }
 
     @Override
-    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors(Settings settings) {
+    public Collection<SystemIndexDescriptor> getSystemIndexDescriptors() {
         return List.of(
             new SystemIndexDescriptor(Watch.INDEX, "Contains Watch definitions"),
             new SystemIndexDescriptor(TriggeredWatchStoreField.INDEX_NAME, "Used to track current and queued Watch execution")