Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] [Snapshot v2] Fix bug in snapshot update check for multiple v2 repo #16382

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading