-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Migrate RepositoriesMetadata to ProjectCustom #125398
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
Migrate RepositoriesMetadata to ProjectCustom #125398
Conversation
|
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
| .metadata( | ||
| Metadata.builder(currentState.getMetadata()) | ||
| .putCustom( | ||
| .putDefaultProjectCustom( |
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 makes the repository explicitly work with the default project. Otherwise, it throws MultiProjectPendingException in some multi-project enabled tests. It worked previously because repositories are cluster custom which does not check the number of projects. It is a temporary workaround (the method is marked as deprecated for removal) and will be removed once repository and snapshot fully support multi-project.
| LicensesMetadata licensesMetadata = new LicensesMetadata(license, TrialLicenseVersion.CURRENT); | ||
| RepositoryMetadata repositoryMetadata = new RepositoryMetadata("repo", "fs", Settings.EMPTY); | ||
| RepositoriesMetadata repositoriesMetadata = new RepositoriesMetadata(Collections.singletonList(repositoryMetadata)); | ||
| NodesShutdownMetadata nodesShutdownMetadata = new NodesShutdownMetadata(Map.of()); |
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 test just needs a different Metadata#ClusterCustom that is not licenses.
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.
I'm pretty concerned with the complexity of the surgery being introduced into the (already complex) diff-serialization process. Did we explore any alternatives? For instance, could we keep this info in cluster-wide customs until org.elasticsearch.cluster.ClusterState#getMinTransportVersion advances far enough that we won't need the BwC complexity?
|
It would require v10 to completely advance this change since v9.0 still stores it in cluster customs. I'd rather to pay for the complexity once similar to how we did it for persistent tasks split so that what's left is removing it once we hit v10, part of it can even be dropped once serverless advances in a few week's time. And it will be in the "final" state. I am sure v10 will come with its own pile of tasks, so overall I think it's better to fix it now. |
|
I don't think that's a very strong argument for introducing this level of complexity right now. We will never need to send a diff from a v9.0 node (using cluster-level repositories) to any v10.x node using project-level ones, and we will need to keep the code for fixing this up when loading the |
Can you expand on this? What exactly will be dropped? Sorry if I've missed something obvious but I couldn't work out which bit you meant here. |
| assert out.getTransportVersion().onOrAfter(TransportVersions.MULTI_PROJECT) | ||
| && out.getTransportVersion().before(TransportVersions.REPOSITORIES_METADATA_AS_PROJECT_CUSTOM) : out.getTransportVersion(); |
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.
@DaveCTurner I meant this method which is most of the new complexity. Versions between MULTI_PROJECT and REPOSITORIES_METADATA_AS_PROJECT_CUSTOM are only released in serverless. Once serverless rolls forward, we can remove it.
|
Diffs are not needed for full cluster restart, only xcontent which has rather minimal BWC changes. |
|
I see, ok, I had missed that if this lands in 9.1 then that becomes dead code. I see there is already prior art for this diff-surgery approach too. I didn't know that, and FTR my discomfort with this PR extends to that prior art too, but I guess we have to roll forwards with it for now. |
|
Yeah let's roll forward 😄 |
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.
To my eyes, these changes look ok. But this is quite tricky to review. So I'd rather leave the final review/LGTM to David.
|
Thanks for taking a look, Pooya. Let me provide a bit high level explanation and see whether it helps. The issue is that we need to split an entry from BWC reading and writing for the entire
The above logic is encapsulated in method @tvernum @nielsbauman Though it is labelled with snapshot/restore, the changes are more for namespacing and tied with previous Metadata changes. I'd appreciate if you could also take a look at this PR since you are familiar with the context. Thank you! |
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 definitely not the most confident approval I've ever given. I agree with David and Pooya (and probably you do too) that this seralization logic is becoming extremely complex and unreadable. I'm happy some of this can be dropped in a few weeks already. I don't immediately have any better suggestions.
| throwForVersionBeforeRepositoriesMetadataMigration(out); | ||
| } | ||
| // RepositoriesMetadata found for the default project as an upsert, package it as MapDiff and merge into Metadata#customs | ||
| combineClustersCustoms.set( |
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.
I'm probably missing something here, but just to double check: is it guaranteed that only one of these lambdas reaches the end? In other words, are we sure we won't encounter non-empty repositories for the default project in both upserts and diffs? I just want to make sure combineClusterCustoms.set() is only called once.
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.
Yes, upserts and diffs are mutually exclusive, see
elasticsearch/server/src/main/java/org/elasticsearch/cluster/DiffableUtils.java
Lines 337 to 348 in dd58b0b
| if (previousValue == null) { | |
| upserts.add(entry); | |
| inserts++; | |
| } else if (entry.getValue().equals(previousValue) == false) { | |
| if (valueSerializer.supportsDiffableValues()) { | |
| diffs.add( | |
| new AbstractMap.SimpleImmutableEntry<>(entry.getKey(), valueSerializer.diff(entry.getValue(), previousValue)) | |
| ); | |
| } else { | |
| upserts.add(entry); | |
| } | |
| } |
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.
LGTM for a very loose definition of "good" which includes:
- this is at least well-covered by existing tests
- there are no obvious mistakes here
- I cannot think of a better way of doing this given where we are today
|
@elasticmachine update branch |
|
Thanks all for the reviews! 🙏 |
This PR migrates RepositoriesMetadata from Metadata#ClusterCustom to Metadata#ProjectCustom and handles wire BWC. Resolves: ES-10477
When migrating RepositoriesMetadata from cluster custom to project custom, we needed temporary BWC handling for clusters running on a version that is before this change but after the initial MP change. Such a cluster can only exist in the serverless environment which has progressed way past any applicable versions. Therefore we no longer need the BWC handling and this PR removes it. Relates: elastic#125398
When migrating RepositoriesMetadata from cluster custom to project custom (#125398), we needed temporary BWC handling for clusters running on a version that is before this change but after the initial MP change. Such a cluster can only exist in the serverless environment which has progressed way past any applicable versions. Therefore we no longer need the BWC handling and this PR removes it. Relates: #125398
When migrating RepositoriesMetadata from cluster custom to project custom (elastic#125398), we needed temporary BWC handling for clusters running on a version that is before this change but after the initial MP change. Such a cluster can only exist in the serverless environment which has progressed way past any applicable versions. Therefore we no longer need the BWC handling and this PR removes it. Relates: elastic#125398
When migrating RepositoriesMetadata from cluster custom to project custom (elastic#125398), we needed temporary BWC handling for clusters running on a version that is before this change but after the initial MP change. Such a cluster can only exist in the serverless environment which has progressed way past any applicable versions. Therefore we no longer need the BWC handling and this PR removes it. Relates: elastic#125398
This PR migrates RepositoriesMetadata from Metadata#ClusterCustom to Metadata#ProjectCustom and handles wire BWC.
Resolves: ES-10477