Pearl1594 commented on a change in pull request #4582:
URL: https://github.com/apache/cloudstack/pull/4582#discussion_r567712717
##########
File path:
engine/schema/src/main/java/com/cloud/upgrade/DatabaseUpgradeChecker.java
##########
@@ -232,11 +233,41 @@ protected void runScript(Connection conn, InputStream
file) {
}
+ private void updateSystemVmTemplates(DbUpgrade[] upgrades) {
+ for (int i = upgrades.length - 1; i >= 0; i--) {
+ DbUpgrade upgrade = upgrades[i];
+ if (upgrade instanceof DbUpgradeSystemVmTemplate) {
+ TransactionLegacy txn = TransactionLegacy.open("Upgrade");
+ txn.start();
+ try {
+ Connection conn;
+ try {
+ conn = txn.getConnection();
+ } catch (SQLException e) {
+ String errorMessage = "Unable to upgrade the database";
+ s_logger.error(errorMessage, e);
+ throw new CloudRuntimeException(errorMessage, e);
+ }
+
((DbUpgradeSystemVmTemplate)upgrade).updateSystemVmTemplates(conn);
+ break;
+ } catch (CloudRuntimeException e) {
+ String errorMessage = "Unable to upgrade the database";
+ s_logger.error(errorMessage, e);
+ throw new CloudRuntimeException(errorMessage, e);
+ } finally {
+ txn.close();
Review comment:
@weizhouapache I tested this by merging this code to master. However,
the steps are equivalent to :
1. Deploy a 4.14 env
2. Register the template (4.15 template)
3. upgrade to 4.15
4. The Management server comes up fine, but, if we check the
cloud.configuration value (in the DB) for attribute -
"router.template.<hypervisor>" notice it doesn't update the template name to
the new one.
The case of not applying the DB changes when template isn't registered,
works absolutely fine.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]