You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by "xyuanlu (via GitHub)" <gi...@apache.org> on 2023/08/15 21:50:34 UTC

[GitHub] [helix] xyuanlu opened a new pull request, #2598: Instance Evacuation operation sanity check

xyuanlu opened a new pull request, #2598:
URL: https://github.com/apache/helix/pull/2598

   ### Issues
   
   - [ ] My PR addresses the following Helix issues and references them in the PR description:
   
   (#200 - Link your issue number here: You can write "Fixes #XXX". Please use the proper keyword so that the issue gets closed automatically. See https://docs.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue
   Any of the following keywords can be used: close, closes, closed, fix, fixes, fixed, resolve, resolves, resolved)
   
   ### Description
   
   - [ ] Here are some details about my PR, including screenshots of any UI changes:
   
   (Write a concise description including what, why, how)
   
   ### Tests
   
   - [ ] The following tests are written for this issue:
   
   (List the names of added unit/integration tests)
   
   - The following is the result of the "mvn test" command on the appropriate module:
   
   (If CI test fails due to known issue, please specify the issue and test PR locally. Then copy & paste the result of "mvn test" to here.)
   
   ### Changes that Break Backward Compatibility (Optional)
   
   - My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:
   
   (Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zpinto commented on a diff in pull request #2598: Instance Evacuation operation sanity check

Posted by "zpinto (via GitHub)" <gi...@apache.org>.
zpinto commented on code in PR #2598:
URL: https://github.com/apache/helix/pull/2598#discussion_r1298056771


##########
helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java:
##########
@@ -331,10 +344,15 @@ public long getInstanceEnabledTime() {
   }
 
   public void setInstanceOperation(InstanceConstants.InstanceOperation operation) {
-    // TODO: also setInstanceEnabled after sanity check.
+    if (operation != InstanceConstants.InstanceOperation.DISABLE
+        && operation != InstanceConstants.InstanceOperation.ENABLE && !getInstanceEnabled()) {
+      throw new HelixException(
+          "setting non enable/disable operation (e.g. evacuate, swap) to helix disabled instance is not allowed");
+    } else {
+      setInstanceEnabledHelper(operation == InstanceConstants.InstanceOperation.ENABLE);

Review Comment:
   This will set HELIX_ENABLED to false for `InstanceConstants.InstanceOperation.EVACUATE` and other operation types when HELIX_ENABLED is true. This should only be called if operation is `ENABLE` or `DISABLE` because HELIX_ENABLED should stay true when we persist `EVACUATE` or other operation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] xyuanlu commented on a diff in pull request #2598: Instance Evacuation operation sanity check

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu commented on code in PR #2598:
URL: https://github.com/apache/helix/pull/2598#discussion_r1296649107


##########
helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java:
##########
@@ -264,9 +264,22 @@ public boolean getInstanceEnabled() {
    * @param enabled true to enable, false to disable
    */
   public void setInstanceEnabled(boolean enabled) {
+    // set instance operation only when we need to change InstanceEnabled value.
+    // When enabling an instance where HELIX_ENABLED is false, we update INSTANCE_OPERATION to 'ENABLE'
+    // When disabling and instance where HELIX_ENABLED is false, we overwrite what current operation and
+    // update INSTANCE_OPERATION to 'DISABLE'.
+    String instanceOperationKey = InstanceConfigProperty.INSTANCE_OPERATION.toString();
+    if (enabled != getInstanceEnabled() && _record.getSimpleField(instanceOperationKey) != null) {

Review Comment:
   Had an offline discussion. We update both operation and helix-enabled when current enabled is not the same as provided value. We also update operation regardless of if there is existing value or not. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] xyuanlu merged pull request #2598: Instance Evacuation operation sanity check

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu merged PR #2598:
URL: https://github.com/apache/helix/pull/2598


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] junkaixue commented on a diff in pull request #2598: Instance Evacuation operation sanity check

Posted by "junkaixue (via GitHub)" <gi...@apache.org>.
junkaixue commented on code in PR #2598:
URL: https://github.com/apache/helix/pull/2598#discussion_r1296456009


##########
helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java:
##########
@@ -331,10 +344,17 @@ public long getInstanceEnabledTime() {
   }
 
   public void setInstanceOperation(InstanceConstants.InstanceOperation operation) {
-    // TODO: also setInstanceEnabled after sanity check.
+    if (operation != InstanceConstants.InstanceOperation.DISABLE
+        && operation != InstanceConstants.InstanceOperation.ENABLE) {
+      if (!getInstanceEnabled()) {
+        throw new HelixException(
+            "setting non enable/disable operation (e.g. evacuate, swap) to helix disabled instance is not allowed");
+      }
+    } else {
+      setInstanceEnabledHelper(operation == InstanceConstants.InstanceOperation.ENABLE);
+    }

Review Comment:
   can be simplified as:
   
   if (operation != InstanceConstants.InstanceOperation.DISABLE
            && operation != InstanceConstants.InstanceOperation.ENABLE && !getInstanceEnabled()) {
            throw new HelixException(
               XXX);
        }
   
   setInstanceEnabledHelper(operation == InstanceConstants.InstanceOperation.ENABLE);
   



##########
helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java:
##########
@@ -264,9 +264,22 @@ public boolean getInstanceEnabled() {
    * @param enabled true to enable, false to disable
    */
   public void setInstanceEnabled(boolean enabled) {
+    // set instance operation only when we need to change InstanceEnabled value.
+    // When enabling an instance where HELIX_ENABLED is false, we update INSTANCE_OPERATION to 'ENABLE'
+    // When disabling and instance where HELIX_ENABLED is false, we overwrite what current operation and
+    // update INSTANCE_OPERATION to 'DISABLE'.
+    String instanceOperationKey = InstanceConfigProperty.INSTANCE_OPERATION.toString();
+    if (enabled != getInstanceEnabled() && _record.getSimpleField(instanceOperationKey) != null) {

Review Comment:
   !getInstanceEnabled()



##########
helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java:
##########
@@ -264,9 +264,22 @@ public boolean getInstanceEnabled() {
    * @param enabled true to enable, false to disable
    */
   public void setInstanceEnabled(boolean enabled) {
+    // set instance operation only when we need to change InstanceEnabled value.
+    // When enabling an instance where HELIX_ENABLED is false, we update INSTANCE_OPERATION to 'ENABLE'
+    // When disabling and instance where HELIX_ENABLED is false, we overwrite what current operation and
+    // update INSTANCE_OPERATION to 'DISABLE'.
+    String instanceOperationKey = InstanceConfigProperty.INSTANCE_OPERATION.toString();
+    if (enabled != getInstanceEnabled() && _record.getSimpleField(instanceOperationKey) != null) {
+      _record.setSimpleField(instanceOperationKey,

Review Comment:
   I would suggest not set but use the record get with DEFAULT value as ENABLED. Because you may write back the enable. This is usual pattern Helix is trying to avoid.



##########
helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java:
##########
@@ -264,9 +264,22 @@ public boolean getInstanceEnabled() {
    * @param enabled true to enable, false to disable
    */
   public void setInstanceEnabled(boolean enabled) {
+    // set instance operation only when we need to change InstanceEnabled value.
+    // When enabling an instance where HELIX_ENABLED is false, we update INSTANCE_OPERATION to 'ENABLE'
+    // When disabling and instance where HELIX_ENABLED is false, we overwrite what current operation and
+    // update INSTANCE_OPERATION to 'DISABLE'.
+    String instanceOperationKey = InstanceConfigProperty.INSTANCE_OPERATION.toString();
+    if (enabled != getInstanceEnabled() && _record.getSimpleField(instanceOperationKey) != null) {
+      _record.setSimpleField(instanceOperationKey,
+          enabled ? InstanceConstants.InstanceOperation.ENABLE.toString()

Review Comment:
   name() instead of toString() for Enum types



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] xyuanlu commented on pull request #2598: Instance Evacuation operation sanity check

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu commented on PR #2598:
URL: https://github.com/apache/helix/pull/2598#issuecomment-1686710030

   This change is ready to be merged. Approved by @zpinto 
   Commit message: Instance Evacuation operation sanity check


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] xyuanlu commented on a diff in pull request #2598: Instance Evacuation operation sanity check

Posted by "xyuanlu (via GitHub)" <gi...@apache.org>.
xyuanlu commented on code in PR #2598:
URL: https://github.com/apache/helix/pull/2598#discussion_r1296648609


##########
helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java:
##########
@@ -264,9 +264,22 @@ public boolean getInstanceEnabled() {
    * @param enabled true to enable, false to disable
    */
   public void setInstanceEnabled(boolean enabled) {
+    // set instance operation only when we need to change InstanceEnabled value.
+    // When enabling an instance where HELIX_ENABLED is false, we update INSTANCE_OPERATION to 'ENABLE'
+    // When disabling and instance where HELIX_ENABLED is false, we overwrite what current operation and
+    // update INSTANCE_OPERATION to 'DISABLE'.
+    String instanceOperationKey = InstanceConfigProperty.INSTANCE_OPERATION.toString();
+    if (enabled != getInstanceEnabled() && _record.getSimpleField(instanceOperationKey) != null) {
+      _record.setSimpleField(instanceOperationKey,
+          enabled ? InstanceConstants.InstanceOperation.ENABLE.toString()

Review Comment:
   Updated
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org