mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Revert "CLOUDSTACK-7077. Quickly attaching multiple data disks to a VM fails."
This reverts commit a9b3ab089d6cb0bc1494e10b2be90292f4c79289.
This commit is contained in:
parent
74847dce47
commit
bb7fc59947
@ -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,12 +1051,7 @@ 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());
|
||||
@ -1085,24 +1078,10 @@ public class VirtualMachineMO extends BaseMO {
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
@ -1128,15 +1107,6 @@ public class VirtualMachineMO extends BaseMO {
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
// vmdkDatastorePath: [datastore name] vmdkFilePath
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user