From a32de521e6ec86f9dfa01a9ec6243119d950c3f0 Mon Sep 17 00:00:00 2001 From: xyuanlu Date: Tue, 26 Nov 2024 15:15:40 -0800 Subject: [PATCH] fix enabled --- .../java/org/apache/helix/model/InstanceConfig.java | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; }