Skip to content

Commit d839205

Browse files
Removing index alias creation for deprecated transforms notification index (#117583)
* Removing index alias creation for deprecated transforms notification index * Update docs/changelog/117583.yaml * Updating changelog * Updating deprecation area to Transform --------- Co-authored-by: Elastic Machine <[email protected]>
1 parent c792595 commit d839205

File tree

4 files changed

+17
-91
lines changed

4 files changed

+17
-91
lines changed

docs/changelog/117583.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
pr: 117583
2+
summary: Removing index alias creation for deprecated transforms notification index
3+
area: Machine Learning
4+
type: deprecation
5+
issues: []
6+
deprecation:
7+
title: Removing index alias creation for deprecated transforms notification index
8+
area: Transform
9+
details: >-
10+
As part of the migration from 7.x to 8.x, the `.data-frame-notifications-1` index
11+
was deprecated and replaced with the `.transform-notifications-000002` index.
12+
The index is no longer created by default, all writes are directed to the new index,
13+
and any clusters with the deprecated index will have an alias created to ensure that
14+
reads are still retrieving data that was written to the index before the migration to 8.x.
15+
This change removes the alias from the deprecated index in 9.x. Any clusters with the alias present
16+
will retain it, but it will not be created on new clusters.
17+
impact: No known end user impact.

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/transform/transforms/persistence/TransformInternalIndexConstants.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public final class TransformInternalIndexConstants {
4545
public static final String AUDIT_TEMPLATE_VERSION = "000002";
4646
public static final String AUDIT_INDEX_PREFIX = TRANSFORM_PREFIX + "notifications-";
4747
public static final String AUDIT_INDEX_PATTERN = AUDIT_INDEX_PREFIX + "*";
48-
public static final String AUDIT_INDEX_DEPRECATED = TRANSFORM_PREFIX_DEPRECATED + "notifications-1";
4948
public static final String AUDIT_INDEX_PATTERN_DEPRECATED = TRANSFORM_PREFIX_DEPRECATED + "notifications-*";
5049

5150
public static final String AUDIT_INDEX_READ_ALIAS = TRANSFORM_PREFIX + "notifications-read";

x-pack/plugin/transform/qa/single-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/transform/integration/TransformAuditorIT.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
package org.elasticsearch.xpack.transform.integration;
99

1010
import org.elasticsearch.client.Request;
11-
import org.elasticsearch.client.RequestOptions;
12-
import org.elasticsearch.common.Strings;
13-
import org.elasticsearch.common.settings.Settings;
1411
import org.elasticsearch.xpack.core.transform.transforms.persistence.TransformInternalIndexConstants;
1512
import org.junit.Before;
1613

@@ -92,28 +89,4 @@ public void testAuditorWritesAudits() throws Exception {
9289
});
9390

9491
}
95-
96-
public void testAliasCreatedforBWCIndexes() throws Exception {
97-
Settings.Builder settings = indexSettings(1, 0);
98-
99-
// These indices should only exist if created in previous versions, ignore the deprecation warning for this test
100-
RequestOptions options = expectWarnings(
101-
"index name ["
102-
+ TransformInternalIndexConstants.AUDIT_INDEX_DEPRECATED
103-
+ "] starts "
104-
+ "with a dot '.', in the next major version, index names starting with a dot are reserved for hidden indices "
105-
+ "and system indices"
106-
).toBuilder().addHeader("X-elastic-product-origin", "elastic").build();
107-
Request request = new Request("PUT", "/" + TransformInternalIndexConstants.AUDIT_INDEX_DEPRECATED);
108-
String entity = "{\"settings\": " + Strings.toString(settings.build()) + "}";
109-
request.setJsonEntity(entity);
110-
request.setOptions(options);
111-
client().performRequest(request);
112-
113-
assertBusy(
114-
() -> assertTrue(
115-
aliasExists(TransformInternalIndexConstants.AUDIT_INDEX_DEPRECATED, TransformInternalIndexConstants.AUDIT_INDEX_READ_ALIAS)
116-
)
117-
);
118-
}
11992
}

x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/TransformClusterStateListener.java

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,18 @@
99

