Skip to content

Commit fa3bf55

Browse files
authored
[8.x] [Deprecation] Refine Transform Destination Index message (#122192) (#122524) (#122648)
When we detect that a Transform writes to the index and the index is incompatible with the next version, change the message, detail, and URL to help the user take the necessary steps to migrate the destination index.
1 parent f655808 commit fa3bf55

File tree

2 files changed

+204
-47
lines changed

2 files changed

+204
-47
lines changed

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

Lines changed: 59 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.elasticsearch.common.TriFunction;
1414
import org.elasticsearch.common.time.DateFormatter;
1515
import org.elasticsearch.common.time.LegacyFormatNames;
16+
import org.elasticsearch.core.Strings;
1617
import org.elasticsearch.index.IndexModule;
1718
import org.elasticsearch.index.IndexSettings;
1819
import org.elasticsearch.index.IndexVersion;
@@ -97,25 +98,39 @@ private DeprecationIssue oldIndicesCheck(
9798
IndexVersion currentCompatibilityVersion = indexMetadata.getCompatibilityVersion();
9899
// We intentionally exclude indices that are in data streams because they will be picked up by DataStreamDeprecationChecks
99100
if (DeprecatedIndexPredicate.reindexRequired(indexMetadata, false) && isNotDataStreamIndex(indexMetadata, clusterState)) {
100-
return new DeprecationIssue(
101-
DeprecationIssue.Level.CRITICAL,
102-
"Old index with a compatibility version < 8.0",
103-
"https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.0.html#breaking-changes-8.0",
104-
"This index has version: " + currentCompatibilityVersion.toReleaseVersion(),
105-
false,
106-
meta(indexMetadata, indexToTransformIds)
107-
);
101+
var transforms = transformIdsForIndex(indexMetadata, indexToTransformIds);
102+
if (transforms.isEmpty() == false) {
103+
return new DeprecationIssue(
104+
DeprecationIssue.Level.CRITICAL,
105+
"One or more Transforms write to this index with a compatibility version < 8.0",
106+
"https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-9.0.html"
107+
+ "#breaking_90_transform_destination_index",
108+
Strings.format(
109+
"This index was created in version [%s] and requires action before upgrading to 9.0. The following transforms are "
110+
+ "configured to write to this index: [%s]. Refer to the migration guide to learn more about how to prepare "
111+
+ "transforms destination indices for your upgrade.",
112+
currentCompatibilityVersion.toReleaseVersion(),
113+
String.join(", ", transforms)
114+
),
115+
false,
116+
Map.of("reindex_required", true, "transform_ids", transforms)
117+
);
118+
} else {
119+
return new DeprecationIssue(
120+
DeprecationIssue.Level.CRITICAL,
121+
"Old index with a compatibility version < 8.0",
122+
"https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-9.0.html",
123+
"This index has version: " + currentCompatibilityVersion.toReleaseVersion(),
124+
false,
125+
Map.of("reindex_required", true)
126+
);
127+
}
108128
}
109129
return null;
110130
}
111131

112-
private Map<String, Object> meta(IndexMetadata indexMetadata, Map<String, List<String>> indexToTransformIds) {
113-
var transforms = indexToTransformIds.getOrDefault(indexMetadata.getIndex().getName(), List.of());
114-
if (transforms.isEmpty()) {
115-
return Map.of("reindex_required", true);
116-
} else {
117-
return Map.of("reindex_required", true, "transform_ids", transforms);
118-
}
132+
private List<String> transformIdsForIndex(IndexMetadata indexMetadata, Map<String, List<String>> indexToTransformIds) {
133+
return indexToTransformIds.getOrDefault(indexMetadata.getIndex().getName(), List.of());
119134
}
120135

121136
private DeprecationIssue ignoredOldIndicesCheck(
@@ -126,16 +141,35 @@ private DeprecationIssue ignoredOldIndicesCheck(
126141
IndexVersion currentCompatibilityVersion = indexMetadata.getCompatibilityVersion();
127142
// We intentionally exclude indices that are in data streams because they will be picked up by DataStreamDeprecationChecks
128143
if (DeprecatedIndexPredicate.reindexRequired(indexMetadata, true) && isNotDataStreamIndex(indexMetadata, clusterState)) {
129-
return new DeprecationIssue(
130-
DeprecationIssue.Level.WARNING,
131-
"Old index with a compatibility version < 8.0 Has Been Ignored",
132-
"https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-8.0.html#breaking-changes-8.0",
133-
"This read-only index has version: "
134-
+ currentCompatibilityVersion.toReleaseVersion()
135-
+ " and will be supported as read-only in 9.0",
136-
false,
137-
meta(indexMetadata, indexToTransformIds)
138-
);
144+
var transforms = transformIdsForIndex(indexMetadata, indexToTransformIds);
145+
if (transforms.isEmpty() == false) {
146+
return new DeprecationIssue(
147+
DeprecationIssue.Level.WARNING,
148+
"One or more Transforms write to this old index with a compatibility version < 8.0",
149+
"https://www.elastic.co/guide/en/elasticsearch/reference/current/migrating-9.0.html"
150+
+ "#breaking_90_transform_destination_index",
151+
Strings.format(
152+
"This index was created in version [%s] and will be supported as a read-only index in 9.0. The following "
153+
+ "transforms are no longer able to write to this index: [%s]. Refer to the migration guide to learn more "
154+
+ "about how to handle your transforms destination indices.",
155+
currentCompatibilityVersion.toReleaseVersion(),
156+
String.join(", ", transforms)
157+
),
158+
false,
159+
Map.of("reindex_required", true, "transform_ids", transforms)
160+
);
161+
} else {
162+
return new DeprecationIssue(
163+
DeprecationIssue.Level.WARNING,
164+
"Old index with a compatibility version < 8.0 has been ignored",
165+
"https://www.elastic.co/guide/en/elasticsearch/reference/current/breaking-changes-9.0.html",
166+
"This read-only index has version: "
167+
+ currentCompatibilityVersion.toReleaseVersion()
168+
+ " and will be supported as read-only in 9.0",
169+
false,
170+
Map.of("reindex_required", true)
171+
);
172+
}
139173
}
140174
return null;
141175
}

0 commit comments

Comments
 (0)