Skip to content

Commit

Permalink
Allow clearing remote_store.compatibility_mode setting (opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#13646)

Signed-off-by: Bhumika Saini <sabhumik@amazon.com>
  • Loading branch information
Bhumika Saini authored and parv0201 committed Jun 10, 2024
1 parent 4a1aa5c commit 01f64bf
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed
- Fix negative RequestStats metric issue ([#13553](https://github.com/opensearch-project/OpenSearch/pull/13553))
- Fix get field mapping API returns 404 error in mixed cluster with multiple versions ([#13624](https://github.com/opensearch-project/OpenSearch/pull/13624))
- Allow clearing `remote_store.compatibility_mode` setting ([#13646](https://github.com/opensearch-project/OpenSearch/pull/13646))

### Security

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.opensearch.test.InternalTestCluster;
import org.opensearch.test.OpenSearchIntegTestCase;

import java.io.IOException;
import java.nio.file.Path;
import java.util.Optional;

Expand All @@ -26,6 +27,8 @@
public class RemoteStoreMigrationSettingsUpdateIT extends RemoteStoreMigrationShardAllocationBaseTestCase {

private Client client;
private String nonRemoteNodeName;
private String remoteNodeName;

// remote store backed index setting tests

Expand Down Expand Up @@ -120,18 +123,7 @@ public void testNewRestoredIndexIsRemoteStoreBackedForRemoteStoreDirectionAndMix
// compatibility mode setting test

public void testSwitchToStrictMode() throws Exception {
logger.info("Initialize cluster");
initializeCluster(false);

logger.info("Create a mixed mode cluster");
setClusterMode(MIXED.mode);
addRemote = true;
String remoteNodeName = internalCluster().startNode();
addRemote = false;
String nonRemoteNodeName = internalCluster().startNode();
internalCluster().validateClusterFormed();
assertNodeInCluster(remoteNodeName);
assertNodeInCluster(nonRemoteNodeName);
createMixedModeCluster();

logger.info("Attempt switching to strict mode");
SettingsException exception = assertThrows(SettingsException.class, () -> setClusterMode(STRICT.mode));
Expand All @@ -140,12 +132,39 @@ public void testSwitchToStrictMode() throws Exception {
exception.getMessage()
);

stopRemoteNode();

logger.info("Attempt switching to strict mode");
setClusterMode(STRICT.mode);
}

public void testClearCompatibilityModeSetting() throws Exception {
createMixedModeCluster();
stopRemoteNode();

logger.info("Attempt clearing compatibility mode");
clearClusterMode();
}

private void stopRemoteNode() throws IOException {
logger.info("Stop remote node so that cluster had only non-remote nodes");
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(remoteNodeName));
ensureStableCluster(2);
}

logger.info("Attempt switching to strict mode");
setClusterMode(STRICT.mode);
private void createMixedModeCluster() {
logger.info("Initialize cluster");
initializeCluster(false);

logger.info("Create a mixed mode cluster");
setClusterMode(MIXED.mode);
addRemote = true;
remoteNodeName = internalCluster().startNode();
addRemote = false;
nonRemoteNodeName = internalCluster().startNode();
internalCluster().validateClusterFormed();
assertNodeInCluster(remoteNodeName);
assertNodeInCluster(nonRemoteNodeName);
}

// bootstrap a cluster
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ protected void setClusterMode(String mode) {
assertAcked(internalCluster().client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
}

protected void clearClusterMode() {
updateSettingsRequest.persistentSettings(Settings.builder().putNull(REMOTE_STORE_COMPATIBILITY_MODE_SETTING.getKey()));
assertAcked(internalCluster().client().admin().cluster().updateSettings(updateSettingsRequest).actionGet());
}

// set the migration direction for cluster [remote_store, docrep, none]
protected void setDirection(String direction) {
updateSettingsRequest.persistentSettings(Settings.builder().put(MIGRATION_DIRECTION_SETTING.getKey(), direction));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@

import java.io.IOException;
import java.util.Collection;
import java.util.Locale;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -285,9 +284,9 @@ public ClusterState execute(final ClusterState currentState) {
public void validateCompatibilityModeSettingRequest(ClusterUpdateSettingsRequest request, ClusterState clusterState) {
Settings settings = Settings.builder().put(request.persistentSettings()).put(request.transientSettings()).build();
if (RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING.exists(settings)) {
String value = settings.get(RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING.getKey()).toLowerCase(Locale.ROOT);
String value = RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING.get(settings).mode;
validateAllNodesOfSameVersion(clusterState.nodes());
if (value.equals(RemoteStoreNodeService.CompatibilityMode.STRICT.mode)) {
if (RemoteStoreNodeService.CompatibilityMode.STRICT.mode.equals(value)) {
validateAllNodesOfSameType(clusterState.nodes());
validateIndexSettings(clusterState);
}
Expand Down

0 comments on commit 01f64bf

Please sign in to comment.