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

implicitly set replication type SEGMENT in remote store enabled cluster if nothing specified by user #9264

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,16 @@ public static Settings remoteStoreClusterSettings(
}

public static Settings remoteStoreClusterSettings(String segmentRepoName, String translogRepoName) {
return Settings.builder()
.put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT)
Settings.Builder settingsBuilder = Settings.builder()
.put(CLUSTER_REMOTE_STORE_ENABLED_SETTING.getKey(), true)
.put(CLUSTER_REMOTE_SEGMENT_STORE_REPOSITORY_SETTING.getKey(), segmentRepoName)
.put(CLUSTER_REMOTE_TRANSLOG_REPOSITORY_SETTING.getKey(), translogRepoName)
.build();
.put(CLUSTER_REMOTE_TRANSLOG_REPOSITORY_SETTING.getKey(), translogRepoName);

if (randomBoolean()) {
settingsBuilder.put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT);
}

return settingsBuilder.build();
}

private Settings defaultIndexSettings() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
import org.opensearch.indices.InvalidIndexNameException;
import org.opensearch.indices.ShardLimitValidator;
import org.opensearch.indices.SystemIndices;
import org.opensearch.indices.replication.common.ReplicationType;
import org.opensearch.threadpool.ThreadPool;

import java.io.IOException;
Expand Down Expand Up @@ -932,15 +933,15 @@ static Settings aggregateIndexSettings(
* @param clusterSettings cluster level settings
*/
private static void updateReplicationStrategy(Settings.Builder settingsBuilder, Settings requestSettings, Settings clusterSettings) {
if (CLUSTER_REPLICATION_TYPE_SETTING.exists(clusterSettings) && INDEX_REPLICATION_TYPE_SETTING.exists(requestSettings) == false) {
settingsBuilder.put(SETTING_REPLICATION_TYPE, CLUSTER_REPLICATION_TYPE_SETTING.get(clusterSettings));
return;
}
if (INDEX_REPLICATION_TYPE_SETTING.exists(requestSettings) == true) {
if (INDEX_REPLICATION_TYPE_SETTING.exists(requestSettings)) {
settingsBuilder.put(SETTING_REPLICATION_TYPE, INDEX_REPLICATION_TYPE_SETTING.get(requestSettings));
return;
} else if (CLUSTER_REPLICATION_TYPE_SETTING.exists(clusterSettings)) {
settingsBuilder.put(SETTING_REPLICATION_TYPE, CLUSTER_REPLICATION_TYPE_SETTING.get(clusterSettings));
} else if (CLUSTER_REMOTE_STORE_ENABLED_SETTING.get(clusterSettings)) {
settingsBuilder.put(SETTING_REPLICATION_TYPE, ReplicationType.SEGMENT);
} else {
settingsBuilder.put(SETTING_REPLICATION_TYPE, CLUSTER_REPLICATION_TYPE_SETTING.get(clusterSettings));
linuxpi marked this conversation as resolved.
Show resolved Hide resolved
}
settingsBuilder.put(SETTING_REPLICATION_TYPE, CLUSTER_REPLICATION_TYPE_SETTING.getDefault(clusterSettings));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1245,6 +1245,37 @@ public void testRemoteStoreNoUserOverrideExceptReplicationTypeSegmentIndexSettin
);
}

public void testRemoteStoreImplicitOverrideReplicationTypeToSegmentForRemoteStore() {
Settings settings = Settings.builder()
.put(CLUSTER_REMOTE_STORE_ENABLED_SETTING.getKey(), true)
.put(CLUSTER_REMOTE_SEGMENT_STORE_REPOSITORY_SETTING.getKey(), "my-segment-repo-1")
.put(CLUSTER_REMOTE_TRANSLOG_REPOSITORY_SETTING.getKey(), "my-translog-repo-1")
.build();
FeatureFlagSetter.set(FeatureFlags.REMOTE_STORE);

request = new CreateIndexClusterStateUpdateRequest("create index", "test", "test");
final Settings.Builder requestSettings = Settings.builder();
request.settings(requestSettings.build());
Settings indexSettings = aggregateIndexSettings(
ClusterState.EMPTY_STATE,
request,
Settings.EMPTY,
null,
settings,
IndexScopedSettings.DEFAULT_SCOPED_SETTINGS,
randomShardLimitService(),
Collections.emptySet()
);
verifyRemoteStoreIndexSettings(
indexSettings,
"true",
"my-segment-repo-1",
"my-translog-repo-1",
ReplicationType.SEGMENT.toString(),
IndexSettings.DEFAULT_REMOTE_TRANSLOG_BUFFER_INTERVAL
);
}

public void testRemoteStoreNoUserOverrideIndexSettings() {
Settings settings = Settings.builder()
.put(CLUSTER_REPLICATION_TYPE_SETTING.getKey(), ReplicationType.SEGMENT)
Expand Down
Loading