Skip to content

Commit 63eb0bb

Browse files
authored
Check for .watches that wasn't upgraded properly (#39609)
If the `.watches` index was created in 5.6 and is still a concrete index, rather than an alias for `.watches-6`, that means that it was not properly upgraded with the Migration Upgrade API before upgrading to Elasticsearch 6.x. In this case, calling the Migration Upgrade API will resolve the problem with the `.watches` index. This isn't going to be a common case, as Watcher will not run properly in this situation, but we should handle it and notify the user of the correct action, just in case.
1 parent 0799ff1 commit 63eb0bb

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecks.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,12 @@ static DeprecationIssue oldIndicesCheck(IndexMetaData indexMetaData) {
112112
"The .tasks index was created before version 6.0 and cannot be opened in 7.0. " +
113113
"You must delete this index and allow it to be re-created by Elasticsearch. If you wish to preserve task history, "+
114114
"reindex this index to a new index before deleting it.");
115+
} else if (".watches".equals(indexMetaData.getIndex().getName())) {
116+
return new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
117+
".watches was not properly upgraded before upgrading to Elasticsearch 6",
118+
"https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-upgrade.html",
119+
"The .watches index was created before version 6.0, and was not properly upgraded in 5.6. " +
120+
"Please upgrade this index using the Migration Upgrade API.");
115121
}
116122
if ((mappingCount == 2 && !hasDefaultMapping)
117123
|| mappingCount > 2) {

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/IndexDeprecationChecksTests.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,23 @@ public void testOldTasksIndexCheck() {
6363
assertEquals(singletonList(expected), issues);
6464
}
6565

66+
public void testUnupgradedWatcherIndexCheck() {
67+
Version createdWith = VersionUtils.randomVersionBetween(random(), Version.V_5_0_0,
68+
VersionUtils.getPreviousVersion(Version.V_6_0_0));
69+
IndexMetaData indexMetaData = IndexMetaData.builder(".watches")
70+
.settings(settings(createdWith))
71+
.numberOfShards(1)
72+
.numberOfReplicas(0)
73+
.build();
74+
DeprecationIssue expected = new DeprecationIssue(DeprecationIssue.Level.CRITICAL,
75+
".watches was not properly upgraded before upgrading to Elasticsearch 6",
76+
"https://www.elastic.co/guide/en/elasticsearch/reference/current/migration-api-upgrade.html",
77+
"The .watches index was created before version 6.0, and was not properly upgraded in 5.6. " +
78+
"Please upgrade this index using the Migration Upgrade API.");
79+
List<DeprecationIssue> issues = DeprecationChecks.filterChecks(INDEX_SETTINGS_CHECKS, c -> c.apply(indexMetaData));
80+
assertEquals(singletonList(expected), issues);
81+
}
82+
6683
public void testMultipleTypesCheckWithDefaultMapping() throws IOException {
6784
String mappingName1 = randomAlphaOfLengthBetween(2, 5);
6885
String mappingJson1 = "{\n" +

0 commit comments

Comments
 (0)