-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Migrate the reserved repository action to be per-project #130155
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
Changes from 3 commits
b6c7e6d
0a0e257
0bfd808
073351c
7cd1101
d99b052
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,9 +12,8 @@ | |
| import org.elasticsearch.action.admin.cluster.repositories.put.PutRepositoryRequest; | ||
| import org.elasticsearch.cluster.ClusterState; | ||
| import org.elasticsearch.cluster.metadata.ProjectId; | ||
| import org.elasticsearch.core.FixForMultiProject; | ||
| import org.elasticsearch.repositories.RepositoriesService; | ||
| import org.elasticsearch.reservedstate.ReservedClusterStateHandler; | ||
| import org.elasticsearch.reservedstate.ReservedProjectStateHandler; | ||
| import org.elasticsearch.reservedstate.TransformState; | ||
| import org.elasticsearch.xcontent.XContentParser; | ||
| import org.elasticsearch.xcontent.XContentParserConfiguration; | ||
|
|
@@ -36,7 +35,7 @@ | |
| * It is used by the ReservedClusterStateService to add/update or remove snapshot repositories. Typical usage | ||
| * for this action is in the context of file based settings. | ||
| */ | ||
| public class ReservedRepositoryAction implements ReservedClusterStateHandler<List<PutRepositoryRequest>> { | ||
| public class ReservedRepositoryAction implements ReservedProjectStateHandler<List<PutRepositoryRequest>> { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basic question. In a non-MP stateless cluster, this is still sufficient because now the cluster back up repo falls under the "default" project? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Additionally, we have ProjectClusterStateHandlerAdapter which reads the reserved state from the main There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is correct, no need to explicitly handle the non-MP case. |
||
| public static final String NAME = "snapshot_repositories"; | ||
|
|
||
| private final RepositoriesService repositoriesService; | ||
|
|
@@ -56,28 +55,24 @@ public String name() { | |
| } | ||
|
|
||
| @SuppressWarnings("unchecked") | ||
| public Collection<PutRepositoryRequest> prepare(Object input) { | ||
| public Collection<PutRepositoryRequest> prepare(ProjectId projectId, Object input) { | ||
| List<PutRepositoryRequest> repositories = (List<PutRepositoryRequest>) input; | ||
|
|
||
| for (var repositoryRequest : repositories) { | ||
| validate(repositoryRequest); | ||
| RepositoriesService.validateRepositoryName(repositoryRequest.name()); | ||
| @FixForMultiProject(description = "resolve the actual projectId, ES-10479") | ||
| final var projectId = ProjectId.DEFAULT; | ||
| repositoriesService.validateRepositoryCanBeCreated(projectId, repositoryRequest); | ||
| } | ||
|
|
||
| return repositories; | ||
| } | ||
|
|
||
| @Override | ||
| public TransformState transform(List<PutRepositoryRequest> source, TransformState prevState) throws Exception { | ||
| var requests = prepare(source); | ||
| public TransformState transform(ProjectId projectId, List<PutRepositoryRequest> source, TransformState prevState) throws Exception { | ||
| var requests = prepare(projectId, source); | ||
|
|
||
| ClusterState state = prevState.state(); | ||
|
|
||
| @FixForMultiProject(description = "resolve the actual projectId, ES-10479") | ||
| final var projectId = ProjectId.DEFAULT; | ||
| for (var request : requests) { | ||
| RepositoriesService.RegisterRepositoryTask task = new RepositoriesService.RegisterRepositoryTask( | ||
| repositoriesService, | ||
|
|
||
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.
This is copied from the same check from other other reserved project-state actions such as this one. There is room for de-duplication as suggested by the comment, but I'll leave it out from this PR.