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

Make SnapshotsInProgress project compatible #125470

Merged

Conversation

ywangd
Copy link
Member

@ywangd ywangd commented Mar 24, 2025

This PR adds project-id to both SnapshotsInProgress and Snapshot so that they are aware of projects and ready to handle snapshots from multiple projects.

Relates: ES-10224

This PR adds project-id to both SnapshotsInProgress and Snapshot so that
they are aware of projects and ready to handle snapshots from multiple
projects.

Relates: ES-10224
@ywangd ywangd marked this pull request as ready for review March 24, 2025 06:49
@ywangd ywangd added >non-issue :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs labels Mar 24, 2025
@ywangd ywangd requested review from pxsalehi, DaveCTurner and a team March 24, 2025 06:50
@elasticsearchmachine elasticsearchmachine added the Team:Distributed Coordination Meta label for Distributed Coordination team label Mar 24, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination)

Comment on lines 72 to 75
@Deprecated(forRemoval = true)
static ProjectRepo defaultProjectRepo(String repoName) {
return new ProjectRepo(ProjectId.DEFAULT, repoName);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add @FixForMultiProject? Also, wouldn't it make more sense to use Metadata.DEFAULT_PROJECT_ID here as this is a temporary usage?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted this method as part of the changes to add an extra ProjectId argument. See also #125470 (comment)

@ywangd ywangd requested a review from nielsbauman March 25, 2025 02:38
Copy link
Member

@pxsalehi pxsalehi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some small suggestions.

final var oldVersion = TransportVersionUtils.getPreviousVersion(TransportVersions.PROJECT_ID_IN_SNAPSHOT);
final BytesStreamOutput out = new BytesStreamOutput();
out.setTransportVersion(oldVersion);
final Custom orig = createTestInstance(() -> randomSnapshot(ProjectId.DEFAULT));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: origin? Original? :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with original. see e211f26

if (isOldCluster()) {
// create an index to have one shard per node
createIndex(indexName, indexSettings(3, 0).put("index.routing.allocation.total_shards_per_node", 1).build());
ensureGreen(indexName);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the sake of completeness maybe (randomly) index some data?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure see e211f26

flush(indexName, true);
// Signal shutdown to prevent snapshot from being completed
putShutdownMetadata(nodeIds);
registerRepository(repositoryName, "fs", randomBoolean(), Settings.builder().put("location", "backup").build());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: maybe doesn't matter, but seems more readable to register the repo a bit earlier?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved as suggested

assertRunningSnapshot(repositoryName, snapshotName);
} else {
if (isUpgradedCluster()) {
deleteShutdownMetadata(nodeIds);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe assert that no shutdown metadata exists after deleting it. It might make possible test failures more concrete.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have SnapshotShutdownProgressTracker reporting quite detailed information about shard snapshot pausing and resuming due to shutdown. That said, it does not hurt to double check as well. So I added it in e211f26

Copy link
Contributor

@nielsbauman nielsbauman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for the explanations!

@ywangd ywangd added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Mar 26, 2025
@elasticsearchmachine elasticsearchmachine merged commit 0c8daae into elastic:main Mar 26, 2025
17 checks passed
@ywangd ywangd deleted the mp/snapshots-in-progress-migration branch March 26, 2025 23:55
omricohenn pushed a commit to omricohenn/elasticsearch that referenced this pull request Mar 28, 2025
This PR adds project-id to both SnapshotsInProgress and Snapshot so that
they are aware of projects and ready to handle snapshots from multiple
projects.

Relates: ES-10224
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >non-issue Team:Distributed Coordination Meta label for Distributed Coordination team v9.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants