Skip to content

Commit f4e4be0

Browse files
author
Prachi Damle
committed
CLOUDSTACK-4668: Upgrade to 4.2 fails with NullPointerException when hypervisor_type is null for a cluster entry
Changes: - Care for null value during comparing the hypervisor_type - Do not consider removed clusters - Method rename according to coding conventions
1 parent d28cca7 commit f4e4be0

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void performDataMigration(Connection conn) {
8383
createPlaceHolderNics(conn);
8484
updateRemoteAccessVpn(conn);
8585
updateSystemVmTemplates(conn);
86-
updateCluster_details(conn);
86+
updateOverCommitRatioClusterDetails(conn);
8787
updatePrimaryStore(conn);
8888
addEgressFwRulesForSRXGuestNw(conn);
8989
upgradeEIPNetworkOfferings(conn);
@@ -898,7 +898,7 @@ private void updatePrimaryStore(Connection conn) {
898898
}
899899

900900
//update the cluster_details table with default overcommit ratios.
901-
private void updateCluster_details(Connection conn) {
901+
private void updateOverCommitRatioClusterDetails(Connection conn) {
902902
PreparedStatement pstmt = null;
903903
PreparedStatement pstmt1 = null;
904904
PreparedStatement pstmt2 =null;
@@ -907,7 +907,7 @@ private void updateCluster_details(Connection conn) {
907907
ResultSet rscpu_global = null;
908908
ResultSet rsmem_global = null;
909909
try {
910-
pstmt = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster`");
910+
pstmt = conn.prepareStatement("select id, hypervisor_type from `cloud`.`cluster` WHERE removed IS NULL");
911911
pstmt1=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES(?, 'cpuOvercommitRatio', ?)");
912912
pstmt2=conn.prepareStatement("INSERT INTO `cloud`.`cluster_details` (cluster_id, name, value) VALUES(?, 'memoryOvercommitRatio', ?)");
913913
pstmt3=conn.prepareStatement("select value from `cloud`.`configuration` where name=?");
@@ -926,7 +926,7 @@ private void updateCluster_details(Connection conn) {
926926
while (rs1.next()) {
927927
long id = rs1.getLong(1);
928928
String hypervisor_type = rs1.getString(2);
929-
if (hypervisor_type.equalsIgnoreCase(HypervisorType.VMware.toString())) {
929+
if (HypervisorType.VMware.toString().equalsIgnoreCase(hypervisor_type)) {
930930
pstmt1.setLong(1,id);
931931
pstmt1.setString(2,global_cpu_overprovisioning_factor);
932932
pstmt1.execute();

0 commit comments

Comments
 (0)