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

[controller] Make setting instance group tags for controller cluster resources configurable #1194

Merged
merged 6 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -214,6 +214,8 @@ private ConfigKeys() {
public static final String CONTROLLER_CLUSTER_ZK_ADDRESSS = "controller.cluster.zk.address";
// Name of the Helix cluster for controllers
public static final String CONTROLLER_CLUSTER = "controller.cluster.name";
// What instance group tag to assign to a cluster resource
public static final String CONTROLLER_RESOURCE_INSTANCE_GROUP_TAG = "controller.resource.instance.group.tag";
// What tags to assign to a controller instance
public static final String CONTROLLER_INSTANCE_TAG_LIST = "controller.instance.tag.list";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import org.apache.helix.HelixAdmin;
import org.apache.helix.manager.zk.ZKHelixManager;
import org.apache.helix.model.LiveInstance;
import org.testng.annotations.BeforeClass;
Expand All @@ -44,18 +45,38 @@
public class TestHAASController {
private Properties enableControllerClusterHAASProperties;
private Properties enableControllerAndStorageClusterHAASProperties;
private final static String instanceTag = "GENERAL";

@BeforeClass
public void setUp() {
enableControllerClusterHAASProperties = new Properties();
enableControllerClusterHAASProperties.put(ConfigKeys.CONTROLLER_CLUSTER_LEADER_HAAS, String.valueOf(true));
enableControllerClusterHAASProperties
.put(ConfigKeys.CONTROLLER_HAAS_SUPER_CLUSTER_NAME, HelixAsAServiceWrapper.HELIX_SUPER_CLUSTER_NAME);
enableControllerClusterHAASProperties.put(ConfigKeys.CONTROLLER_RESOURCE_INSTANCE_GROUP_TAG, instanceTag);
enableControllerClusterHAASProperties.put(ConfigKeys.CONTROLLER_INSTANCE_TAG_LIST, instanceTag);

nisargthakkar marked this conversation as resolved.
Show resolved Hide resolved
enableControllerAndStorageClusterHAASProperties = (Properties) enableControllerClusterHAASProperties.clone();
enableControllerAndStorageClusterHAASProperties
.put(ConfigKeys.VENICE_STORAGE_CLUSTER_LEADER_HAAS, String.valueOf(true));
}

@Test(timeOut = 60 * Time.MS_PER_SECOND)
public void testClusterResourceInstanceTag() {
try (VeniceClusterWrapper venice = ServiceFactory.getVeniceCluster(0, 0, 0, 1);
HelixAsAServiceWrapper helixAsAServiceWrapper = startAndWaitForHAASToBeAvailable(venice.getZk().getAddress())) {
VeniceControllerWrapper controllerWrapper =
venice.addVeniceController(enableControllerAndStorageClusterHAASProperties);

String controllerClusterName = "venice-controllers";
HelixAdmin helixAdmin = controllerWrapper.getVeniceHelixAdmin().getHelixAdmin();
List<String> resources = helixAdmin.getResourcesInClusterWithTag(controllerClusterName, instanceTag);
assertEquals(resources.size(), 1);
List<String> instances = helixAdmin.getInstancesInClusterWithTag(controllerClusterName, instanceTag);
assertEquals(instances.size(), 1);
}
}

@Test(timeOut = 60 * Time.MS_PER_SECOND)
public void testStartHAASHelixControllerAsControllerClusterLeader() {
try (VeniceClusterWrapper venice = ServiceFactory.getVeniceCluster(0, 0, 0, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import static com.linkedin.venice.ConfigKeys.CONTROLLER_PARENT_SYSTEM_STORE_REPAIR_CHECK_INTERVAL_SECONDS;
import static com.linkedin.venice.ConfigKeys.CONTROLLER_PARENT_SYSTEM_STORE_REPAIR_RETRY_COUNT;
import static com.linkedin.venice.ConfigKeys.CONTROLLER_PARENT_SYSTEM_STORE_REPAIR_SERVICE_ENABLED;
import static com.linkedin.venice.ConfigKeys.CONTROLLER_RESOURCE_INSTANCE_GROUP_TAG;
import static com.linkedin.venice.ConfigKeys.CONTROLLER_SCHEMA_VALIDATION_ENABLED;
import static com.linkedin.venice.ConfigKeys.CONTROLLER_SSL_ENABLED;
import static com.linkedin.venice.ConfigKeys.CONTROLLER_STORE_GRAVEYARD_CLEANUP_DELAY_MINUTES;
Expand Down Expand Up @@ -224,6 +225,7 @@ public class VeniceControllerClusterConfig {
// Name of the Helix cluster for controllers
private final String controllerClusterName;
private final String controllerClusterZkAddress;
private final String controllerResourceInstanceGroupTag;
private final List<String> controllerInstanceTagList;
private final boolean multiRegion;
private final boolean parent;
Expand Down Expand Up @@ -637,6 +639,7 @@ public VeniceControllerClusterConfig(VeniceProperties props) {
*/
this.adminCheckReadMethodForKafka = props.getBoolean(ADMIN_CHECK_READ_METHOD_FOR_KAFKA, true);
this.controllerClusterName = props.getString(CONTROLLER_CLUSTER, "venice-controllers");
this.controllerResourceInstanceGroupTag = props.getString(CONTROLLER_RESOURCE_INSTANCE_GROUP_TAG, "");
this.controllerInstanceTagList = props.getList(CONTROLLER_INSTANCE_TAG_LIST, Collections.emptyList());
this.controllerClusterReplica = props.getInt(CONTROLLER_CLUSTER_REPLICA, 3);
this.controllerClusterZkAddress = props.getString(CONTROLLER_CLUSTER_ZK_ADDRESSS, getZkAddress());
Expand Down Expand Up @@ -1164,6 +1167,10 @@ public String getControllerClusterName() {
return controllerClusterName;
}

public String getControllerResourceInstanceGroupTag() {
return controllerResourceInstanceGroupTag;
}

public List<String> getControllerInstanceTagList() {
return controllerInstanceTagList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,17 @@ public void addVeniceStorageClusterToControllerCluster(String clusterName) {
LeaderStandbySMD.name,
IdealState.RebalanceMode.FULL_AUTO.toString(),
AutoRebalanceStrategy.class.getName());
VeniceControllerClusterConfig config = multiClusterConfigs.getControllerConfig(clusterName);
IdealState idealState = helixAdmin.getResourceIdealState(controllerClusterName, clusterName);
idealState.setMinActiveReplicas(controllerClusterReplicaCount);
idealState.setRebalancerClassName(DelayedAutoRebalancer.class.getName());
idealState.setRebalanceStrategy(CrushRebalanceStrategy.class.getName());

String instanceGroupTag = config.getControllerResourceInstanceGroupTag();
if (!instanceGroupTag.isEmpty()) {
idealState.setInstanceGroupTag(instanceGroupTag);
}

helixAdmin.setResourceIdealState(controllerClusterName, clusterName, idealState);
helixAdmin.rebalance(controllerClusterName, clusterName, controllerClusterReplicaCount);
} catch (Exception e) {
Expand Down
Loading