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


##########
engine/schema/src/main/java/com/cloud/network/dao/NetworkDomainDaoImpl.java:
##########
@@ -71,4 +92,34 @@ public List<Long> listNetworkIdsByDomain(long domainId) {
         }
         return networkIdsToReturn;
     }
+
+    @Override
+    public Map<Long, List<String>> 
listDomainsOfSharedNetworksUsedByDomainPath(String domainPath) {
+        logger.debug(String.format("Retrieving the domains of the shared 
networks with subdomain access used by domain with path [%s].", domainPath));
+
+        TransactionLegacy txn = TransactionLegacy.currentTxn();
+        try (PreparedStatement pstmt = 
txn.prepareStatement(LIST_DOMAINS_OF_SHARED_NETWORKS_USED_BY_DOMAIN_PATH)) {
+            Map<Long, List<String>> domainsOfSharedNetworksUsedByDomainPath = 
new HashMap<>();
+
+            String domainSearch = domainPath.concat("%");
+            pstmt.setString(1, domainSearch);
+            pstmt.setString(2, domainSearch);
+
+            try (ResultSet rs = pstmt.executeQuery()) {
+                while (rs.next()) {
+                    Long domainId = rs.getLong(1);
+                    List<String> vmUuidsAndNetworkUuids = 
Arrays.asList(rs.getString(2).split(","));
+
+                    domainsOfSharedNetworksUsedByDomainPath.put(domainId, 
vmUuidsAndNetworkUuids);
+                }
+            }
+
+            return domainsOfSharedNetworksUsedByDomainPath;
+        } catch (SQLException e) {
+            logger.error(String.format("Failed to retrieve the domains of the 
shared networks with subdomain access used by domain with path [%s] due to 
[%s]. Returning an empty "
+                    + "list of domains.", domainPath, e.getMessage()), e);

Review Comment:
   @DaanHoogland, when the error happens, if the operator is not with the debug 
logs active, they will not have the stacktrace to track the issue. They would 
have to change the logging level and try to reproduce the error; here's the 
catch: what if we can't reproduce the error easily? 
   
   Also, from my experience, operators tend to search for exception on `ERROR` 
and `WARN` levels, and ignore them in lower level logs (like `INFO` or 
`DEBUG`). What would be the point in printing the stacktrace on `DEBUG` level?



-- 
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