Skip to content

Commit c3ef955

Browse files
author
Harish Bhakuni
committed
Address PR Comments
Signed-off-by: Harish Bhakuni <hbhakuni@amazon.com>
1 parent fe70d7d commit c3ef955

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

server/src/main/java/org/opensearch/repositories/RepositoriesService.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.apache.logging.log4j.LogManager;
3636
import org.apache.logging.log4j.Logger;
3737
import org.apache.logging.log4j.message.ParameterizedMessage;
38+
import org.opensearch.Version;
3839
import org.opensearch.action.ActionListener;
3940
import org.opensearch.action.ActionRunnable;
4041
import org.opensearch.action.admin.cluster.repositories.delete.DeleteRepositoryRequest;
@@ -79,6 +80,8 @@
7980
import java.util.stream.Collectors;
8081
import java.util.stream.Stream;
8182

83+
import static org.opensearch.repositories.blobstore.BlobStoreRepository.REMOTE_STORE_INDEX_SHALLOW_COPY;
84+
8285
/**
8386
* Service responsible for maintaining and providing access to snapshot repositories on nodes.
8487
*
@@ -160,6 +163,7 @@ public void registerRepository(final PutRepositoryRequest request, final ActionL
160163

161164
final RepositoryMetadata newRepositoryMetadata = new RepositoryMetadata(request.name(), request.type(), request.settings());
162165
validate(request.name());
166+
validateRepositoryMetadataSettings(clusterService, request.name(), request.settings());
163167

164168
final ActionListener<ClusterStateUpdateResponse> registrationListener;
165169
if (request.verify()) {
@@ -605,6 +609,26 @@ private static void validate(final String repositoryName) {
605609
}
606610
}
607611

612+
public static void validateRepositoryMetadataSettings(
613+
ClusterService clusterService,
614+
final String repositoryName,
615+
final Settings repositoryMetadataSettings
616+
) {
617+
// We can add more validations here for repository settings in the future.
618+
Version minVersionInCluster = clusterService.state().getNodes().getMinNodeVersion();
619+
if (REMOTE_STORE_INDEX_SHALLOW_COPY.get(repositoryMetadataSettings) && !minVersionInCluster.onOrAfter(Version.V_2_9_0)) {
620+
throw new RepositoryException(
621+
repositoryName,
622+
"setting "
623+
+ REMOTE_STORE_INDEX_SHALLOW_COPY.getKey()
624+
+ " cannot be enabled as some of the nodes in cluster are on version older than "
625+
+ Version.V_2_9_0
626+
+ ". Minimum node version in cluster is: "
627+
+ minVersionInCluster
628+
);
629+
}
630+
}
631+
608632
private static void ensureRepositoryNotInUse(ClusterState clusterState, String repository) {
609633
if (isRepositoryInUse(clusterState, repository)) {
610634
throw new IllegalStateException("trying to modify or unregister repository that is currently used");

server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ private void snapshot(
394394
GatedCloseable<IndexCommit> wrappedSnapshot = null;
395395
try {
396396
if (remoteStoreIndexShallowCopy && indexShard.indexSettings().isRemoteStoreEnabled()) {
397-
long startTime = threadPool.absoluteTimeInMillis();
397+
long startTime = threadPool.relativeTimeInMillis();
398398
// we flush first to make sure we get the latest writes snapshotted
399399
wrappedSnapshot = indexShard.acquireLastIndexCommitAndRefresh(true);
400400
long primaryTerm = indexShard.getOperationPrimaryTerm();
@@ -426,7 +426,7 @@ private void snapshot(
426426
indexShard.releaseLockOnCommitData(snapshot.getSnapshotId().getUUID(), primaryTerm, commitGeneration);
427427
throw e;
428428
}
429-
long endTime = threadPool.absoluteTimeInMillis();
429+
long endTime = threadPool.relativeTimeInMillis();
430430
logger.debug(
431431
"Time taken (in milliseconds) to complete shallow copy snapshot, "
432432
+ "for index "

server/src/main/java/org/opensearch/snapshots/SnapshotsService.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,16 +338,6 @@ public ClusterState execute(ClusterState currentState) {
338338
}
339339

340340
boolean remoteStoreIndexShallowCopy = REMOTE_STORE_INDEX_SHALLOW_COPY.get(repository.getMetadata().settings());
341-
Version minVersionInCluster = currentState.nodes().getMinNodeVersion();
342-
if (remoteStoreIndexShallowCopy && !minVersionInCluster.onOrAfter(Version.V_2_9_0)) {
343-
remoteStoreIndexShallowCopy = false;
344-
logger.warn(
345-
"Setting {} is ignored as some of the nodes in cluster are on version older than {}. Minimum node version in cluster is: {}",
346-
REMOTE_STORE_INDEX_SHALLOW_COPY,
347-
Version.V_2_9_0,
348-
minVersionInCluster
349-
);
350-
}
351341
newEntry = SnapshotsInProgress.startedEntry(
352342
new Snapshot(repositoryName, snapshotId),
353343
request.includeGlobalState(),

0 commit comments

Comments
 (0)