You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "JoaoJandre (via GitHub)" <gi...@apache.org> on 2023/09/18 15:59:30 UTC

[GitHub] [cloudstack] JoaoJandre commented on a diff in pull request #7214: Improve logs when adding components to avoid set

JoaoJandre commented on code in PR #7214:
URL: https://github.com/apache/cloudstack/pull/7214#discussion_r1328947010


##########
api/src/main/java/com/cloud/deploy/DeploymentPlanner.java:
##########
@@ -104,13 +107,27 @@ public ExcludeList(Set<Long> dcIds, Set<Long> podIds, Set<Long> clusterIds, Set<
             }
         }
 
+        private void logAvoid(Class<?> scope, CloudException e) {
+            try {
+                Long id = null;
+                if (e instanceof InsufficientCapacityException) {
+                    id = ((InsufficientCapacityException) e).getId();
+                } else {
+                    id = ((ResourceUnavailableException) e).getResourceId();
+                }
+                LOGGER.trace(String.format("Adding %s [%s] to the avoid set due to [%s].", scope.getSimpleName(), id, e.getMessage()));
+            } catch (Exception ex) {
+                LOGGER.trace(String.format("Failed to log avoided component due to [%s].", ex.getMessage()));
+            }

Review Comment:
   Instead of using a try catch, we should test if `e` is an instance of `ResourceUnavailableException` and if not, just log that the type of `e` is unexpected. This way we can get rid of the try catch block altogether. 



-- 
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: commits-unsubscribe@cloudstack.apache.org

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