Skip to content

Commit

Permalink
Fix bug in snapshot update check for multiple v2 repo (opensearch-pro…
Browse files Browse the repository at this point in the history
…ject#16379)

Signed-off-by: Gaurav Bafna <gbbafna@amazon.com>
  • Loading branch information
gbbafna authored and dk2k committed Oct 21, 2024
1 parent f4f37d5 commit 875b129
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -729,7 +730,7 @@ public static void validateRepositoryMetadataSettings(
+ " in the name as this delimiter is used to create pinning entity"
);
}
if (repositoryWithShallowV2Exists(repositories)) {
if (repositoryWithShallowV2Exists(repositories, repositoryName)) {
throw new RepositoryException(
repositoryName,
"setting "
Expand Down Expand Up @@ -763,8 +764,13 @@ public static void validateRepositoryMetadataSettings(
}
}

private static boolean repositoryWithShallowV2Exists(Map<String, Repository> repositories) {
return repositories.values().stream().anyMatch(repo -> SHALLOW_SNAPSHOT_V2.get(repo.getMetadata().settings()));
private static boolean repositoryWithShallowV2Exists(Map<String, Repository> repositories, String repositoryName) {
return repositories.values()
.stream()
.anyMatch(
repository -> SHALLOW_SNAPSHOT_V2.get(repository.getMetadata().settings())
&& !Objects.equals(repository.getMetadata().name(), repositoryName)
);
}

private static boolean pinnedTimestampExistsWithDifferentRepository(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,13 @@ public void testRepositoryCreationShallowV2() throws Exception {
);
}

// Modify repo-1 settings. This should go through
updateRepository(
client,
"test-repo-1",
Settings.builder().put(snapshotRepoSettings1).put("max_snapshot_bytes_per_sec", "10k").build()
);

// Disable shallow snapshot V2 setting on test-repo-1
updateRepository(
client,
Expand Down

0 comments on commit 875b129

Please sign in to comment.