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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to