diff --git a/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java b/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java index 1b3acd68d6..29f7db4cb0 100644 --- a/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java +++ b/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java @@ -656,6 +656,17 @@ public InstanceOperation getInstanceOperation() { .build(); } + // if instance operation id DISABLE, we override it to ENABLE if instance is enabled + if (activeInstanceOperation.equals(InstanceConstants.InstanceOperation.DISABLE)) { + // it is not likely that instanceEnabled is unset, because when we set operation to disable, + // we always set instanceEnabled to false + // If instance is enabled by old version helix (not having instance operation), the instance config + // will have HELIX_ENABLED set to true. In this case, we should override the instance operation to ENABLE + if ("true".equals(_record.getSimpleField(InstanceConfigProperty.HELIX_ENABLED.name()))) { + return new InstanceOperation.Builder().setOperation(InstanceConstants.InstanceOperation.ENABLE).build(); + } + } + return activeInstanceOperation; }