Skip to content

Commit 875b129

Browse files
gbbafnadk2k
authored andcommitted
Fix bug in snapshot update check for multiple v2 repo (opensearch-project#16379)
Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
1 parent f4f37d5 commit 875b129

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

server/src/main/java/org/opensearch/repositories/RepositoriesService.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import java.util.HashMap;
8282
import java.util.List;
8383
import java.util.Map;
84+
import java.util.Objects;
8485
import java.util.Set;
8586
import java.util.stream.Collectors;
8687
import java.util.stream.Stream;
@@ -729,7 +730,7 @@ public static void validateRepositoryMetadataSettings(
729730
+ " in the name as this delimiter is used to create pinning entity"
730731
);
731732
}
732-
if (repositoryWithShallowV2Exists(repositories)) {
733+
if (repositoryWithShallowV2Exists(repositories, repositoryName)) {
733734
throw new RepositoryException(
734735
repositoryName,
735736
"setting "
@@ -763,8 +764,13 @@ public static void validateRepositoryMetadataSettings(
763764
}
764765
}
765766

766-
private static boolean repositoryWithShallowV2Exists(Map<String, Repository> repositories) {
767-
return repositories.values().stream().anyMatch(repo -> SHALLOW_SNAPSHOT_V2.get(repo.getMetadata().settings()));
767+
private static boolean repositoryWithShallowV2Exists(Map<String, Repository> repositories, String repositoryName) {
768+
return repositories.values()
769+
.stream()
770+
.anyMatch(
771+
repository -> SHALLOW_SNAPSHOT_V2.get(repository.getMetadata().settings())
772+
&& !Objects.equals(repository.getMetadata().name(), repositoryName)
773+
);
768774
}
769775

770776
private static boolean pinnedTimestampExistsWithDifferentRepository(

server/src/test/java/org/opensearch/repositories/blobstore/BlobStoreRepositoryRemoteIndexTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,13 @@ public void testRepositoryCreationShallowV2() throws Exception {
431431
);
432432
}
433433

434+
// Modify repo-1 settings. This should go through
435+
updateRepository(
436+
client,
437+
"test-repo-1",
438+
Settings.builder().put(snapshotRepoSettings1).put("max_snapshot_bytes_per_sec", "10k").build()
439+
);
440+
434441
// Disable shallow snapshot V2 setting on test-repo-1
435442
updateRepository(
436443
client,

0 commit comments

Comments
 (0)