You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2020/03/04 22:34:07 UTC

[GitHub] [helix] NealSun96 opened a new pull request #858: Add error handling to getInstanceById

NealSun96 opened a new pull request #858: Add error handling to getInstanceById
URL: https://github.com/apache/helix/pull/858
 
 
   ### Issues
   
   - [x] My PR addresses the following Helix issues and references them in the PR description:
   
   Fixes #857
   
   ### Description
   
   - [x] Here are some details about my PR, including screenshots of any UI changes:
   
   This PR add logs and exception throws across all vulnerable points in relevant code to the `getInstanceById` endpoint. We want to prevent the endpoint from silently failing.
   
   ### Tests
   - [] The following is the result of the "mvn test" command on the appropriate module:
   
   
   ### Commits
   
   - [x] My commits all reference appropriate Apache Helix GitHub issues in their subject lines, and I have squashed multiple commits if they address the same issue. 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
   
   - [x] My diff has been formatted using helix-style.xml

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#discussion_r388037214
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
 ##########
 @@ -266,6 +269,9 @@ public static boolean isInstanceStable(HelixDataAccessor dataAccessor, String in
       IdealState idealState = dataAccessor.getProperty(keyBuilder.idealStates(idealStateName));
       if (idealState == null || !idealState.isEnabled() || !idealState.isValid()
           || TaskConstants.STATE_MODEL_NAME.equals(idealState.getStateModelDefRef())) {
+        _logger.warn(
+            "idealState is either null, not enabled, not valid, or has Task as stateModelDefRef. IdealState: {}",
+            instanceName);
 
 Review comment:
   You're not catching anything here, right? Also if IdealState is null, you skip over that resource, right? Would that ever cause a problem?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#discussion_r388015261
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
 ##########
 @@ -266,6 +269,9 @@ public static boolean isInstanceStable(HelixDataAccessor dataAccessor, String in
       IdealState idealState = dataAccessor.getProperty(keyBuilder.idealStates(idealStateName));
       if (idealState == null || !idealState.isEnabled() || !idealState.isValid()
           || TaskConstants.STATE_MODEL_NAME.equals(idealState.getStateModelDefRef())) {
+        _logger.warn(
+            "idealState is either null, not enabled, not valid, or has Task as stateModelDefRef. IdealState: {}",
+            instanceName);
 
 Review comment:
   This won't make things fail, will it?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] narendly merged pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
narendly merged pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858
 
 
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#discussion_r388015858
 
 

 ##########
 File path: helix-rest/src/main/java/org/apache/helix/rest/server/service/InstanceServiceImpl.java
 ##########
 @@ -101,9 +103,15 @@ public InstanceInfo getInstanceInfo(String clusterId, String instanceName,
             _dataAccessor.keyBuilder().currentState(instanceName, sessionId, resourceName));
         if (currentState != null && currentState.getPartitionStateMap() != null) {
           partitions.addAll(currentState.getPartitionStateMap().keySet());
+        } else {
+          LOG.warn(
+              "Current state is either null or partitionStateMap is missing. InstanceName: {}, SessionId: {}, ResourceName: {}",
+              instanceName, sessionId, resourceName);
         }
       }
       instanceInfoBuilder.partitions(partitions);
+    } else {
+      LOG.warn("Missing instance config for {}", instanceName);
 
 Review comment:
   LiveInstance?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] NealSun96 commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#discussion_r388035730
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
 ##########
 @@ -266,6 +269,9 @@ public static boolean isInstanceStable(HelixDataAccessor dataAccessor, String in
       IdealState idealState = dataAccessor.getProperty(keyBuilder.idealStates(idealStateName));
       if (idealState == null || !idealState.isEnabled() || !idealState.isValid()
           || TaskConstants.STATE_MODEL_NAME.equals(idealState.getStateModelDefRef())) {
+        _logger.warn(
+            "idealState is either null, not enabled, not valid, or has Task as stateModelDefRef. IdealState: {}",
+            instanceName);
 
 Review comment:
   I mostly want to ensure the case of `idealState == null` is caught. That situation shouldn't happen. 
   Regardless, I don't have a strong opinion about this. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] NealSun96 commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#discussion_r388022876
 
 

 ##########
 File path: helix-rest/src/main/java/org/apache/helix/rest/server/service/InstanceServiceImpl.java
 ##########
 @@ -101,9 +103,15 @@ public InstanceInfo getInstanceInfo(String clusterId, String instanceName,
             _dataAccessor.keyBuilder().currentState(instanceName, sessionId, resourceName));
         if (currentState != null && currentState.getPartitionStateMap() != null) {
           partitions.addAll(currentState.getPartitionStateMap().keySet());
+        } else {
+          LOG.warn(
+              "Current state is either null or partitionStateMap is missing. InstanceName: {}, SessionId: {}, ResourceName: {}",
+              instanceName, sessionId, resourceName);
         }
       }
       instanceInfoBuilder.partitions(partitions);
+    } else {
+      LOG.warn("Missing instance config for {}", instanceName);
 
 Review comment:
   Oops, let me fix that. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] NealSun96 commented on issue #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on issue #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#issuecomment-595481931
 
 
   This PR is ready to be merged, approved by @narendly
   Final commit message:
   ## Add logs and throw exceptions in getInstanceById ##

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#discussion_r388028332
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
 ##########
 @@ -266,6 +269,9 @@ public static boolean isInstanceStable(HelixDataAccessor dataAccessor, String in
       IdealState idealState = dataAccessor.getProperty(keyBuilder.idealStates(idealStateName));
       if (idealState == null || !idealState.isEnabled() || !idealState.isValid()
           || TaskConstants.STATE_MODEL_NAME.equals(idealState.getStateModelDefRef())) {
+        _logger.warn(
+            "idealState is either null, not enabled, not valid, or has Task as stateModelDefRef. IdealState: {}",
+            instanceName);
 
 Review comment:
   This block mostly exists to filter out non-existing IdealStates and Task Framework idealStates. The reason I pointed this out is because I don't think it will add much in debugging and it will just end up making the log file large. Let's not log this.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] NealSun96 commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
NealSun96 commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#discussion_r388022752
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
 ##########
 @@ -266,6 +269,9 @@ public static boolean isInstanceStable(HelixDataAccessor dataAccessor, String in
       IdealState idealState = dataAccessor.getProperty(keyBuilder.idealStates(idealStateName));
       if (idealState == null || !idealState.isEnabled() || !idealState.isValid()
           || TaskConstants.STATE_MODEL_NAME.equals(idealState.getStateModelDefRef())) {
+        _logger.warn(
+            "idealState is either null, not enabled, not valid, or has Task as stateModelDefRef. IdealState: {}",
+            instanceName);
 
 Review comment:
   While this block doesn't fail the code, it's triggered in situations where idealState is null or is invalid. Just like the logs I did in `InstanceServiceImpl.java`, I think it's a good idea to log these unusual situations for debug purposes. 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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


[GitHub] [helix] narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById

Posted by GitBox <gi...@apache.org>.
narendly commented on a change in pull request #858: Add logs and throw exceptions in getInstanceById
URL: https://github.com/apache/helix/pull/858#discussion_r388015261
 
 

 ##########
 File path: helix-core/src/main/java/org/apache/helix/util/InstanceValidationUtil.java
 ##########
 @@ -266,6 +269,9 @@ public static boolean isInstanceStable(HelixDataAccessor dataAccessor, String in
       IdealState idealState = dataAccessor.getProperty(keyBuilder.idealStates(idealStateName));
       if (idealState == null || !idealState.isEnabled() || !idealState.isValid()
           || TaskConstants.STATE_MODEL_NAME.equals(idealState.getStateModelDefRef())) {
+        _logger.warn(
+            "idealState is either null, not enabled, not valid, or has Task as stateModelDefRef. IdealState: {}",
+            instanceName);
 
 Review comment:
   This won't make things fail, will it? Since we are doing a continue, I don't think this would be necessary.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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