Skip to content

Commit 42414f4

Browse files
author
Daan Hoogland
committed
make condition not fatal
1 parent 2135e1e commit 42414f4

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -451,15 +451,15 @@ public void check() {
451451
throw new CloudRuntimeException("Unable to acquire lock to check for database integrity.");
452452
}
453453

454-
// not sure about the right moment to do this yet
455-
checkIfStandalone();
456-
doUpgrades(lock);
454+
if (isStandalone()) {
455+
doUpgrades(lock);
456+
}
457457
} finally {
458458
lock.releaseRef();
459459
}
460460
}
461-
private void checkIfStandalone() throws CloudRuntimeException {
462-
boolean standalone = Transaction.execute(new TransactionCallback<>() {
461+
private boolean isStandalone() throws CloudRuntimeException {
462+
return Transaction.execute(new TransactionCallback<>() {
463463
@Override
464464
public Boolean doInTransaction(TransactionStatus status) {
465465
String sql = "SELECT COUNT(*) FROM `cloud`.`mshost` WHERE `state` = 'UP'";
@@ -473,16 +473,11 @@ public Boolean doInTransaction(TransactionStatus status) {
473473
} catch (SQLException e) {
474474
String errorMessage = "Unable to check if the management server is running in standalone mode.";
475475
LOGGER.error(errorMessage, e);
476-
throw new CloudRuntimeException(errorMessage, e);
476+
return false;
477477
}
478478
return true;
479479
}
480480
});
481-
if (! standalone) {
482-
String msg = "CloudStack is running multiple management servers while attempting to upgrade. Upgrades can only be run in standalone mode. Aborting.";
483-
LOGGER.info(msg);
484-
throw new CloudRuntimeException(msg);
485-
}
486481
}
487482

488483
private void doUpgrades(GlobalLock lock) {

0 commit comments

Comments
 (0)