Browse Source

Revert "[ML] Use a new annotations index for future annotations (#79006)"

This reverts commit 0af4fe24ece174d5eaf5001b6ed9063dc25dc851.
David Roberts 4 years ago
parent
commit
b4bcb86ff3

+ 12 - 34
x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/annotations/AnnotationIndex.java

@@ -15,7 +15,6 @@ import org.elasticsearch.action.ActionListener;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse;
 import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
 import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
-import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequestBuilder;
 import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
 import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
 import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
 import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
 import org.elasticsearch.action.support.master.AcknowledgedResponse;
 import org.elasticsearch.action.support.master.AcknowledgedResponse;
@@ -31,7 +30,6 @@ import org.elasticsearch.xpack.core.ml.job.persistence.ElasticsearchMappings;
 import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
 import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper;
 import org.elasticsearch.xpack.core.template.TemplateUtils;
 import org.elasticsearch.xpack.core.template.TemplateUtils;
 
 
-import java.util.List;
 import java.util.SortedMap;
 import java.util.SortedMap;
 
 
 import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
 import static org.elasticsearch.xpack.core.ClientHelper.ML_ORIGIN;
@@ -43,15 +41,8 @@ public class AnnotationIndex {
 
 
     public static final String READ_ALIAS_NAME = ".ml-annotations-read";
     public static final String READ_ALIAS_NAME = ".ml-annotations-read";
     public static final String WRITE_ALIAS_NAME = ".ml-annotations-write";
     public static final String WRITE_ALIAS_NAME = ".ml-annotations-write";
-
-    // Exposed for testing, but always use the aliases in non-test code.
-    public static final String LATEST_INDEX_NAME = ".ml-annotations-000001";
-    // Due to historical bugs this index may not have the correct mappings
-    // in some production clusters. Therefore new annotations should be
-    // written to the latest index. If we ever switch to another new annotations
-    // index then this list should be adjusted to include the previous latest
-    // index.
-    public static final List<String> OLD_INDEX_NAMES = List.of(".ml-annotations-6");
+    // Exposed for testing, but always use the aliases in non-test code
+    public static final String INDEX_NAME = ".ml-annotations-6";
 
 
     private static final String MAPPINGS_VERSION_VARIABLE = "xpack.ml.version";
     private static final String MAPPINGS_VERSION_VARIABLE = "xpack.ml.version";
 
 
@@ -94,18 +85,12 @@ public class AnnotationIndex {
             finalListener::onFailure);
             finalListener::onFailure);
 
 
         final ActionListener<Boolean> createAliasListener = ActionListener.wrap(success -> {
         final ActionListener<Boolean> createAliasListener = ActionListener.wrap(success -> {
-            final IndicesAliasesRequestBuilder requestBuilder =
+            final IndicesAliasesRequest request =
                 client.admin().indices().prepareAliases()
                 client.admin().indices().prepareAliases()
-                    .addAliasAction(IndicesAliasesRequest.AliasActions.add()
-                        .index(LATEST_INDEX_NAME).alias(READ_ALIAS_NAME).isHidden(true))
-                    .addAliasAction(IndicesAliasesRequest.AliasActions.add()
-                        .index(LATEST_INDEX_NAME).alias(WRITE_ALIAS_NAME).isHidden(true));
-            for (String oldIndexName : OLD_INDEX_NAMES) {
-                if (state.getMetadata().getIndicesLookup().containsKey(oldIndexName)) {
-                    requestBuilder.removeAlias(oldIndexName, WRITE_ALIAS_NAME);
-                }
-            }
-            executeAsyncWithOrigin(client.threadPool().getThreadContext(), ML_ORIGIN, requestBuilder.request(),
+                    .addAliasAction(IndicesAliasesRequest.AliasActions.add().index(INDEX_NAME).alias(READ_ALIAS_NAME).isHidden(true))
+                    .addAliasAction(IndicesAliasesRequest.AliasActions.add().index(INDEX_NAME).alias(WRITE_ALIAS_NAME).isHidden(true))
+                    .request();
+            executeAsyncWithOrigin(client.threadPool().getThreadContext(), ML_ORIGIN, request,
                 ActionListener.<AcknowledgedResponse>wrap(
                 ActionListener.<AcknowledgedResponse>wrap(
                     r -> checkMappingsListener.onResponse(r.isAcknowledged()), finalListener::onFailure),
                     r -> checkMappingsListener.onResponse(r.isAcknowledged()), finalListener::onFailure),
                 client.admin().indices()::aliases);
                 client.admin().indices()::aliases);
@@ -119,18 +104,18 @@ public class AnnotationIndex {
             mlLookup.isEmpty() == false && mlLookup.firstKey().startsWith(".ml")) {
             mlLookup.isEmpty() == false && mlLookup.firstKey().startsWith(".ml")) {
 
 
             // Create the annotations index if it doesn't exist already.
             // Create the annotations index if it doesn't exist already.
-            if (mlLookup.containsKey(LATEST_INDEX_NAME) == false) {
+            if (mlLookup.containsKey(INDEX_NAME) == false) {
                 logger.debug(
                 logger.debug(
                     () -> new ParameterizedMessage(
                     () -> new ParameterizedMessage(
                         "Creating [{}] because [{}] exists; trace {}",
                         "Creating [{}] because [{}] exists; trace {}",
-                        LATEST_INDEX_NAME,
+                        INDEX_NAME,
                         mlLookup.firstKey(),
                         mlLookup.firstKey(),
                         org.elasticsearch.ExceptionsHelper.formatStackTrace(Thread.currentThread().getStackTrace())
                         org.elasticsearch.ExceptionsHelper.formatStackTrace(Thread.currentThread().getStackTrace())
                     )
                     )
                 );
                 );
 
 
                 CreateIndexRequest createIndexRequest =
                 CreateIndexRequest createIndexRequest =
-                    new CreateIndexRequest(LATEST_INDEX_NAME)
+                    new CreateIndexRequest(INDEX_NAME)
                         .mapping(annotationsMapping())
                         .mapping(annotationsMapping())
                         .settings(Settings.builder()
                         .settings(Settings.builder()
                             .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
                             .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
@@ -155,14 +140,7 @@ public class AnnotationIndex {
             }
             }
 
 
             // Recreate the aliases if they've gone even though the index still exists.
             // Recreate the aliases if they've gone even though the index still exists.
-            IndexAbstraction writeAliasDefinition = mlLookup.get(WRITE_ALIAS_NAME);
-            if (mlLookup.containsKey(READ_ALIAS_NAME) == false || writeAliasDefinition == null) {
-                createAliasListener.onResponse(true);
-                return;
-            }
-
-            List<IndexMetadata> writeAliasMetadata = writeAliasDefinition.getIndices();
-            if (writeAliasMetadata.size() != 1 || LATEST_INDEX_NAME.equals(writeAliasMetadata.get(0).getIndex().getName()) == false) {
+            if (mlLookup.containsKey(READ_ALIAS_NAME) == false || mlLookup.containsKey(WRITE_ALIAS_NAME) == false) {
                 createAliasListener.onResponse(true);
                 createAliasListener.onResponse(true);
                 return;
                 return;
             }
             }
@@ -176,7 +154,7 @@ public class AnnotationIndex {
         finalListener.onResponse(false);
         finalListener.onResponse(false);
     }
     }
 
 
-    public static String annotationsMapping() {
+    private static String annotationsMapping() {
         return TemplateUtils.loadTemplate(
         return TemplateUtils.loadTemplate(
             "/org/elasticsearch/xpack/core/ml/annotations_index_mappings.json", Version.CURRENT.toString(), MAPPINGS_VERSION_VARIABLE);
             "/org/elasticsearch/xpack/core/ml/annotations_index_mappings.json", Version.CURRENT.toString(), MAPPINGS_VERSION_VARIABLE);
     }
     }

+ 0 - 1
x-pack/plugin/core/src/main/resources/org/elasticsearch/xpack/core/ml/annotations_index_mappings.json

@@ -3,7 +3,6 @@
     "_meta" : {
     "_meta" : {
       "version" : "${xpack.ml.version}"
       "version" : "${xpack.ml.version}"
     },
     },
-    "dynamic" : false,
     "properties" : {
     "properties" : {
       "annotation" : {
       "annotation" : {
         "type" : "text"
         "type" : "text"

+ 2 - 2
x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/security/authz/store/ReservedRolesStoreTests.java

@@ -1479,7 +1479,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
         assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX);
         assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX);
         assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT);
         assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT);
         assertOnlyReadAllowed(role, NotificationsIndex.NOTIFICATIONS_INDEX);
         assertOnlyReadAllowed(role, NotificationsIndex.NOTIFICATIONS_INDEX);
-        assertReadWriteDocsButNotDeleteIndexAllowed(role, AnnotationIndex.LATEST_INDEX_NAME);
+        assertReadWriteDocsButNotDeleteIndexAllowed(role, AnnotationIndex.INDEX_NAME);
 
 
         assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
         assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
         assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
         assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
@@ -1633,7 +1633,7 @@ public class ReservedRolesStoreTests extends ESTestCase {
         assertNoAccessAllowed(role, AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX);
         assertNoAccessAllowed(role, AnomalyDetectorsIndexFields.STATE_INDEX_PREFIX);
         assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT);
         assertOnlyReadAllowed(role, AnomalyDetectorsIndexFields.RESULTS_INDEX_PREFIX + AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT);
         assertOnlyReadAllowed(role, NotificationsIndex.NOTIFICATIONS_INDEX);
         assertOnlyReadAllowed(role, NotificationsIndex.NOTIFICATIONS_INDEX);
-        assertReadWriteDocsButNotDeleteIndexAllowed(role, AnnotationIndex.LATEST_INDEX_NAME);
+        assertReadWriteDocsButNotDeleteIndexAllowed(role, AnnotationIndex.INDEX_NAME);
 
 
         assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
         assertNoAccessAllowed(role, RestrictedIndicesNames.RESTRICTED_NAMES);
         assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));
         assertNoAccessAllowed(role, XPackPlugin.ASYNC_RESULTS_INDEX + randomAlphaOfLengthBetween(0, 2));

+ 1 - 1
x-pack/plugin/ml/qa/native-multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/ml/integration/MlNativeAutodetectIntegTestCase.java

@@ -264,7 +264,7 @@ abstract class MlNativeAutodetectIntegTestCase extends MlNativeIntegTestCase {
 
 
     protected void assertThatNumberOfAnnotationsIsEqualTo(int expectedNumberOfAnnotations) throws IOException {
     protected void assertThatNumberOfAnnotationsIsEqualTo(int expectedNumberOfAnnotations) throws IOException {
         // Refresh the annotations index so that recently indexed annotation docs are visible.
         // Refresh the annotations index so that recently indexed annotation docs are visible.
-        client().admin().indices().prepareRefresh(AnnotationIndex.LATEST_INDEX_NAME)
+        client().admin().indices().prepareRefresh(AnnotationIndex.INDEX_NAME)
             .setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN)
             .setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN)
             .execute()
             .execute()
             .actionGet();
             .actionGet();

+ 7 - 54
x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/AnnotationIndexIT.java

@@ -7,10 +7,6 @@
 package org.elasticsearch.xpack.ml.integration;
 package org.elasticsearch.xpack.ml.integration;
 
 
 import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
 import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
-
-import org.elasticsearch.action.admin.indices.alias.Alias;
-import org.elasticsearch.action.admin.indices.create.CreateIndexAction;
-import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
 import org.elasticsearch.action.index.IndexRequest;
 import org.elasticsearch.action.index.IndexRequest;
 import org.elasticsearch.action.index.IndexResponse;
 import org.elasticsearch.action.index.IndexResponse;
 import org.elasticsearch.action.search.SearchPhaseExecutionException;
 import org.elasticsearch.action.search.SearchPhaseExecutionException;
@@ -18,7 +14,6 @@ import org.elasticsearch.action.search.SearchRequest;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.action.search.SearchResponse;
 import org.elasticsearch.action.support.IndicesOptions;
 import org.elasticsearch.action.support.IndicesOptions;
 import org.elasticsearch.cluster.metadata.AliasMetadata;
 import org.elasticsearch.cluster.metadata.AliasMetadata;
-import org.elasticsearch.cluster.metadata.IndexMetadata;
 import org.elasticsearch.cluster.service.ClusterService;
 import org.elasticsearch.cluster.service.ClusterService;
 import org.elasticsearch.common.collect.ImmutableOpenMap;
 import org.elasticsearch.common.collect.ImmutableOpenMap;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.common.settings.Settings;
@@ -31,12 +26,11 @@ import org.elasticsearch.xpack.core.ml.action.SetUpgradeModeAction;
 import org.elasticsearch.xpack.core.ml.annotations.AnnotationIndex;
 import org.elasticsearch.xpack.core.ml.annotations.AnnotationIndex;
 import org.elasticsearch.xpack.ml.MlSingleNodeTestCase;
 import org.elasticsearch.xpack.ml.MlSingleNodeTestCase;
 import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
 import org.elasticsearch.xpack.ml.notifications.AnomalyDetectionAuditor;
+import org.junit.Before;
 
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Collections;
 import java.util.List;
 import java.util.List;
 
 
-import static org.hamcrest.Matchers.containsInAnyOrder;
 import static org.hamcrest.Matchers.is;
 import static org.hamcrest.Matchers.is;
 
 
 public class AnnotationIndexIT extends MlSingleNodeTestCase {
 public class AnnotationIndexIT extends MlSingleNodeTestCase {
@@ -50,6 +44,11 @@ public class AnnotationIndexIT extends MlSingleNodeTestCase {
         return newSettings.build();
         return newSettings.build();
     }
     }
 
 
+    @Before
+    public void createComponents() throws Exception {
+        waitForMlTemplates();
+    }
+
     public void testNotCreatedWhenNoOtherMlIndices() {
     public void testNotCreatedWhenNoOtherMlIndices() {
 
 
         // Ask a few times to increase the chance of failure if the .ml-annotations index is created when no other ML index exists
         // Ask a few times to increase the chance of failure if the .ml-annotations index is created when no other ML index exists
@@ -72,52 +71,6 @@ public class AnnotationIndexIT extends MlSingleNodeTestCase {
         });
         });
     }
     }
 
 
-    public void testAliasesMovedFromOldToNew() throws Exception {
-
-        // Create an old annotations index with both read and write aliases pointing at it.
-        String oldIndex = randomFrom(AnnotationIndex.OLD_INDEX_NAMES);
-        CreateIndexRequest createIndexRequest =
-            new CreateIndexRequest(oldIndex)
-                .mapping(AnnotationIndex.annotationsMapping())
-                .settings(Settings.builder()
-                    .put(IndexMetadata.SETTING_AUTO_EXPAND_REPLICAS, "0-1")
-                    .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, "1")
-                    .put(IndexMetadata.SETTING_INDEX_HIDDEN, true))
-                .alias(new Alias(AnnotationIndex.READ_ALIAS_NAME).isHidden(true))
-                .alias(new Alias(AnnotationIndex.WRITE_ALIAS_NAME).isHidden(true));
-        client().execute(CreateIndexAction.INSTANCE, createIndexRequest).actionGet();
-
-        // Because the old annotations index name began with .ml, it will trigger the new annotations index to be created.
-        // When this happens the read alias should be changed to cover both indices, and the write alias should be
-        // switched to only point at the new index.
-        assertBusy(() -> {
-            assertTrue(annotationsIndexExists());
-            ImmutableOpenMap<String, List<AliasMetadata>> aliases = client().admin().indices()
-                .prepareGetAliases(AnnotationIndex.READ_ALIAS_NAME, AnnotationIndex.WRITE_ALIAS_NAME)
-                .setIndicesOptions(IndicesOptions.LENIENT_EXPAND_OPEN_CLOSED_HIDDEN)
-                .get()
-                .getAliases();
-            assertNotNull(aliases);
-            List<String> indicesWithReadAlias = new ArrayList<>();
-            for (ObjectObjectCursor<String, List<AliasMetadata>> entry : aliases) {
-                for (AliasMetadata aliasMetadata : entry.value) {
-                    switch (aliasMetadata.getAlias()) {
-                        case AnnotationIndex.WRITE_ALIAS_NAME:
-                            assertThat(entry.key, is(AnnotationIndex.LATEST_INDEX_NAME));
-                            break;
-                        case AnnotationIndex.READ_ALIAS_NAME:
-                            indicesWithReadAlias.add(entry.key);
-                            break;
-                        default:
-                            fail("Found unexpected alias " + aliasMetadata.getAlias() + " on index " + entry.key);
-                            break;
-                    }
-                }
-            }
-            assertThat(indicesWithReadAlias, containsInAnyOrder(oldIndex, AnnotationIndex.LATEST_INDEX_NAME));
-        });
-    }
-
     public void testNotCreatedWhenAfterOtherMlIndexAndUpgradeInProgress() throws Exception {
     public void testNotCreatedWhenAfterOtherMlIndexAndUpgradeInProgress() throws Exception {
 
 
         client().execute(SetUpgradeModeAction.INSTANCE, new SetUpgradeModeAction.Request(true)).actionGet();
         client().execute(SetUpgradeModeAction.INSTANCE, new SetUpgradeModeAction.Request(true)).actionGet();
@@ -170,7 +123,7 @@ public class AnnotationIndexIT extends MlSingleNodeTestCase {
     }
     }
 
 
     private boolean annotationsIndexExists() {
     private boolean annotationsIndexExists() {
-        return ESIntegTestCase.indexExists(AnnotationIndex.LATEST_INDEX_NAME, client());
+        return ESIntegTestCase.indexExists(AnnotationIndex.INDEX_NAME, client());
     }
     }
 
 
     private int numberOfAnnotationsAliases() {
     private int numberOfAnnotationsAliases() {

+ 1 - 1
x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/AutodetectResultProcessorIT.java

@@ -731,7 +731,7 @@ public class AutodetectResultProcessorIT extends MlSingleNodeTestCase {
 
 
     private List<Annotation> getAnnotations() throws Exception {
     private List<Annotation> getAnnotations() throws Exception {
         // Refresh the annotations index so that recently indexed annotation docs are visible.
         // Refresh the annotations index so that recently indexed annotation docs are visible.
-        client().admin().indices().prepareRefresh(AnnotationIndex.LATEST_INDEX_NAME)
+        client().admin().indices().prepareRefresh(AnnotationIndex.INDEX_NAME)
             .setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED)
             .setIndicesOptions(IndicesOptions.STRICT_EXPAND_OPEN_HIDDEN_FORBID_CLOSED)
             .execute()
             .execute()
             .actionGet();
             .actionGet();

+ 5 - 8
x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/job/process/autodetect/AutodetectProcessManagerTests.java

@@ -92,7 +92,6 @@ import java.util.function.BiConsumer;
 import java.util.function.Consumer;
 import java.util.function.Consumer;
 
 
 import static org.elasticsearch.action.support.master.MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT;
 import static org.elasticsearch.action.support.master.MasterNodeRequest.DEFAULT_MASTER_NODE_TIMEOUT;
-import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_INDEX_HIDDEN;
 import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
 import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS;
 import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
 import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS;
 import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_VERSION_CREATED;
 import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_VERSION_CREATED;
@@ -185,23 +184,21 @@ public class AutodetectProcessManagerTests extends ESTestCase {
                             Settings.builder()
                             Settings.builder()
                                 .put(SETTING_NUMBER_OF_SHARDS, 1)
                                 .put(SETTING_NUMBER_OF_SHARDS, 1)
                                 .put(SETTING_NUMBER_OF_REPLICAS, 0)
                                 .put(SETTING_NUMBER_OF_REPLICAS, 0)
-                                .put(SETTING_INDEX_HIDDEN, true)
                                 .put(SETTING_VERSION_CREATED, Version.CURRENT)
                                 .put(SETTING_VERSION_CREATED, Version.CURRENT)
                                 .build())
                                 .build())
-                        .putAlias(AliasMetadata.builder(AnomalyDetectorsIndex.jobStateIndexWriteAlias()).isHidden(true).build())
+                        .putAlias(AliasMetadata.builder(AnomalyDetectorsIndex.jobStateIndexWriteAlias()).build())
                         .build())
                         .build())
                 .fPut(
                 .fPut(
-                    AnnotationIndex.LATEST_INDEX_NAME,
-                    IndexMetadata.builder(AnnotationIndex.LATEST_INDEX_NAME)
+                    AnnotationIndex.INDEX_NAME,
+                    IndexMetadata.builder(AnnotationIndex.INDEX_NAME)
                         .settings(
                         .settings(
                             Settings.builder()
                             Settings.builder()
                                 .put(SETTING_NUMBER_OF_SHARDS, 1)
                                 .put(SETTING_NUMBER_OF_SHARDS, 1)
                                 .put(SETTING_NUMBER_OF_REPLICAS, 0)
                                 .put(SETTING_NUMBER_OF_REPLICAS, 0)
-                                .put(SETTING_INDEX_HIDDEN, true)
                                 .put(SETTING_VERSION_CREATED, Version.CURRENT)
                                 .put(SETTING_VERSION_CREATED, Version.CURRENT)
                                 .build())
                                 .build())
-                        .putAlias(AliasMetadata.builder(AnnotationIndex.READ_ALIAS_NAME).isHidden(true).build())
-                        .putAlias(AliasMetadata.builder(AnnotationIndex.WRITE_ALIAS_NAME).isHidden(true).build())
+                        .putAlias(AliasMetadata.builder(AnnotationIndex.READ_ALIAS_NAME).build())
+                        .putAlias(AliasMetadata.builder(AnnotationIndex.WRITE_ALIAS_NAME).build())
                         .build())
                         .build())
                 .build())
                 .build())
             .build();
             .build();

+ 3 - 3
x-pack/qa/rolling-upgrade/src/test/resources/rest-api-spec/test/upgraded_cluster/30_ml_jobs_crud.yml

@@ -157,6 +157,6 @@ setup:
       indices.get_mapping:
       indices.get_mapping:
         index: .ml-annotations-write
         index: .ml-annotations-write
 
 
-  - match: { \.ml-annotations-000001.mappings.properties.type.type: "keyword" }
-  - match: { \.ml-annotations-000001.mappings.properties.event.type: "keyword" }
-  - match: { \.ml-annotations-000001.mappings.properties.detector_index.type: "integer" }
+  - match: { \.ml-annotations-6.mappings.properties.type.type: "keyword" }
+  - match: { \.ml-annotations-6.mappings.properties.event.type: "keyword" }
+  - match: { \.ml-annotations-6.mappings.properties.detector_index.type: "integer" }