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:06:33 UTC

git commit: updated refs/heads/4.2 to 375a59d

Updated Branches:
  refs/heads/4.2 9672a45ea -> 375a59d2f


NPE while deleting old root volumes of a restored VM during storage garbage collection


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

Branch: refs/heads/4.2
Commit: 375a59d2f73e23194e1dae5b9ee11ae111a28027
Parents: 9672a45
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:12:51 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/375a59d2/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 2a4d4bd..a88a63b 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -62,6 +62,10 @@ import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
 import org.apache.cloudstack.engine.service.api.OrchestrationService;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
+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;
@@ -430,6 +434,10 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
     PlannerHostReservationDao _plannerHostReservationDao;
     @Inject
     private ServiceOfferingDetailsDao serviceOfferingDetailsDao;
+    @Inject
+    VolumeService _volService;
+    @Inject
+    VolumeDataFactory volFactory;
 
     protected ScheduledExecutorService _executor = null;
     protected int _expungeInterval;
@@ -4910,6 +4918,17 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Use
         _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);