cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kous...@apache.org
Subject git commit: updated refs/heads/4.2 to 470e76b
Date Thu, 08 Aug 2013 09:42:38 GMT
Updated Branches:
  refs/heads/4.2 c84f373d4 -> 470e76b3d


CLOUDSTACK-4136: [upgraded ENV]Deleting Snapshot which was created before upgrade is throwing
NPE.
Snapshot object is being accessed even when it is null. In case snapshot is not present in
backup store the code should return after cleaning db entry.
Also noticed discrepancy in the upgraded db setup but couldn't fully verify it, so added logging
in the upgrade logic for template/snapshots etc.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/470e76b3
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/470e76b3
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/470e76b3

Branch: refs/heads/4.2
Commit: 470e76b3d6046ddc44d4795d69646f810b857fd0
Parents: c84f373
Author: Koushik Das <koushik@apache.org>
Authored: Thu Aug 8 15:05:29 2013 +0530
Committer: Koushik Das <koushik@apache.org>
Committed: Thu Aug 8 15:05:29 2013 +0530

----------------------------------------------------------------------
 .../com/cloud/upgrade/dao/Upgrade410to420.java  | 28 +++++++++++++-------
 .../snapshot/XenserverSnapshotStrategy.java     |  7 ++---
 2 files changed, 23 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/470e76b3/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
index 79576f2..b80a3f9 100644
--- a/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
+++ b/engine/schema/src/com/cloud/upgrade/dao/Upgrade410to420.java
@@ -1686,7 +1686,7 @@ public class Upgrade410to420 implements DbUpgrade {
         ResultSet storeInfo = null;
         Long storeId = null;
 
-
+        s_logger.debug("Migrating secondary storage to image store");
         try {
             storeQuery = conn.prepareStatement("select id from `cloud`.`image_store` where
uuid = ?");
             storeDetailInsert = conn
@@ -1803,7 +1803,7 @@ public class Upgrade410to420 implements DbUpgrade {
                 }
                 swift_store_id_map.put(swift_id, storeId);
             }
-             */
+            */
 
             // migrate NFS secondary storage, for nfs, keep previous host_id as the store_id
             storeInsert = conn
@@ -1881,6 +1881,7 @@ public class Upgrade410to420 implements DbUpgrade {
             } catch (SQLException e) {
             }
         }
+        s_logger.debug("Completed migrating secondary storage to image store");
     }
 
     // migrate volume_host_ref to volume_store_ref
