Skip to content
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

Fix stale cluster state custom file deletion #16670

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Fix rollover alias supports restored searchable snapshot index([#16483](https://github.com/opensearch-project/OpenSearch/pull/16483))
- Fix permissions error on scripted query against remote snapshot ([#16544](https://github.com/opensearch-project/OpenSearch/pull/16544))
- Fix `doc_values` only (`index:false`) IP field searching for masks ([#16628](https://github.com/opensearch-project/OpenSearch/pull/16628))
- Fix stale cluster state custom file deletion ([#16670](https://github.com/opensearch-project/OpenSearch/pull/16670))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void deleteClusterMetadata(
staleEphemeralAttributePaths.add(clusterMetadataManifest.getHashesOfConsistentSettings().getUploadedFilename());
}
if (clusterMetadataManifest.getClusterStateCustomMap() != null) {
clusterMetadataManifest.getCustomMetadataMap()
shwetathareja marked this conversation as resolved.
Show resolved Hide resolved
clusterMetadataManifest.getClusterStateCustomMap()
.values()
.stream()
.filter(u -> !filesToKeep.contains(u.getUploadedFilename()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -200,6 +201,7 @@ public void testDeleteClusterMetadata() throws IOException {
.nodeId("nodeA")
.opensearchVersion(VersionUtils.randomOpenSearchVersion(random()))
.previousClusterUUID(ClusterState.UNKNOWN_UUID)
.clusterStateCustomMetadataMap(Map.of("snapshots", new UploadedMetadataAttribute("snapshots", "snapshot_file1")))
.committed(true)
.build();
ClusterMetadataManifest manifest2 = ClusterMetadataManifest.builder(manifest1)
Expand All @@ -209,10 +211,12 @@ public void testDeleteClusterMetadata() throws IOException {
.coordinationMetadata(coordinationMetadata)
.templatesMetadata(templateMetadata)
.settingMetadata(settingMetadata)
.clusterStateCustomMetadataMap(Map.of("restore", new UploadedMetadataAttribute("restore", "restore_file1")))
.build();
ClusterMetadataManifest manifest3 = ClusterMetadataManifest.builder(manifest2)
.indices(List.of(index1UpdatedMetadata, index2Metadata))
.settingMetadata(settingMetadataUpdated)
.clusterStateCustomMetadataMap(Map.of())
.build();

UploadedIndexMetadata index3Metadata = new UploadedIndexMetadata("index3", "indexUUID3", "index_metadata3__2");
Expand Down Expand Up @@ -286,6 +290,7 @@ public void testDeleteClusterMetadata() throws IOException {
)
);
verify(container).deleteBlobsIgnoringIfNotExists(List.of(getFormattedIndexFileName(index1Metadata.getUploadedFilePath())));
verify(container).deleteBlobsIgnoringIfNotExists(List.of("restore_file1", "snapshot_file1"));
Set<String> staleManifest = new HashSet<>();
inactiveBlobs.forEach(
blob -> staleManifest.add(
Expand Down
Loading