mirror of https://github.com/apache/cloudstack.git
bug CS-10789: Some more code to make the Uploav volume more robust.
This commit is contained in:
parent
9097b53eab
commit
c65d3bdace
|
|
@ -62,6 +62,7 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.St
|
|||
s_fsm.addTransition(Allocated, Event.UploadRequested, Uploading);
|
||||
s_fsm.addTransition(Uploading, Event.UploadSucceeded, Uploaded);
|
||||
s_fsm.addTransition(Uploading, Event.OperationFailed, UploadError);
|
||||
s_fsm.addTransition(UploadError, Event.DestroyRequested, Destroy);
|
||||
s_fsm.addTransition(Uploaded, Event.UploadSucceeded, Uploaded);
|
||||
s_fsm.addTransition(Uploaded, Event.CopyRequested, Creating);
|
||||
s_fsm.addTransition(Uploaded, Event.DestroyRequested, Destroy);
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
createdefaultDiskOffering(null, "Medium", "Medium Disk, 20 GB", 20, null, false, false);
|
||||
createdefaultDiskOffering(null, "Large", "Large Disk, 100 GB", 100, null, false, false);
|
||||
createdefaultDiskOffering(null, "Large", "Large Disk, 100 GB", 100, null, false, false);
|
||||
createdefaultDiskOffering(null, "Custom", "Custom Disk", 0, null, true, true);
|
||||
createdefaultDiskOffering(null, "Custom", "Custom Disk", 0, null, true, false);
|
||||
|
||||
// Save the mount parent to the configuration table
|
||||
String mountParent = getMountParent();
|
||||
|
|
|
|||
|
|
@ -3374,13 +3374,18 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
|
|||
//Find out if the volume is present on secondary storage
|
||||
VolumeHostVO volumeHost = _volumeHostDao.findByVolumeId(vol.getId());
|
||||
if(volumeHost != null){
|
||||
HostVO ssHost = _hostDao.findById(volumeHost.getHostId());
|
||||
DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(ssHost.getStorageUrl(), volumeHost.getInstallPath());
|
||||
Answer answer = _agentMgr.sendToSecStorage(ssHost, dtCommand);
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.debug("Failed to delete " + volumeHost + " due to " + ((answer == null) ? "answer is null" : answer.getDetails()));
|
||||
return;
|
||||
}
|
||||
if (volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOADED){
|
||||
HostVO ssHost = _hostDao.findById(volumeHost.getHostId());
|
||||
DeleteVolumeCommand dtCommand = new DeleteVolumeCommand(ssHost.getStorageUrl(), volumeHost.getInstallPath());
|
||||
Answer answer = _agentMgr.sendToSecStorage(ssHost, dtCommand);
|
||||
if (answer == null || !answer.getResult()) {
|
||||
s_logger.debug("Failed to delete " + volumeHost + " due to " + ((answer == null) ? "answer is null" : answer.getDetails()));
|
||||
return;
|
||||
}
|
||||
}else if(volumeHost.getDownloadState() == VMTemplateStorageResourceAssoc.Status.DOWNLOAD_IN_PROGRESS){
|
||||
s_logger.debug("Volume: " + vol.getName() + " is currently being uploaded; cant' delete it.");
|
||||
throw new CloudRuntimeException("Please specify a volume that is not currently being uploaded.");
|
||||
}
|
||||
_volumeHostDao.remove(volumeHost.getId());
|
||||
_volumeDao.remove(vol.getId());
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -744,8 +744,16 @@ public class DownloadMonitorImpl implements DownloadMonitor {
|
|||
volumeHost.setSize(volInfo.getSize());
|
||||
volumeHost.setPhysicalSize(volInfo.getPhysicalSize());
|
||||
volumeHost.setLastUpdated(new Date());
|
||||
if (volume.getState() == Volume.State.Uploading){
|
||||
try {
|
||||
_storageMgr.stateTransitTo(volume, Event.UploadSucceeded);
|
||||
} catch (NoTransitionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
_volumeHostDao.update(volumeHost.getId(), volumeHost);
|
||||
}
|
||||
_volumeHostDao.update(volumeHost.getId(), volumeHost);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue