Skip to content

Commit 2d58d0f

Browse files
Stop suggesting feature migrations for 7.x indices (#93666) (#93708)
* Don't report MIGRATION_NEEDED for 7.x indices Eventually, we will need to migrate 7.x indices to 8.x before doing a significant upgrade of Lucene. However, the migrations to 8.x are not adequately tested: while they will eventually be needed, they are not currently needed, and may in fact produce bugs. This change will ensure that the GET _migration/system_feature API returns NO_MIGRATION_NEEDED in 8.x. We will begin to require migrations once we start testing for the next major version upgrade.
1 parent 173db6d commit 2d58d0f

File tree

6 files changed

+33
-9
lines changed

6 files changed

+33
-9
lines changed

docs/changelog/93666.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 93666
2+
summary: Don't report MIGRATION_NEEDED for 7.x indices
3+
area: Infra/Core
4+
type: bug
5+
issues: []

modules/ingest-geoip/qa/full-cluster-restart/build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88

99
import org.elasticsearch.gradle.Version
10+
import org.elasticsearch.gradle.VersionProperties
1011
import org.elasticsearch.gradle.internal.info.BuildParams
1112
import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask
1213

@@ -37,7 +38,12 @@ tasks.withType(Test).configureEach {
3738
}
3839
}
3940

