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

[Snapshot Interop] Keep API parameters behind remote store experiment… #8594

Merged
merged 1 commit into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.opensearch.common.io.stream.StreamOutput;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.core.common.Strings;
import org.opensearch.core.xcontent.ToXContentObject;
import org.opensearch.core.xcontent.XContentBuilder;
Expand Down Expand Up @@ -150,7 +151,7 @@ public RestoreSnapshotRequest(StreamInput in) throws IOException {
if (in.getVersion().onOrAfter(Version.V_2_7_0)) {
storageType = in.readEnum(StorageType.class);
}
if (in.getVersion().onOrAfter(Version.V_2_9_0)) {
if (FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE) && in.getVersion().onOrAfter(Version.V_2_9_0)) {
sourceRemoteStoreRepository = in.readOptionalString();
}
}
Expand All @@ -174,7 +175,7 @@ public void writeTo(StreamOutput out) throws IOException {
if (out.getVersion().onOrAfter(Version.V_2_7_0)) {
out.writeEnum(storageType);
}
if (out.getVersion().onOrAfter(Version.V_2_9_0)) {
if (FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE) && out.getVersion().onOrAfter(Version.V_2_9_0)) {
out.writeOptionalString(sourceRemoteStoreRepository);
}
}
Expand Down Expand Up @@ -614,6 +615,11 @@ public RestoreSnapshotRequest source(Map<String, Object> source) {
}

} else if (name.equals("source_remote_store_repository")) {
if (!FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE)) {
throw new IllegalArgumentException(
"Unsupported parameter " + name + ". Please enable remote store feature flag for this experimental feature"
);
}
if (entry.getValue() instanceof String) {
setSourceRemoteStoreRepository((String) entry.getValue());
} else {
Expand Down Expand Up @@ -664,7 +670,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
if (storageType != null) {
storageType.toXContent(builder);
}
if (sourceRemoteStoreRepository != null) {
if (FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE) && sourceRemoteStoreRepository != null) {
builder.field("source_remote_store_repository", sourceRemoteStoreRepository);
}
builder.endObject();
Expand All @@ -681,7 +687,7 @@ public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
RestoreSnapshotRequest that = (RestoreSnapshotRequest) o;
return waitForCompletion == that.waitForCompletion
boolean equals = waitForCompletion == that.waitForCompletion
&& includeGlobalState == that.includeGlobalState
&& partial == that.partial
&& includeAliases == that.includeAliases
Expand All @@ -694,27 +700,48 @@ public boolean equals(Object o) {
&& Objects.equals(indexSettings, that.indexSettings)
&& Arrays.equals(ignoreIndexSettings, that.ignoreIndexSettings)
&& Objects.equals(snapshotUuid, that.snapshotUuid)
&& Objects.equals(storageType, that.storageType)
&& Objects.equals(sourceRemoteStoreRepository, that.sourceRemoteStoreRepository);
&& Objects.equals(storageType, that.storageType);
if (FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE)) {
equals = Objects.equals(sourceRemoteStoreRepository, that.sourceRemoteStoreRepository);
}
return equals;
}

@Override
public int hashCode() {
int result = Objects.hash(
snapshot,
repository,
indicesOptions,
renamePattern,
renameReplacement,
waitForCompletion,
includeGlobalState,
partial,
includeAliases,
indexSettings,
snapshotUuid,
storageType,
sourceRemoteStoreRepository
);
int result;
if (FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE)) {
result = Objects.hash(
snapshot,
repository,
indicesOptions,
renamePattern,
renameReplacement,
waitForCompletion,
includeGlobalState,
partial,
includeAliases,
indexSettings,
snapshotUuid,
storageType,
sourceRemoteStoreRepository
);
} else {
result = Objects.hash(
snapshot,
repository,
indicesOptions,
renamePattern,
renameReplacement,
waitForCompletion,
includeGlobalState,
partial,
includeAliases,
indexSettings,
snapshotUuid,
storageType
);
}
result = 31 * result + Arrays.hashCode(indices);
result = 31 * result + Arrays.hashCode(ignoreIndexSettings);
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.opensearch.common.settings.Setting;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.util.FeatureFlags;
import org.opensearch.common.util.concurrent.ConcurrentCollections;
import org.opensearch.common.util.io.IOUtils;
import org.opensearch.repositories.blobstore.MeteredBlobStoreRepository;
Expand Down Expand Up @@ -627,6 +628,12 @@ public static void validateRepositoryMetadataSettings(
+ minVersionInCluster
);
}
if (REMOTE_STORE_INDEX_SHALLOW_COPY.get(repositoryMetadataSettings) && !FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE)) {
throw new RepositoryException(
repositoryName,
"setting " + REMOTE_STORE_INDEX_SHALLOW_COPY.getKey() + " cannot be enabled, as remote store feature is not enabled."
);
}
}

private static void ensureRepositoryNotInUse(ClusterState clusterState, String repository) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,12 @@ public ClusterState execute(ClusterState currentState) {
final boolean isRemoteStoreShallowCopy = Boolean.TRUE.equals(
snapshotInfo.isRemoteStoreIndexShallowCopyEnabled()
) && metadata.index(index).getSettings().getAsBoolean(SETTING_REMOTE_STORE_ENABLED, false);
if (isSearchableSnapshot && isRemoteStoreShallowCopy) {
throw new SnapshotRestoreException(
snapshot,
"Shallow copy snapshot cannot be restored as searchable snapshot."
);
}
if (isRemoteStoreShallowCopy && !currentState.getNodes().getMinNodeVersion().onOrAfter(Version.V_2_9_0)) {
throw new SnapshotRestoreException(
snapshot,
Expand Down