Skip to content

Commit

Permalink
Override local disk state if we are able to restore from remote
Browse files Browse the repository at this point in the history
Signed-off-by: bansvaru <bansvaru@amazon.com>
  • Loading branch information
linuxpi committed Oct 19, 2023
1 parent 56736be commit 8d41733
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,15 @@ public void start(
try {
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings))
.version(lastAcceptedVersion)
.metadata(metadata)
.build();

boolean isRemoteStateRestored = false;
if (DiscoveryNode.isClusterManagerNode(settings) && isRemoteStoreClusterStateEnabled(settings)) {
String lastKnownClusterUUID = ClusterState.UNKNOWN_UUID;
// If the cluster UUID loaded from local is unknown (_na_) then fetch the best state from remote
// If there is no valid state on remote, continue with initial empty state
// If there is a valid state, then restore index metadata using this state
String lastKnownClusterUUID = ClusterState.UNKNOWN_UUID;
if (ClusterState.UNKNOWN_UUID.equals(clusterState.metadata().clusterUUID())) {
if (ClusterState.UNKNOWN_UUID.equals(metadata.clusterUUID())) {
lastKnownClusterUUID = remoteClusterStateService.getLastKnownUUIDFromRemote(
clusterState.getClusterName().value()
);
Expand All @@ -181,15 +181,21 @@ public void start(
new String[] {}
);
clusterState = remoteRestoreResult.getClusterState();
isRemoteStateRestored = true;
}
}
remotePersistedState = new RemotePersistedState(remoteClusterStateService, lastKnownClusterUUID);
}

if (isRemoteStateRestored == false) {
clusterState = ClusterState.builder(clusterState).metadata(metadata).build();
}

// Recovers Cluster and Index level blocks
clusterState = prepareInitialClusterState(
transportService,
clusterService,
// if we did not restore from remote, apply the local disk state.
ClusterState.builder(clusterState)
.metadata(upgradeMetadataForNode(clusterState.metadata(), metadataIndexUpgradeService, metadataUpgrader))
.build()
Expand Down

0 comments on commit 8d41733

Please sign in to comment.