Skip to content

Commit 15cc0a9

Browse files
committed
Fix stale cluster state custom file deletion
Signed-off-by: Sooraj Sinha <soosinha@amazon.com>
1 parent d4d70d8 commit 15cc0a9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

server/src/main/java/org/opensearch/gateway/remote/RemoteClusterStateCleanupManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ void deleteClusterMetadata(
306306
staleEphemeralAttributePaths.add(clusterMetadataManifest.getHashesOfConsistentSettings().getUploadedFilename());
307307
}
308308
if (clusterMetadataManifest.getClusterStateCustomMap() != null) {
309-
clusterMetadataManifest.getCustomMetadataMap()
309+
clusterMetadataManifest.getClusterStateCustomMap()
310310
.values()
311311
.stream()
312312
.filter(u -> !filesToKeep.contains(u.getUploadedFilename()))

server/src/test/java/org/opensearch/gateway/remote/RemoteClusterStateCleanupManagerTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import java.util.HashSet;
4343
import java.util.List;
4444
import java.util.Locale;
45+
import java.util.Map;
4546
import java.util.Set;
4647
import java.util.concurrent.CountDownLatch;
4748
import java.util.concurrent.TimeUnit;
@@ -200,6 +201,7 @@ public void testDeleteClusterMetadata() throws IOException {
200201
.nodeId("nodeA")
201202
.opensearchVersion(VersionUtils.randomOpenSearchVersion(random()))
202203
.previousClusterUUID(ClusterState.UNKNOWN_UUID)
204+
.clusterStateCustomMetadataMap(Map.of("snapshots", new UploadedMetadataAttribute("snapshots", "snapshot_file1")))
203205
.committed(true)
204206
.build();
205207
ClusterMetadataManifest manifest2 = ClusterMetadataManifest.builder(manifest1)
@@ -209,10 +211,12 @@ public void testDeleteClusterMetadata() throws IOException {
209211
.coordinationMetadata(coordinationMetadata)
210212
.templatesMetadata(templateMetadata)
211213
.settingMetadata(settingMetadata)
214+
.clusterStateCustomMetadataMap(Map.of("restore", new UploadedMetadataAttribute("restore", "restore_file1")))
212215
.build();
213216
ClusterMetadataManifest manifest3 = ClusterMetadataManifest.builder(manifest2)
214217
.indices(List.of(index1UpdatedMetadata, index2Metadata))
215218
.settingMetadata(settingMetadataUpdated)
219+
.clusterStateCustomMetadataMap(Map.of())
216220
.build();
217221

218222
UploadedIndexMetadata index3Metadata = new UploadedIndexMetadata("index3", "indexUUID3", "index_metadata3__2");
@@ -286,6 +290,7 @@ public void testDeleteClusterMetadata() throws IOException {
286290
)
287291
);
288292
verify(container).deleteBlobsIgnoringIfNotExists(List.of(getFormattedIndexFileName(index1Metadata.getUploadedFilePath())));
293+
verify(container).deleteBlobsIgnoringIfNotExists(List.of("restore_file1", "snapshot_file1"));
289294
Set<String> staleManifest = new HashSet<>();
290295
inactiveBlobs.forEach(
291296
blob -> staleManifest.add(

0 commit comments

Comments
 (0)