mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 10632: allow volume to be recreated when it is in recreating state
This commit is contained in:
parent
cae81c9a66
commit
c679fc078a
@ -31,6 +31,7 @@ import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -112,8 +113,8 @@ import com.cloud.exception.StorageUnavailableException;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.host.dao.HostDetailsDao;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.hypervisor.HypervisorGuruManager;
|
||||
import com.cloud.network.NetworkManager;
|
||||
@ -183,8 +184,6 @@ import com.cloud.vm.dao.SecondaryStorageVmDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@Local(value = { StorageManager.class, StorageService.class })
|
||||
public class StorageManagerImpl implements StorageManager, StorageService, Manager, ClusterManagerListener {
|
||||
private static final Logger s_logger = Logger.getLogger(StorageManagerImpl.class);
|
||||
@ -1683,7 +1682,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
if (diskOffering.getDiskSize() > 0) {
|
||||
size = diskOffering.getDiskSize();
|
||||
}
|
||||
}
|
||||
|
||||
if (!validateVolumeSizeRange(size)) {// convert size from mb to gb for validation
|
||||
throw new InvalidParameterValueException("Invalid size for custom volume creation: " + size + " ,max volume size is:" + _maxVolumeSizeInGb);
|
||||
@ -1697,7 +1696,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
|
||||
if (snapshotCheck.getStatus() != Snapshot.Status.BackedUp) {
|
||||
throw new InvalidParameterValueException("Snapshot id=" + snapshotId + " is not in " + Snapshot.Status.BackedUp + " state yet and can't be used for volume creation");
|
||||
}
|
||||
}
|
||||
|
||||
diskOfferingId = (cmd.getDiskOfferingId() != null) ? cmd.getDiskOfferingId() : snapshotCheck.getDiskOfferingId();
|
||||
zoneId = snapshotCheck.getDataCenterId();
|
||||
@ -2627,7 +2626,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
if (assignedPool != null) {
|
||||
Volume.State state = vol.getState();
|
||||
if (state == Volume.State.Allocated) {
|
||||
if (state == Volume.State.Allocated && state == Volume.State.Creating) {
|
||||
recreateVols.add(vol);
|
||||
} else {
|
||||
if (vol.isRecreatable()) {
|
||||
@ -2649,7 +2648,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("No need to recreate the volume: "+vol+ ", since it already has a pool assigned: "+vol.getPoolId()+", adding disk to VM");
|
||||
}
|
||||
}
|
||||
StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId());
|
||||
vm.addDisk(new VolumeTO(vol, pool));
|
||||
}
|
||||
@ -2714,7 +2713,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
txn.start();
|
||||
_volsDao.update(existingVolume, Volume.Event.Destroy);
|
||||
|
||||
Long templateIdToUse = null;
|
||||
Long templateIdToUse = null;
|
||||
Long volTemplateId = existingVolume.getTemplateId();
|
||||
long vmTemplateId = vm.getTemplateId();
|
||||
if (volTemplateId != null && volTemplateId.longValue() != vmTemplateId) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user