Skip to content

Commit 6db8124

Browse files
Fix bug in snapshot update check for multiple v2 repo (#16379) (#16382)
(cherry picked from commit 9096aee) Signed-off-by: Gaurav Bafna <gbbafna@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent e7941c9 commit 6db8124

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

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

+9-3
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;
@@ -743,7 +744,7 @@ public static void validateRepositoryMetadataSettings(
743744
+ " in the name as this delimiter is used to create pinning entity"
744745
);
745746
}
746-
if (repositoryWithShallowV2Exists(repositories)) {
747+
if (repositoryWithShallowV2Exists(repositories, repositoryName)) {
747748
throw new RepositoryException(
748749
repositoryName,
749750
"setting "
@@ -777,8 +778,13 @@ public static void validateRepositoryMetadataSettings(
777778
}
778779
}
779780

780-
private static boolean repositoryWithShallowV2Exists(Map<String, Repository> repositories) {
781-
return repositories.values().stream().anyMatch(repo -> SHALLOW_SNAPSHOT_V2.get(repo.getMetadata().settings()));
781+
private static boolean repositoryWithShallowV2Exists(Map<String, Repository> repositories, String repositoryName) {
782+
return repositories.values()
783+
.stream()
784+
.anyMatch(
785+
repository -> SHALLOW_SNAPSHOT_V2.get(repository.getMetadata().settings())
786+
&& !Objects.equals(repository.getMetadata().name(), repositoryName)
787+
);
782788
}
783789

784790
private static boolean pinnedTimestampExistsWithDifferentRepository(

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

+7
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,13 @@ public void testRepositoryCreationShallowV2() throws Exception {
430430
);
431431
}
432432

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

0 commit comments

Comments
 (0)