Copilot commented on code in PR #12140:
URL: https://github.com/apache/cloudstack/pull/12140#discussion_r2569366598
##########
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`.`mshosts` 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;
Review Comment:
This line uses assignment operator (=) instead of comparison operator (==).
It should be `return count == 0;` to check if count equals 0. Currently, this
assigns 0 to count and always returns false, which is the opposite of the
intended logic.
```suggestion
return count == 0;
```
--
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]