@@ -1888,14 +1889,16 @@ public class Upgrade410to420 implements DbUpgrade {
         PreparedStatement volStoreInsert = null;
         PreparedStatement volStoreUpdate = null;
 
+        s_logger.debug("Updating volume_store_ref table from volume_host_ref table");
         try {
-
             volStoreInsert = conn
                     .prepareStatement("INSERT INTO `cloud`.`volume_store_ref` (store_id,
 volume_id, zone_id, created, last_updated, job_id, download_pct, size, physical_size, download_state,
checksum, error_str, local_path, install_path, url, destroyed, update_count, ref_cnt, state)
select host_id, volume_id, zone_id, created, last_updated, job_id, download_pct, size, physical_size,
download_state, checksum, error_str, local_path, install_path, url, destroyed, 0, 0, 'Allocated'
from `cloud`.`volume_host_ref`");
-            volStoreInsert.executeUpdate();
+            int rowCount = volStoreInsert.executeUpdate();
+            s_logger.debug("Insert modified " + rowCount + " rows");
 
             volStoreUpdate = conn.prepareStatement("update `cloud`.`volume_store_ref` set
state = 'Ready' where download_state = 'DOWNLOADED'");
-            volStoreUpdate.executeUpdate();
+            rowCount = volStoreUpdate.executeUpdate();
+            s_logger.debug("Update modified " + rowCount + " rows");
         }
         catch (SQLException e) {
             String msg = "Unable to migrate volume_host_ref." + e.getMessage();
@@ -1912,6 +1915,7 @@ public class Upgrade410to420 implements DbUpgrade {
             } catch (SQLException e) {
             }
         }
+        s_logger.debug("Completed updating volume_store_ref table from volume_host_ref table");
     }
 
     // migrate template_host_ref to template_store_ref
@@ -1919,14 +1923,16 @@ public class Upgrade410to420 implements DbUpgrade {
         PreparedStatement tmplStoreInsert = null;
         PreparedStatement tmplStoreUpdate = null;
 
+        s_logger.debug("Updating template_store_ref table from template_host_ref table");
         try {
-
             tmplStoreInsert = conn
                     .prepareStatement("INSERT INTO `cloud`.`template_store_ref` (store_id,
 template_id, created, last_updated, job_id, download_pct, size, physical_size, download_state,
error_str, local_path, install_path, url, destroyed, is_copy, update_count, ref_cnt, store_role,
state) select host_id, template_id, created, last_updated, job_id, download_pct, size, physical_size,
download_state, error_str, local_path, install_path, url, destroyed, is_copy, 0, 0, 'Image',
'Allocated' from `cloud`.`template_host_ref`");
-            tmplStoreInsert.executeUpdate();
+            int rowCount = tmplStoreInsert.executeUpdate();
+            s_logger.debug("Insert modified " + rowCount + " rows");
 
             tmplStoreUpdate = conn.prepareStatement("update `cloud`.`template_store_ref`
set state = 'Ready' where download_state = 'DOWNLOADED'");
-            tmplStoreUpdate.executeUpdate();
+            rowCount = tmplStoreUpdate.executeUpdate();
+            s_logger.debug("Update modified " + rowCount + " rows");
         }
         catch (SQLException e) {
             String msg = "Unable to migrate template_host_ref." + e.getMessage();
@@ -1943,16 +1949,19 @@ public class Upgrade410to420 implements DbUpgrade {
             } catch (SQLException e) {
             }
         }
+        s_logger.debug("Completed updating template_store_ref table from template_host_ref
table");
     }
 
     // migrate some entry contents of snapshots to snapshot_store_ref
     private void migrateSnapshotStoreRef(Connection conn) {
         PreparedStatement snapshotStoreInsert = null;
 
+        s_logger.debug("Updating snapshot_store_ref table from snapshots table");
         try {
             snapshotStoreInsert = conn
                     .prepareStatement("INSERT INTO `cloud`.`snapshot_store_ref` (store_id,
 snapshot_id, created, size, parent_snapshot_id, install_path, volume_id, update_count, ref_cnt,
store_role, state) select sechost_id, id, created, size, prev_snap_id, CONCAT('snapshots',
'/', account_id, '/', volume_id, '/', backup_snap_id), volume_id, 0, 0, 'Image', 'Ready' from
`cloud`.`snapshots` where status = 'BackedUp' and sechost_id is not null and removed is null");
-            snapshotStoreInsert.executeUpdate();
+            int rowCount = snapshotStoreInsert.executeUpdate();
+            s_logger.debug("Insert modified " + rowCount + " rows");
         }
         catch (SQLException e) {
             String msg = "Unable to migrate snapshot_store_ref." + e.getMessage();
@@ -1966,6 +1975,7 @@ public class Upgrade410to420 implements DbUpgrade {
             } catch (SQLException e) {
             }
         }
+        s_logger.debug("Completed updating snapshot_store_ref table from snapshots table");
     }
 
     private void fixNiciraKeys(Connection conn) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/470e76b3/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
----------------------------------------------------------------------
diff --git a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
index d9ee75e..a425ce7 100644
--- a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
+++ b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
@@ -189,7 +189,6 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
             return true;
         }
 
-
         if (snapshotVO.getState() == Snapshot.State.CreatedOnPrimary) {
             s_logger.debug("delete snapshot on primary storage:");
             snapshotVO.setState(Snapshot.State.Destroyed);
@@ -202,13 +201,14 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase
{
                     + " due to it is not in BackedUp Status");
         }
 
-        // firt mark the snapshot as destroyed, so that ui can't see it, but we
-        // may not destroy the snapshot on the storage, as other snaphosts may
+        // first mark the snapshot as destroyed, so that ui can't see it, but we
+        // may not destroy the snapshot on the storage, as other snapshots may
         // depend on it.
         SnapshotInfo snapshotOnImage = this.snapshotDataFactory.getSnapshot(snapshotId, DataStoreRole.Image);
         if (snapshotOnImage == null) {
             s_logger.debug("Can't find snapshot on backup storage, delete it in db");
             snapshotDao.remove(snapshotId);
+            return true;
         }
 
         SnapshotObject obj = (SnapshotObject) snapshotOnImage;
@@ -237,6 +237,7 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase {
             } catch (NoTransitionException e1) {
                 s_logger.debug("Failed to change snapshot state: " + e.toString());
             }
+            return false;
         }
 
         return true;


Mime
View raw message