1010
import org.apache.logging.log4j.LogManager;
1111
import org.apache.logging.log4j.Logger;
12-
import org.elasticsearch.action.ActionListener;
13-
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
14-
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesResponse;
1512
import org.elasticsearch.client.internal.Client;
1613
import org.elasticsearch.cluster.ClusterChangedEvent;
1714
import org.elasticsearch.cluster.ClusterState;
1815
import org.elasticsearch.cluster.ClusterStateListener;
19-
import org.elasticsearch.cluster.metadata.Metadata;
2016
import org.elasticsearch.cluster.service.ClusterService;
2117
import org.elasticsearch.gateway.GatewayService;
22-
import org.elasticsearch.xpack.core.transform.transforms.persistence.TransformInternalIndexConstants;
2318

2419
import java.util.Optional;
2520
import java.util.concurrent.atomic.AtomicBoolean;
2621
import java.util.concurrent.atomic.AtomicReference;
2722
import java.util.function.Supplier;
2823

29-
import static org.elasticsearch.xpack.core.ClientHelper.TRANSFORM_ORIGIN;
30-
import static org.elasticsearch.xpack.core.ClientHelper.executeAsyncWithOrigin;
31-
3224
class TransformClusterStateListener implements ClusterStateListener, Supplier<Optional<ClusterState>> {
3325

3426
private static final Logger logger = LogManager.getLogger(TransformClusterStateListener.class);
@@ -51,61 +43,6 @@ public void clusterChanged(ClusterChangedEvent event) {
5143
}
5244

5345
clusterState.set(event.state());
54-
55-
// The atomic flag prevents multiple simultaneous attempts to run alias creation
56-
// if there is a flurry of cluster state updates in quick succession
57-
if (event.localNodeMaster() && isIndexCreationInProgress.compareAndSet(false, true)) {
58-
createAuditAliasForDataFrameBWC(event.state(), client, ActionListener.wrap(r -> {
59-
isIndexCreationInProgress.set(false);
60-
if (r) {
61-
logger.info("Created alias for deprecated data frame notifications index");
62-
} else {
63-
logger.debug("Skipped creating alias for deprecated data frame notifications index");
64-
}
65-
}, e -> {
66-
isIndexCreationInProgress.set(false);
67-
logger.error("Error creating alias for deprecated data frame notifications index", e);
68-
}));
69-
}
70-
}
71-
72-
private static void createAuditAliasForDataFrameBWC(ClusterState state, Client client, final ActionListener<Boolean> finalListener) {
73-
74-
// check if old audit index exists, no need to create the alias if it does not
75-
if (state.getMetadata().hasIndexAbstraction(TransformInternalIndexConstants.AUDIT_INDEX_DEPRECATED) == false) {
76-
finalListener.onResponse(false);
77-
return;
78-
}
79-
80-
Metadata metadata = state.metadata();
81-
if (state.getMetadata()
82-
.getIndicesLookup()
83-
.get(TransformInternalIndexConstants.AUDIT_INDEX_DEPRECATED)
84-
.getIndices()
85-
.stream()
86-
.anyMatch(name -> metadata.index(name).getAliases().containsKey(TransformInternalIndexConstants.AUDIT_INDEX_READ_ALIAS))) {
87-
finalListener.onResponse(false);
88-
return;
89-
}
90-
91-
final IndicesAliasesRequest request = client.admin()
92-
.indices()
93-
.prepareAliases()
94-
.addAliasAction(
95-
IndicesAliasesRequest.AliasActions.add()
96-
.index(TransformInternalIndexConstants.AUDIT_INDEX_DEPRECATED)
97-
.alias(TransformInternalIndexConstants.AUDIT_INDEX_READ_ALIAS)
98-
.isHidden(true)
99-
)
100-
.request();
101-
102-
executeAsyncWithOrigin(
103-
client.threadPool().getThreadContext(),
104-
TRANSFORM_ORIGIN,
105-
request,
106-
ActionListener.<IndicesAliasesResponse>wrap(r -> finalListener.onResponse(r.isAcknowledged()), finalListener::onFailure),
107-
client.admin().indices()::aliases
108-
);
10946
}
11047

11148
/**

0 commit comments

Comments
 (0)