cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject git commit: updated refs/heads/4.2 to a747ee5
Date Thu, 01 Aug 2013 00:43:12 GMT
Updated Branches:
  refs/heads/4.2 da124c2d8 -> a747ee508


CLOUDSTACK-3976: if the snapshot is empty and it's the last one in the chain, we need to take
full snapshot for the snapshots in sequence


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

Branch: refs/heads/4.2
Commit: a747ee508bcc6786432ed68e900f3d1fd35d05e0
Parents: da124c2
Author: Edison Su <sudison@gmail.com>
Authored: Wed Jul 31 17:42:35 2013 -0700
Committer: Edison Su <sudison@gmail.com>
Committed: Wed Jul 31 17:42:35 2013 -0700

----------------------------------------------------------------------
 .../snapshot/XenserverSnapshotStrategy.java     | 57 ++++++++++++--------
 1 file changed, 35 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a747ee50/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 c470bfe..3e6c508 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
@@ -130,31 +130,44 @@ public class XenserverSnapshotStrategy extends SnapshotStrategyBase
{
     protected boolean deleteSnapshotChain(SnapshotInfo snapshot) {
         s_logger.debug("delete snapshot chain for snapshot: " + snapshot.getId());
         boolean result = false;
-        while (snapshot != null && (snapshot.getState() == Snapshot.State.Destroying
|| snapshot.getState()
-                == Snapshot.State.Destroyed || snapshot.getState() == Snapshot.State.Error))
{
-            SnapshotInfo child = snapshot.getChild();
+        boolean resultIsSet = false;   //need to track, the snapshot itself is deleted or
not.
+        try {
+            while (snapshot != null && (snapshot.getState() == Snapshot.State.Destroying
|| snapshot.getState()
+                    == Snapshot.State.Destroyed || snapshot.getState() == Snapshot.State.Error))
{
+                SnapshotInfo child = snapshot.getChild();
 
-            if (child != null) {
-                s_logger.debug("the snapshot has child, can't delete it on the storage");
-                break;
-            }
-            s_logger.debug("Snapshot: " + snapshot.getId() + " doesn't have children, so
it's ok to delete it and its parents");
-            SnapshotInfo parent = snapshot.getParent();
-            boolean deleted = false;
-            if (parent != null) {
-                if (parent.getPath() != null && parent.getPath().equalsIgnoreCase(snapshot.getPath()))
{
-                    //NOTE: if both snapshots share the same path, it's for xenserver's empty
delta snapshot. We can't delete the snapshot on the backend, as parent snapshot still reference
to it
-                    //Instead, mark it as destroyed in the db.
-                    s_logger.debug("for empty delta snapshot, only mark it as destroyed in
db");
-                    snapshot.processEvent(Event.DestroyRequested);
-                    snapshot.processEvent(Event.OperationSuccessed);
-                    deleted = true;
+                if (child != null) {
+                    s_logger.debug("the snapshot has child, can't delete it on the storage");
+                    break;
                 }
+                s_logger.debug("Snapshot: " + snapshot.getId() + " doesn't have children,
so it's ok to delete it and its parents");
+                SnapshotInfo parent = snapshot.getParent();
+                boolean deleted = false;
+                if (parent != null) {
+                    if (parent.getPath() != null && parent.getPath().equalsIgnoreCase(snapshot.getPath()))
{
+                        //NOTE: if both snapshots share the same path, it's for xenserver's
empty delta snapshot. We can't delete the snapshot on the backend, as parent snapshot still
reference to it
+                        //Instead, mark it as destroyed in the db.
+                        s_logger.debug("for empty delta snapshot, only mark it as destroyed
in db");
+                        snapshot.processEvent(Event.DestroyRequested);
+                        snapshot.processEvent(Event.OperationSuccessed);
+                        deleted = true;
+                        if (!resultIsSet) {
+                            result = true;
+                            resultIsSet = true;
+                        }
+                    }
+                }
+                if (!deleted) {
+                    boolean r = this.snapshotSvr.deleteSnapshot(snapshot);
+                    if (!resultIsSet) {
+                        result = r;
+                        resultIsSet = true;
+                    }
+                }
+                snapshot = parent;
             }
-            if (!deleted) {
-                result = this.snapshotSvr.deleteSnapshot(snapshot);
-            }
-            snapshot = parent;
+        } catch (Exception e) {
+            s_logger.debug("delete snapshot failed: ", e);
         }
         return result;
     }


Mime
View raw message