Skip to content

Commit

Permalink
Fix bug in snapshot update check for multiple v2 repo (#16379) (#16382)
Browse files Browse the repository at this point in the history
(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>
  • Loading branch information
1 parent e7941c9 commit 6db8124
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 @@ -743,7 +744,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 @@ -777,8 +778,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 @@ -430,6 +430,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 6db8124

Please sign in to comment.