cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From likit...@apache.org
Subject [2/2] git commit: updated refs/heads/master to b41a78c
Date Fri, 08 Aug 2014 10:27:30 GMT
Revert "CLOUDSTACK-7077. Quickly attaching multiple data disks to a VM fails."

This reverts commit a9b3ab089d6cb0bc1494e10b2be90292f4c79289.


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

Branch: refs/heads/master
Commit: bb7fc5994761cb56b142d418deb9080d59b3a3c3
Parents: 74847dc
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Fri Aug 8 13:03:06 2014 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Fri Aug 8 15:31:03 2014 +0530

----------------------------------------------------------------------
 .../hypervisor/vmware/mo/VirtualMachineMO.java  | 108 +++++++------------
 1 file changed, 39 insertions(+), 69 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb7fc599/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
----------------------------------------------------------------------
diff --git a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
index e5398af..2439691 100644
--- a/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
+++ b/vmware-base/src/com/cloud/hypervisor/vmware/mo/VirtualMachineMO.java
@@ -108,13 +108,11 @@ import com.cloud.utils.ActionDelegate;
 import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.concurrency.NamedThreadFactory;
-import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.script.Script;
 
 public class VirtualMachineMO extends BaseMO {
     private static final Logger s_logger = Logger.getLogger(VirtualMachineMO.class);
     private static final ExecutorService MonitorServiceExecutor = Executors.newCachedThreadPool(new
NamedThreadFactory("VM-Question-Monitor"));
-    private static final int ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_DISK_ATTACH = 5 * 60; // Wait
for a maximum of 5 minutes to prepare a disk while VM is being re-configured with another
disk
     private ManagedObjectReference _vmEnvironmentBrowser = null;
 
     public VirtualMachineMO(VmwareContext context, ManagedObjectReference morVm) {
@@ -1053,90 +1051,62 @@ public class VirtualMachineMO extends BaseMO {
     }
 
     public void attachDisk(String[] vmdkDatastorePathChain, ManagedObjectReference morDs)
throws Exception {
-        // Add lock to ensure that only one disk is being prepared and attached to the VM
at a time
-        GlobalLock lock = GlobalLock.getInternLock("disk.attach");
-        try {
-            s_logger.trace("Grabbing lock to ensure that only one disk is being prepared
and attached to the VM at a time.");
-            if (lock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_DISK_ATTACH)) {
-                try {
-                    if (s_logger.isTraceEnabled())
-                        s_logger.trace("vCenter API trace - attachDisk(). target MOR: " +
_mor.getValue() + ", vmdkDatastorePath: " + new Gson().toJson(vmdkDatastorePathChain) +
-                                ", datastore: " + morDs.getValue());
-
-                    VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, null, getScsiDeviceControllerKey(),
vmdkDatastorePathChain, morDs, -1, 1);
-                    VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
-                    VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
 
-                    deviceConfigSpec.setDevice(newDisk);
-                    deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
+        if (s_logger.isTraceEnabled())
+            s_logger.trace("vCenter API trace - attachDisk(). target MOR: " + _mor.getValue()
+ ", vmdkDatastorePath: " + new Gson().toJson(vmdkDatastorePathChain) +
+                    ", datastore: " + morDs.getValue());
 
-                    reConfigSpec.getDeviceChange().add(deviceConfigSpec);
+        VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, null, getScsiDeviceControllerKey(),
vmdkDatastorePathChain, morDs, -1, 1);
+        VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
+        VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
 
-                    ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor,
reConfigSpec);
-                    boolean result = _context.getVimClient().waitForTask(morTask);
+        deviceConfigSpec.setDevice(newDisk);
+        deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
 
-                    if (!result) {
-                        if (s_logger.isTraceEnabled())
-                            s_logger.trace("vCenter API trace - attachDisk() done(failed)");
-                        throw new Exception("Failed to attach disk due to " + TaskMO.getTaskFailureInfo(_context,
morTask));
-                    }
+        reConfigSpec.getDeviceChange().add(deviceConfigSpec);
 
-                    _context.waitForTaskProgressDone(morTask);
+        ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
+        boolean result = _context.getVimClient().waitForTask(morTask);
 
-                    if (s_logger.isTraceEnabled())
-                        s_logger.trace("vCenter API trace - attachDisk() done(successfully)");
-                } finally {
-                    lock.unlock();
-                }
-            } else {
-                s_logger.warn("Couldn't get lock on VM: " + _mor.getValue() + " to attach
disk: " + vmdkDatastorePathChain + " ,maybe another disk is being attached to the VM.");
-            }
-        } finally {
-            lock.releaseRef();
+        if (!result) {
+            if (s_logger.isTraceEnabled())
+                s_logger.trace("vCenter API trace - attachDisk() done(failed)");
+            throw new Exception("Failed to attach disk due to " + TaskMO.getTaskFailureInfo(_context,
morTask));
         }
+
+        _context.waitForTaskProgressDone(morTask);
+
+        if (s_logger.isTraceEnabled())
+            s_logger.trace("vCenter API trace - attachDisk() done(successfully)");
     }
 
     public void attachDisk(Pair<String, ManagedObjectReference>[] vmdkDatastorePathChain,
int controllerKey) throws Exception {
-        // Add lock to ensure that only one disk is being prepared and attached to the VM
at a time
-        GlobalLock lock = GlobalLock.getInternLock("disk.attach");
-        try {
-            s_logger.trace("Grabbing lock to ensure that only one disk is being prepared
and attached to the VM at a time.");
-            if (lock.lock(ACQUIRE_GLOBAL_LOCK_TIMEOUT_FOR_DISK_ATTACH)) {
-                try {
-                     if (s_logger.isTraceEnabled())
-                         s_logger.trace("vCenter API trace - attachDisk(). target MOR: "
+ _mor.getValue() + ", vmdkDatastorePath: " + new Gson().toJson(vmdkDatastorePathChain));
 
-                     VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, controllerKey,
vmdkDatastorePathChain, -1, 1);
-                     VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
-                     VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
-
-                     deviceConfigSpec.setDevice(newDisk);
-                     deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
+        if (s_logger.isTraceEnabled())
+            s_logger.trace("vCenter API trace - attachDisk(). target MOR: " + _mor.getValue()
+ ", vmdkDatastorePath: " + new Gson().toJson(vmdkDatastorePathChain));
 
-                     reConfigSpec.getDeviceChange().add(deviceConfigSpec);
+        VirtualDevice newDisk = VmwareHelper.prepareDiskDevice(this, controllerKey, vmdkDatastorePathChain,
-1, 1);
+        VirtualMachineConfigSpec reConfigSpec = new VirtualMachineConfigSpec();
+        VirtualDeviceConfigSpec deviceConfigSpec = new VirtualDeviceConfigSpec();
 
-                     ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor,
reConfigSpec);
-                     boolean result = _context.getVimClient().waitForTask(morTask);
+        deviceConfigSpec.setDevice(newDisk);
+        deviceConfigSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
 
-                     if (!result) {
-                         if (s_logger.isTraceEnabled())
-                             s_logger.trace("vCenter API trace - attachDisk() done(failed)");
-                         throw new Exception("Failed to attach disk due to " + TaskMO.getTaskFailureInfo(_context,
morTask));
-                     }
+        reConfigSpec.getDeviceChange().add(deviceConfigSpec);
 
-                     _context.waitForTaskProgressDone(morTask);
+        ManagedObjectReference morTask = _context.getService().reconfigVMTask(_mor, reConfigSpec);
+        boolean result = _context.getVimClient().waitForTask(morTask);
 
-                     if (s_logger.isTraceEnabled())
-                         s_logger.trace("vCenter API trace - attachDisk() done(successfully)");
-                } finally {
-                    lock.unlock();
-                }
-            } else {
-                s_logger.warn("Couldn't get lock on VM: " + _mor.getValue() + " to attach
disk: " + vmdkDatastorePathChain + " ,maybe another disk is being attached to the VM.");
-            }
-        } finally {
-            lock.releaseRef();
+        if (!result) {
+            if (s_logger.isTraceEnabled())
+                s_logger.trace("vCenter API trace - attachDisk() done(failed)");
+            throw new Exception("Failed to attach disk due to " + TaskMO.getTaskFailureInfo(_context,
morTask));
         }
+
+        _context.waitForTaskProgressDone(morTask);
+
+        if (s_logger.isTraceEnabled())
+            s_logger.trace("vCenter API trace - attachDisk() done(successfully)");
     }
 
     // vmdkDatastorePath: [datastore name] vmdkFilePath


Mime
View raw message