DaanHoogland commented on code in PR #12140:
URL: https://github.com/apache/cloudstack/pull/12140#discussion_r2571982752


##########
engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java:
##########
@@ -448,39 +451,71 @@ public void check() {
                 throw new CloudRuntimeException("Unable to acquire lock to 
check for database integrity.");
             }
 
-            try {
-                initializeDatabaseEncryptors();
+            // not sure about the right moment to do this yet
+            checkIfStandalone();
+            doUpgrades(lock);
+        } finally {
+            lock.releaseRef();
+        }
+    }
+    private void checkIfStandalone() throws CloudRuntimeException {
+        boolean standalone = Transaction.execute(new TransactionCallback<>() {
+            @Override
+            public Boolean doInTransaction(TransactionStatus status) {
+                String sql = "SELECT COUNT(*) FROM `cloud`.`mshost` WHERE 
`state` = 'UP'";
+                try (Connection conn = 
TransactionLegacy.getStandaloneConnection();
+                     PreparedStatement pstmt = conn.prepareStatement(sql);
+                     ResultSet rs = pstmt.executeQuery()) {
+                    if (rs.next()) {
+                        int count = rs.getInt(1);
+                        return count == 0;
+                    }
+                } catch (SQLException e) {
+                    String errorMessage = "Unable to check if the management 
server is running in standalone mode.";
+                    LOGGER.error(errorMessage, e);
+                    throw new CloudRuntimeException(errorMessage, e);
+                }
+                return true;

Review Comment:
   maybe be save and return false as we are not sure.



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