Skip to content

Commit

Permalink
Ensure no impact to existing remote restore and update UTs
Browse files Browse the repository at this point in the history
Signed-off-by: bansvaru <[email protected]>
  • Loading branch information
linuxpi committed Oct 18, 2023
1 parent 4650fbb commit 439c73b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -454,10 +454,11 @@ public Builder initializeAsRemoteStoreRestore(
IndexMetadata indexMetadata,
RemoteStoreRecoverySource recoverySource,
Map<ShardId, IndexShardRoutingTable> indexShardRoutingTableMap,
boolean forceRecoverAllPrimaries
boolean forceRecoverAllPrimaries,
boolean metadataFromRemoteStore
) {
final UnassignedInfo unassignedInfo = new UnassignedInfo(
UnassignedInfo.Reason.REMOTE_METADATA_RECOVERED,
metadataFromRemoteStore ? UnassignedInfo.Reason.REMOTE_METADATA_RECOVERED : UnassignedInfo.Reason.EXISTING_INDEX_RESTORED,
"restore_source[remote_store]"
);
assert indexMetadata.getIndex().equals(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,17 @@ public Builder addAsRemoteStoreRestore(
IndexMetadata indexMetadata,
RemoteStoreRecoverySource recoverySource,
Map<ShardId, IndexShardRoutingTable> indexShardRoutingTableMap,
boolean forceRecoveryPrimary
boolean forceRecoveryPrimary,
boolean metadataFromRemoteStore
) {
IndexRoutingTable.Builder indexRoutingBuilder = new IndexRoutingTable.Builder(indexMetadata.getIndex())
.initializeAsRemoteStoreRestore(indexMetadata, recoverySource, indexShardRoutingTableMap, forceRecoveryPrimary);
.initializeAsRemoteStoreRestore(
indexMetadata,
recoverySource,
indexShardRoutingTableMap,
forceRecoveryPrimary,
metadataFromRemoteStore
);
add(indexRoutingBuilder);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ public enum Reason {
* Unassigned as a result of closing an index.
*/
INDEX_CLOSED,

/**
* Unassigned as restored from Remote Metadata.
*/
REMOTE_METADATA_RECOVERED
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ private RemoteRestoreResult executeRestore(
updatedIndexMetadata,
recoverySource,
indexShardRoutingTableMap,
restoreAllShards || metadataFromRemoteStore
restoreAllShards,
metadataFromRemoteStore
);
blocks.updateBlocks(updatedIndexMetadata);
mdBuilder.put(updatedIndexMetadata, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ public void testAddAsRemoteStoreRestoreAllUnassigned() {
indexMetadata,
remoteStoreRecoverySource,
getIndexShardRoutingTableMap(indexMetadata.getIndex(), true, numberOfReplicas),
false,
false
).build();
assertTrue(routingTable.hasIndex(TEST_INDEX_1));
Expand Down Expand Up @@ -623,6 +624,7 @@ public void testAddAsRemoteStoreRestoreWithActiveShards() {
indexMetadata,
remoteStoreRecoverySource,
indexShardRoutingTableMap,
false,
false
).build();
assertTrue(routingTable.hasIndex(TEST_INDEX_1));
Expand Down Expand Up @@ -665,6 +667,7 @@ public void testAddAsRemoteStoreRestoreShardMismatch() {
indexMetadata,
remoteStoreRecoverySource,
indexShardRoutingTableMap,
false,
false
).build()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ public void testSkipRoutingTableUpdateWhenRemoteRecovery() {
new IndexId(remoteMetadata.getIndex().getName(), remoteMetadata.getIndexUUID())
),
new HashMap<>(),
true,
true
);
final Index index = remoteMetadata.getIndex();
Expand All @@ -393,7 +394,7 @@ public void testSkipRoutingTableUpdateWhenRemoteRecovery() {
assertEquals(
numOfShards,
newRemoteIndexRoutingTable.shardsMatchingPredicateCount(
shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.EXISTING_INDEX_RESTORED)
shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.REMOTE_METADATA_RECOVERED)
)
);
assertEquals(
Expand Down Expand Up @@ -427,6 +428,7 @@ public void testSkipRoutingTableUpdateWhenRemoteRecovery() {
new IndexId(remoteMetadata.getIndex().getName(), remoteMetadata.getIndexUUID())
),
new HashMap<>(),
true,
true
);
IndexRoutingTable.Builder nonRemoteBuilderWithoutRemoteRecovery = new IndexRoutingTable.Builder(nonRemoteMetadata.getIndex())
Expand Down Expand Up @@ -456,7 +458,7 @@ public void testSkipRoutingTableUpdateWhenRemoteRecovery() {
assertEquals(
numOfShards,
newRemoteIndexRoutingTable.shardsMatchingPredicateCount(
shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.EXISTING_INDEX_RESTORED)
shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.REMOTE_METADATA_RECOVERED)
)
);
assertEquals(
Expand Down Expand Up @@ -516,6 +518,7 @@ public void testSkipRoutingTableUpdateWhenRemoteRecovery() {
new IndexId(remoteMetadata.getIndex().getName(), remoteMetadata.getIndexUUID())
),
new HashMap<>(),
true,
true
);
IndexRoutingTable.Builder remoteBuilderWithoutRemoteRecovery = new IndexRoutingTable.Builder(
Expand Down Expand Up @@ -547,7 +550,7 @@ public void testSkipRoutingTableUpdateWhenRemoteRecovery() {
assertEquals(
numOfShards,
newRemoteIndexRoutingTable.shardsMatchingPredicateCount(
shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.EXISTING_INDEX_RESTORED)
shardRouting -> shardRouting.unassignedInfo().getReason().equals(UnassignedInfo.Reason.REMOTE_METADATA_RECOVERED)
)
);
assertEquals(
Expand Down

0 comments on commit 439c73b

Please sign in to comment.