40-
BuildParams.bwcVersions.withWireCompatible(v -> v.before("8.0.0")) { bwcVersion, baseName ->
41+
assert Version.fromString(VersionProperties.getVersions().get("elasticsearch")).getMajor() == 8 :
42+
"If we are targeting a branch other than 8, we should enable migration tests"
43+
44+
// once we are ready to test migrations from 8.x to 9.x, we can set the compatible version to 8.0.0
45+
// see https://github.com/elastic/elasticsearch/pull/93666
46+
BuildParams.bwcVersions.withWireCompatible(v -> v.before("7.0.0")) { bwcVersion, baseName ->
4147
def baseCluster = testClusters.register(baseName) {
4248
testDistribution = "DEFAULT"
4349
if (bwcVersion.before(BuildParams.bwcVersions.minimumWireCompatibleVersion)) {

modules/reindex/src/internalClusterTest/java/org/elasticsearch/migration/AbstractFeatureMigrationIntegTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.elasticsearch.Version;
1212
import org.elasticsearch.action.ActionListener;
13+
import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction;
1314
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
1415
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
1516
import org.elasticsearch.action.admin.indices.stats.IndexStats;
@@ -64,7 +65,7 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase
6465
static final String INTERNAL_MANAGED_INDEX_NAME = ".int-man-old";
6566
static final int INDEX_DOC_COUNT = 100; // arbitrarily chosen
6667
static final int INTERNAL_MANAGED_FLAG_VALUE = 1;
67-
public static final Version NEEDS_UPGRADE_VERSION = Version.V_7_0_0;
68+
public static final Version NEEDS_UPGRADE_VERSION = TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION.previousMajor();
6869

6970
static final SystemIndexDescriptor EXTERNAL_UNMANAGED = SystemIndexDescriptor.builder()
7071
.setIndexPattern(".ext-unman-*")
@@ -131,6 +132,11 @@ public abstract class AbstractFeatureMigrationIntegTest extends ESIntegTestCase
131132

132133
@Before
133134
public void setup() {
135+
assumeTrue(
136+
"We can only create the test indices we need if they're in the previous major version",
137+
NEEDS_UPGRADE_VERSION.onOrAfter(Version.CURRENT.previousMajor())
138+
);
139+
134140
internalCluster().setBootstrapMasterNodeIndex(0);
135141
masterName = internalCluster().startMasterOnlyNode();
136142
masterAndDataNode = internalCluster().startNode();

qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/FeatureUpgradeIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
package org.elasticsearch.upgrades;
1010

11-
import org.elasticsearch.Version;
11+
import org.elasticsearch.action.admin.cluster.migration.TransportGetFeatureUpgradeStatusAction;
1212
import org.elasticsearch.client.Request;
1313
import org.elasticsearch.client.ResponseException;
1414
import org.elasticsearch.test.XContentTestUtils;
@@ -94,7 +94,7 @@ public void testGetFeatureUpgradeStatus() throws Exception {
9494

9595
assertThat(feature.size(), equalTo(4));
9696
assertThat(feature.get("minimum_index_version"), equalTo(UPGRADE_FROM_VERSION.toString()));
97-
if (UPGRADE_FROM_VERSION.before(Version.V_8_0_0)) {
97+
if (UPGRADE_FROM_VERSION.before(TransportGetFeatureUpgradeStatusAction.NO_UPGRADE_REQUIRED_VERSION)) {
9898
assertThat(feature.get("migration_status"), equalTo("MIGRATION_NEEDED"));
9999
} else {
100100
assertThat(feature.get("migration_status"), equalTo("NO_MIGRATION_NEEDED"));

server/src/main/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusAction.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ public class TransportGetFeatureUpgradeStatusAction extends TransportMasterNodeA
4949
GetFeatureUpgradeStatusResponse> {
5050

5151
/**
52-
* This version is only valid for >=8.0.0 and should be changed on backport.
52+
* Once all feature migrations for 8.x -> 9.x have been tested, we can bump this to Version.V_8_0_0
5353
*/
54-
public static final Version NO_UPGRADE_REQUIRED_VERSION = Version.V_8_0_0;
54+
public static final Version NO_UPGRADE_REQUIRED_VERSION = Version.V_7_0_0;
5555

5656
private final SystemIndices systemIndices;
5757
PersistentTasksService persistentTasksService;
@@ -77,6 +77,9 @@ public TransportGetFeatureUpgradeStatusAction(
7777
GetFeatureUpgradeStatusResponse::new,
7878
ThreadPool.Names.SAME
7979
);
80+
81+
assert Version.CURRENT.major == 8 : "Once we begin working on 9.x, we need to update our migration classes";
82+
8083
this.systemIndices = systemIndices;
8184
this.persistentTasksService = persistentTasksService;
8285
}

server/src/test/java/org/elasticsearch/action/admin/cluster/migration/TransportGetFeatureUpgradeStatusActionTests.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class TransportGetFeatureUpgradeStatusActionTests extends ESTestCase {
2929
public static String TEST_SYSTEM_INDEX_PATTERN = ".test*";
3030
private static final ClusterState CLUSTER_STATE = getClusterState();
3131
private static final SystemIndices.Feature FEATURE = getFeature();
32+
private static final Version TEST_OLD_VERSION = Version.fromString("6.0.0");
3233

3334
public void testGetFeatureStatus() {
3435
GetFeatureUpgradeStatusResponse.FeatureUpgradeStatus status = TransportGetFeatureUpgradeStatusAction.getFeatureUpgradeStatus(
@@ -38,7 +39,7 @@ public void testGetFeatureStatus() {
3839

3940
assertThat(status.getUpgradeStatus(), equalTo(MIGRATION_NEEDED));
4041
assertThat(status.getFeatureName(), equalTo("test-feature"));
41-
assertThat(status.getMinimumIndexVersion(), equalTo(Version.V_7_0_0));
42+
assertThat(status.getMinimumIndexVersion(), equalTo(TEST_OLD_VERSION));
4243
assertThat(status.getIndexVersions().size(), equalTo(2)); // additional testing below
4344
}
4445

@@ -57,7 +58,7 @@ public void testGetIndexInfos() {
5758
}
5859
{
5960
GetFeatureUpgradeStatusResponse.IndexInfo version = versions.get(1);
60-
assertThat(version.getVersion(), equalTo(Version.V_7_0_0));
61+
assertThat(version.getVersion(), equalTo(TEST_OLD_VERSION));
6162
assertThat(version.getIndexName(), equalTo(".test-index-2"));
6263
}
6364
}
@@ -80,8 +81,11 @@ private static ClusterState getClusterState() {
8081
.numberOfReplicas(0)
8182
.build();
8283

84+
// Once we start testing 9.x, we should update this test to use a 7.x "version created"
85+
assert Version.CURRENT.major < 9;
86+
8387
IndexMetadata indexMetadata2 = IndexMetadata.builder(".test-index-2")
84-
.settings(Settings.builder().put("index.version.created", Version.V_7_0_0).build())
88+
.settings(Settings.builder().put("index.version.created", Version.fromString("6.0.0")).build())
8589
.numberOfShards(1)
8690
.numberOfReplicas(0)
8791
.build();

0 commit comments

Comments
 (0)