Skip to content

Updates the deprecation info API to not warn about system indices and data streams #122951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/122951.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 122951
summary: Updates the deprecation info API to not warn about system indices and data
streams
area: Indices APIs
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,15 @@ public static Predicate<Index> getReindexRequiredPredicate(Metadata metadata, bo
*/
public static boolean reindexRequired(IndexMetadata indexMetadata, boolean filterToBlockedStatus) {
return creationVersionBeforeMinimumWritableVersion(indexMetadata)
&& isNotSystem(indexMetadata)
&& isNotSearchableSnapshot(indexMetadata)
&& matchBlockedStatus(indexMetadata, filterToBlockedStatus);
}

private static boolean isNotSystem(IndexMetadata indexMetadata) {
return indexMetadata.isSystem() == false;
}

private static boolean isNotSearchableSnapshot(IndexMetadata indexMetadata) {
return indexMetadata.isSearchableSnapshot() == false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ public Map<String, List<DeprecationIssue>> check(ClusterState clusterState) {
Map<String, List<DeprecationIssue>> dataStreamIssues = new HashMap<>();
for (String dataStreamName : dataStreamNames) {
DataStream dataStream = clusterState.metadata().dataStreams().get(dataStreamName);
List<DeprecationIssue> issuesForSingleDataStream = DATA_STREAM_CHECKS.stream()
.map(c -> c.apply(dataStream, clusterState))
.filter(Objects::nonNull)
.toList();
if (issuesForSingleDataStream.isEmpty() == false) {
dataStreamIssues.put(dataStreamName, issuesForSingleDataStream);
if (dataStream.isSystem() == false) {
List<DeprecationIssue> issuesForSingleDataStream = DATA_STREAM_CHECKS.stream()
.map(c -> c.apply(dataStream, clusterState))
.filter(Objects::nonNull)
.toList();
if (issuesForSingleDataStream.isEmpty() == false) {
dataStreamIssues.put(dataStreamName, issuesForSingleDataStream);
}
}
}
return dataStreamIssues.isEmpty() ? Map.of() : dataStreamIssues;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,4 +302,52 @@ public void testOldIndicesIgnoredWarningCheck() {
assertThat(issuesByDataStream.get(dataStream.getName()), equalTo(List.of(expected)));
}

public void testOldSystemDataStreamIgnored() {
// We do not want system data streams coming back in the deprecation info API
int oldIndexCount = randomIntBetween(1, 100);
int newIndexCount = randomIntBetween(1, 100);
List<Index> allIndices = new ArrayList<>();
Map<String, IndexMetadata> nameToIndexMetadata = new HashMap<>();
for (int i = 0; i < oldIndexCount; i++) {
Settings.Builder settings = settings(IndexVersion.fromId(7170099));

String indexName = "old-data-stream-index-" + i;
settings.put(MetadataIndexStateService.VERIFIED_READ_ONLY_SETTING.getKey(), true);

IndexMetadata oldIndexMetadata = IndexMetadata.builder(indexName)
.settings(settings)
.numberOfShards(1)
.numberOfReplicas(0)
.build();
allIndices.add(oldIndexMetadata.getIndex());
nameToIndexMetadata.put(oldIndexMetadata.getIndex().getName(), oldIndexMetadata);
}
for (int i = 0; i < newIndexCount; i++) {
Index newIndex = createNewIndex(i, false, nameToIndexMetadata);
allIndices.add(newIndex);
}
DataStream dataStream = new DataStream(
randomAlphaOfLength(10),
allIndices,
randomNegativeLong(),
Map.of(),
true,
false,
true,
randomBoolean(),
randomFrom(IndexMode.values()),
null,
randomFrom(DataStreamOptions.EMPTY, DataStreamOptions.FAILURE_STORE_DISABLED, DataStreamOptions.FAILURE_STORE_ENABLED, null),
List.of(),
randomBoolean(),
null
);
Metadata metadata = Metadata.builder()
.indices(nameToIndexMetadata)
.dataStreams(Map.of(dataStream.getName(), dataStream), Map.of())
.build();
ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT).metadata(metadata).build();
assertThat(checker.check(clusterState), equalTo(Map.of()));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,28 @@ public void testOldIndicesIgnoredWarningCheck() {
assertEquals(List.of(expected), issuesByIndex.get("test"));
}

public void testOldSystemIndicesIgnored() {
// We do not want system indices coming back in the deprecation info API
Settings.Builder settings = settings(OLD_VERSION).put(MetadataIndexStateService.VERIFIED_READ_ONLY_SETTING.getKey(), true);
IndexMetadata indexMetadata = IndexMetadata.builder("test")
.system(true)
.settings(settings)
.numberOfShards(1)
.numberOfReplicas(0)
.state(indexMetdataState)
.build();
ClusterState clusterState = ClusterState.builder(ClusterState.EMPTY_STATE)
.metadata(Metadata.builder().put(indexMetadata, true))
.blocks(clusterBlocksForIndices(indexMetadata))
.build();
Map<String, List<DeprecationIssue>> issuesByIndex = checker.check(
clusterState,
new DeprecationInfoAction.Request(TimeValue.THIRTY_SECONDS),
emptyPrecomputedData
);
assertThat(issuesByIndex, equalTo(Map.of()));
}

private IndexMetadata readonlyIndexMetadata(String indexName, IndexVersion indexVersion) {
Settings.Builder settings = settings(indexVersion).put(MetadataIndexStateService.VERIFIED_READ_ONLY_SETTING.getKey(), true);
return IndexMetadata.builder(indexName).settings(settings).numberOfShards(1).numberOfReplicas(0).state(indexMetdataState).build();
Expand Down