diff --git a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java index 2b46c0830b5..373234c22dd 100644 --- a/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java +++ b/server/src/com/cloud/upgrade/DatabaseUpgradeChecker.java @@ -73,10 +73,13 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { ScriptRunner runner = new ScriptRunner(conn, false, true); runner.runScript(reader); } catch (FileNotFoundException e) { + s_logger.error("Unable to find upgrade script: " + file.getAbsolutePath(), e); throw new CloudRuntimeException("Unable to find upgrade script: " + file.getAbsolutePath(), e); } catch (IOException e) { + s_logger.error("Unable to read upgrade script: " + file.getAbsolutePath(), e); throw new CloudRuntimeException("Unable to read upgrade script: " + file.getAbsolutePath(), e); } catch (SQLException e) { + s_logger.error("Unable to execute upgrade script: " + file.getAbsolutePath(), e); throw new CloudRuntimeException("Unable to execute upgrade script: " + file.getAbsolutePath(), e); } } @@ -89,10 +92,12 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { DbUpgrade[] upgrades = _upgradeMap.get(trimmedDbVersion); if (upgrades == null) { + s_logger.error("There is no upgrade path from " + dbVersion + " to " + currentVersion); throw new CloudRuntimeException("There is no upgrade path from " + dbVersion + " to " + currentVersion); } if (Version.compare(trimmedCurrentVersion, upgrades[upgrades.length - 1].getUpgradedVersion()) != 0) { + s_logger.error("The end upgrade version is actually at " + upgrades[upgrades.length - 1].getUpgradedVersion() + " but our management server code version is at " + currentVersion); throw new CloudRuntimeException("The end upgrade version is actually at " + upgrades[upgrades.length - 1].getUpgradedVersion() + " but our management server code version is at " + currentVersion); } @@ -106,6 +111,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { } if (!supportsRollingUpgrade && ClusterManagerImpl.arePeersRunning(null)) { + s_logger.error("Unable to run upgrade because the upgrade sequence does not support rolling update and there are other management server nodes running"); throw new CloudRuntimeException("Unable to run upgrade because the upgrade sequence does not support rolling update and there are other management server nodes running"); } @@ -119,6 +125,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { try { conn = txn.getConnection(); } catch (SQLException e) { + s_logger.error("Unable to upgrade the database", e); throw new CloudRuntimeException("Unable to upgrade the database", e); } File[] scripts = upgrade.getPrepareScripts(); @@ -127,6 +134,7 @@ public class DatabaseUpgradeChecker implements SystemIntegrityChecker { runScript(script); } } + upgrade.performDataMigration(conn); boolean upgradeVersion = true; diff --git a/server/src/com/cloud/upgrade/dao/Upgrade218to22.java b/server/src/com/cloud/upgrade/dao/Upgrade218to22.java index 8a6cdedab13..8d08a1b09d8 100644 --- a/server/src/com/cloud/upgrade/dao/Upgrade218to22.java +++ b/server/src/com/cloud/upgrade/dao/Upgrade218to22.java @@ -847,6 +847,7 @@ public class Upgrade218to22 implements DbUpgrade { pstmt = conn.prepareStatement("SELECT id FROM network_offerings WHERE name='System-Management-Network'"); rs = pstmt.executeQuery(); if (!rs.next()) { + s_logger.error("Unable to find the management network offering."); throw new CloudRuntimeException("Unable to find the management network offering."); } long managementNetworkOfferingId = rs.getLong(1); @@ -856,6 +857,7 @@ public class Upgrade218to22 implements DbUpgrade { pstmt = conn.prepareStatement("SELECT id FROM network_offerings WHERE name='System-Public-Network'"); rs = pstmt.executeQuery(); if (!rs.next()) { + s_logger.error("Unable to find the public network offering."); throw new CloudRuntimeException("Unable to find the public network offering."); } long publicNetworkOfferingId = rs.getLong(1); @@ -865,6 +867,7 @@ public class Upgrade218to22 implements DbUpgrade { pstmt = conn.prepareStatement("SELECT id FROM network_offerings WHERE name='System-Control-Network'"); rs = pstmt.executeQuery(); if (!rs.next()) { + s_logger.error("Unable to find the control network offering."); throw new CloudRuntimeException("Unable to find the control network offering."); } long controlNetworkOfferingId = rs.getLong(1); @@ -874,6 +877,7 @@ public class Upgrade218to22 implements DbUpgrade { pstmt = conn.prepareStatement("SELECT id FROM network_offerings WHERE name='System-Storage-Network'"); rs = pstmt.executeQuery(); if (!rs.next()) { + s_logger.error("Unable to find the storage network offering."); throw new CloudRuntimeException("Unable to find the storage network offering."); } long storageNetworkOfferingId = rs.getLong(1); @@ -1082,6 +1086,7 @@ public class Upgrade218to22 implements DbUpgrade { deleteOrphanedTemplateRef(conn); } catch (SQLException e) { + s_logger.error("Can't update data center ", e); throw new CloudRuntimeException("Can't update data center ", e); } } @@ -1721,12 +1726,20 @@ public class Upgrade218to22 implements DbUpgrade { @Override public void performDataMigration(Connection conn) { - upgradeDataCenter(conn); - upgradeStoragePools(conn); - upgradeInstanceGroups(conn); - upgradePortForwardingRules(conn); - upgradeLoadBalancingRules(conn); - migrateEvents(conn); + try { + PreparedStatement pstmt = conn.prepareStatement("USE cloud"); + pstmt.executeQuery(); + upgradeDataCenter(conn); + upgradeStoragePools(conn); + upgradeInstanceGroups(conn); + upgradePortForwardingRules(conn); + upgradeLoadBalancingRules(conn); + migrateEvents(conn); + } catch (SQLException e) { + s_logger.error("Can't perform data migration ", e); + throw new CloudRuntimeException("Can't perform data migration ", e); + } + } @Override