You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by li...@apache.org on 2013/10/29 07:08:11 UTC

git commit: updated refs/heads/master to cc4b612

Updated Branches:
  refs/heads/master 6be228a43 -> cc4b612bf


CLOUDSTACK-4985. NPE while deleting old root volumes of a restored VM during storage garbage collection.
In case of VMware, once the state of the old root volume has been updated to destroyed force expunge it from primary storage to avoid the garbage collector from trying to delete the new root volume


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

Branch: refs/heads/master
Commit: cc4b612bf604addb1ad903ef8adc504c569abe55
Parents: 6be228a
Author: Likitha Shetty <li...@citrix.com>
Authored: Tue Oct 29 11:11:50 2013 +0530
Committer: Likitha Shetty <li...@citrix.com>
Committed: Tue Oct 29 11:31:45 2013 +0530

----------------------------------------------------------------------
 server/src/com/cloud/vm/UserVmManagerImpl.java | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cc4b612b/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index e97dfd7..f202784 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -73,6 +73,10 @@ import org.apache.cloudstack.framework.config.Configurable;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.framework.jobs.AsyncJobManager;
 import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService;
+import org.apache.cloudstack.engine.subsystem.api.storage.VolumeService.VolumeApiResult;
+import org.apache.cloudstack.framework.async.AsyncCallFuture;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.cloudstack.storage.to.TemplateObjectTO;
@@ -437,6 +441,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
     PlannerHostReservationDao _plannerHostReservationDao;
     @Inject
     private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
+    @Inject
+    VolumeService _volService;
+    @Inject
+    VolumeDataFactory volFactory;
 
     protected ScheduledExecutorService _executor = null;
     protected int _expungeInterval;
@@ -4914,6 +4922,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
         _volsDao.detachVolume(root.getId());
         volumeMgr.destroyVolume(root);
 
+        // For VMware hypervisor since the old root volume is replaced by the new root volume in storage, force expunge old root volume
+        if (vm.getHypervisorType() == HypervisorType.VMware) {
+            s_logger.info("Expunging volume " + root.getId() + " from primary data store");
+            AsyncCallFuture<VolumeApiResult> future = _volService.expungeVolumeAsync(volFactory.getVolume(root.getId()));
+            try {
+                future.get();
+            } catch (Exception e) {
+                s_logger.debug("Failed to expunge volume:" + root.getId(), e);
+            }
+        }
+
         if (template.getEnablePassword()) {
             String password = generateRandomPassword();
             boolean result = resetVMPasswordInternal(vmId, password);