-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Add default snapshot repo cluster setting #139155
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a cluster setting to specify a default snapshot repository for snapshot and restore operations. When configured, this eliminates the need to explicitly specify a repository name in these operations.
Key changes:
- Added
repositories.default_repositorydynamic cluster setting - Implemented validation to ensure only registered repositories can be set as default
- Added protection to prevent deletion of the default repository
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
RepositoriesService.java |
Adds the default repository cluster setting, validation logic, getter/setter methods, and prevention of default repository deletion |
ClusterSettings.java |
Registers the new DEFAULT_REPOSITORY_SETTING in the cluster settings registry |
10_default_repository.yml |
Adds comprehensive YAML REST tests covering setting, validation, and edge cases for the default repository feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
server/src/main/java/org/elasticsearch/repositories/RepositoriesService.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/repositories/RepositoriesService.java
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/repositories/RepositoriesService.java
Show resolved
Hide resolved
…esService.java Co-authored-by: Copilot <[email protected]>
…esService.java Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
server/src/main/java/org/elasticsearch/repositories/RepositoriesService.java
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/es-data-management (Team:Data Management) |
nielsbauman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this, Sean! I added a few minor comments, but we should get someone from the Distributed team to look at this as well, as they own the snapshot/restore feature.
server/src/main/java/org/elasticsearch/repositories/RepositoriesService.java
Outdated
Show resolved
Hide resolved
...pi-spec/src/yamlRestTest/resources/rest-api-spec/test/repositories/10_default_repository.yml
Outdated
Show resolved
Hide resolved
...pi-spec/src/yamlRestTest/resources/rest-api-spec/test/repositories/10_default_repository.yml
Outdated
Show resolved
Hide resolved
...pi-spec/src/yamlRestTest/resources/rest-api-spec/test/repositories/10_default_repository.yml
Outdated
Show resolved
Hide resolved
server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java
Show resolved
Hide resolved
| clusterService.getClusterSettings() | ||
| .addSettingsUpdateConsumer(DEFAULT_REPOSITORY_SETTING, this::setDefaultRepository, this::validateDefaultRepository); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should get someone from the Distributed team to have a look at this validation, to verify if there's any reason this validation could cause issues. I'll add the area label to the PR, could you reach out to #es-destrib and ask for a review?
|
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
| private boolean isRepositoryRegistered(String repositoryName) { | ||
| if (repositoryOrNull(ProjectId.DEFAULT, repositoryName) != null) { | ||
| return true; | ||
| } | ||
| boolean found = repositories.values().stream().anyMatch(projectRepos -> projectRepos.containsKey(repositoryName)); | ||
| if (found) { | ||
| return true; | ||
| } | ||
| found = internalRepositories.values().stream().anyMatch(projectRepos -> projectRepos.containsKey(repositoryName)); | ||
| return found; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments:
- We should not check internal repositories since those are used for CCR.
- We should be explicit about it being the default project and not check with any other project
This PR adds a cluster setting for the default repository. The setting defaults to "".
The default repo cannot be deleted, you must change the setting before being able to delete a repo. We check that the repo is registered upon updating the setting. The setting can be cleared by setting it to ""
closes #66040
closes https://github.com/elastic/elasticsearch-team/issues/2103