Skip to content

Commit

Permalink
Remove featureflag and JoinTaskExecutor changes
Browse files Browse the repository at this point in the history
Signed-off-by: Lakshya Taragi <lakshya.taragi@gmail.com>
  • Loading branch information
ltaragi committed Mar 4, 2024
1 parent 719a369 commit 9fc1b0f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
import org.opensearch.plugins.Plugin;
import org.opensearch.test.OpenSearchIntegTestCase;

import static org.opensearch.cluster.metadata.IndexMetadata.*;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REPLICATION_TYPE;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_SEGMENT_STORE_REPOSITORY;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_REPOSITORY;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_STORE_ENABLED;
import static org.opensearch.node.remotestore.RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING;
import static org.opensearch.node.remotestore.RemoteStoreNodeService.REMOTE_STORE_COMPATIBILITY_MODE_SETTING;
import static org.opensearch.remotestore.RemoteStoreBaseIntegTestCase.remoteStoreClusterSettings;
Expand Down Expand Up @@ -789,7 +792,6 @@ private ClusterRerouteResponse relocateShard (String currentNodeName, String tar

// verify that shard does not exist at targetNode
private void assertNonAllocation (ShardRouting shardRouting) {
logger.info("*** shardRouting: " + shardRouting);
assertFalse(shardRouting.active());
assertNull(shardRouting.currentNodeId());
assertEquals(ShardRoutingState.UNASSIGNED, shardRouting.state());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
import org.opensearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.NodeLoadAwareAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.NodeVersionAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.RemoteStoreMigrationAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.RebalanceOnlyWhenActiveAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.ReplicaAfterPrimaryActiveAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.ResizeAllocationDecider;
Expand Down Expand Up @@ -375,9 +374,6 @@ public static Collection<AllocationDecider> createAllocationDeciders(
addAllocationDecider(deciders, new AwarenessAllocationDecider(settings, clusterSettings));
addAllocationDecider(deciders, new NodeLoadAwareAllocationDecider(settings, clusterSettings));
addAllocationDecider(deciders, new TargetPoolAllocationDecider());
if (FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING)) {
addAllocationDecider(deciders, new RemoteStoreMigrationAllocationDecider(settings, clusterSettings));
}

clusterPlugins.stream()
.flatMap(p -> p.createAllocationDeciders(settings, clusterSettings).stream())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ public class JoinTaskExecutor implements ClusterStateTaskExecutor<JoinTaskExecut

private final RemoteStoreNodeService remoteStoreNodeService;

private static Settings currentNodeSettings = Settings.EMPTY;

/**
* Task for the join task executor.
*
Expand Down Expand Up @@ -147,16 +145,12 @@ public JoinTaskExecutor(
this.logger = logger;
this.rerouteService = rerouteService;
this.remoteStoreNodeService = remoteStoreNodeService;
currentNodeSettings = settings;
}

public static Settings getCurrentNodeSettings() {
return currentNodeSettings;
}

@Override
public ClusterTasksResult<Task> execute(ClusterState currentState, List<Task> joiningNodes) throws Exception {
final ClusterTasksResult.Builder<Task> results = ClusterTasksResult.builder();

final DiscoveryNodes currentNodes = currentState.nodes();
boolean nodesChanged = false;
ClusterState.Builder newState;
Expand Down Expand Up @@ -513,12 +507,9 @@ private static void ensureRemoteStoreNodesCompatibility(DiscoveryNode joiningNod

assert existingNodes.isEmpty() == false;

CompatibilityMode remoteStoreCompatibilityMode = REMOTE_STORE_COMPATIBILITY_MODE_SETTING.get(getCurrentNodeSettings());
if (REMOTE_STORE_COMPATIBILITY_MODE_SETTING.exists(metadata.settings())) {
remoteStoreCompatibilityMode = REMOTE_STORE_COMPATIBILITY_MODE_SETTING.get(metadata.settings());
}

CompatibilityMode remoteStoreCompatibilityMode = REMOTE_STORE_COMPATIBILITY_MODE_SETTING.get(metadata.settings());
if (STRICT.equals(remoteStoreCompatibilityMode)) {

DiscoveryNode existingNode = existingNodes.get(0);
if (joiningNode.isRemoteStoreNode()) {
ensureRemoteStoreNodesCompatibility(joiningNode, existingNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
import org.opensearch.node.remotestore.RemoteStoreNodeService.Direction;
import org.opensearch.node.remotestore.RemoteStoreNodeService.CompatibilityMode;

import java.util.Locale;

/**
* An allocation decider to oversee shard allocation or relocation to facilitate remote-store migration:
* A new allocation decider for migration of document replication clusters to remote store backed clusters:
* - For STRICT compatibility mode, the decision is always YES
* * - For remote_store_enabled indices, relocation or allocation/relocation can only be towards a remote node
* - For remote_store_enabled indices, relocation or allocation/relocation can only be towards a remote node
* - For "REMOTE_STORE" migration direction:
* - New primary shards can only be allocated to a remote node
* - New replica shards can be allocated to a remote node iff the primary has been migrated/allocated to a remote node
Expand Down Expand Up @@ -176,8 +178,9 @@ private String getDecisionDetails(
String reason
) {
return String.format(
Locale.ROOT,
"[%s migration_direction]: %s shard copy %s be %s to a %s node%s",
migrationDirection,
migrationDirection.direction,
(shardRouting.primary() ? "primary" : "replica"),
(isYes ? "can" : "can not"),
(!shardRouting.assignedToNode() ? "allocated" : "relocated"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import org.opensearch.cluster.routing.allocation.decider.NodeLoadAwareAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.NodeVersionAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.RebalanceOnlyWhenActiveAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.RemoteStoreMigrationAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.ReplicaAfterPrimaryActiveAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.ResizeAllocationDecider;
import org.opensearch.cluster.routing.allocation.decider.RestoreInProgressAllocationDecider;
Expand Down Expand Up @@ -244,9 +243,6 @@ public void testAllocationDeciderOrder() {
NodeLoadAwareAllocationDecider.class,
TargetPoolAllocationDecider.class
);
if (FeatureFlags.isEnabled(FeatureFlags.REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING)) {
expectedDeciders.add(RemoteStoreMigrationAllocationDecider.class);
}
Collection<AllocationDecider> deciders = ClusterModule.createAllocationDeciders(
Settings.EMPTY,
new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
package org.opensearch.cluster.routing.allocation;

import org.opensearch.Version;
import org.opensearch.cluster.*;
import org.opensearch.cluster.OpenSearchAllocationTestCase;
import org.opensearch.cluster.ClusterState;
import org.opensearch.cluster.ClusterName;
import org.opensearch.cluster.routing.allocation.decider.RemoteStoreMigrationAllocationDecider;
import org.opensearch.cluster.metadata.IndexMetadata;
import org.opensearch.cluster.metadata.Metadata;
Expand All @@ -48,7 +50,8 @@
import org.opensearch.cluster.routing.ShardRouting;
import org.opensearch.cluster.routing.ShardRoutingState;
import org.opensearch.cluster.routing.TestShardRouting;
import org.opensearch.cluster.routing.allocation.decider.*;
import org.opensearch.cluster.routing.allocation.decider.Decision;
import org.opensearch.cluster.routing.allocation.decider.AllocationDeciders;
import org.opensearch.common.UUIDs;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
Expand All @@ -61,7 +64,10 @@
import java.util.Locale;
import java.util.Map;

import static org.opensearch.cluster.metadata.IndexMetadata.*;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REPLICATION_TYPE;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_SEGMENT_STORE_REPOSITORY;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_TRANSLOG_STORE_REPOSITORY;
import static org.opensearch.cluster.metadata.IndexMetadata.SETTING_REMOTE_STORE_ENABLED;
import static org.opensearch.common.util.FeatureFlags.REMOTE_STORE_MIGRATION_EXPERIMENTAL;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY;
import static org.opensearch.node.remotestore.RemoteStoreNodeService.MIGRATION_DIRECTION_SETTING;
Expand Down

0 comments on commit 9fc1b0f

Please sign in to comment.