Skip to content

Commit

Permalink
Fix stale cluster state custom file deletion
Browse files Browse the repository at this point in the history
Signed-off-by: Sooraj Sinha <[email protected]>
  • Loading branch information
soosinha committed Nov 18, 2024
1 parent d4d70d8 commit 15cc0a9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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()
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

0 comments on commit 15cc0a9

Please sign in to comment.