bug 9827: call destroyVolume() method only after ensuring that the volume is not destroyed already.

status 9827: resolved fixed

also added an assert to the method itself to throw a warn if the method is called for destroyed volume
This commit is contained in:
alena 2011-05-11 14:05:58 -07:00
parent ab576308a2
commit ac8c79314d
2 changed files with 4 additions and 1 deletions

View File

@ -1686,6 +1686,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
@Override
@DB
public void destroyVolume(VolumeVO volume) throws ConcurrentOperationException {
assert (volume.getState() != Volume.State.Destroy) : "Why destroy method is called for the volume that is already destroyed?";
Transaction txn = Transaction.currentTxn();
txn.start();

View File

@ -1541,7 +1541,9 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
List<VolumeVO> volumesForThisVm = _volsDao.findByInstance(vm.getId());
for(VolumeVO volume : volumesForThisVm) {
try {
_storageMgr.destroyVolume(volume);
if (volume.getState() != Volume.State.Destroy) {
_storageMgr.destroyVolume(volume);
}
if (volume.getState() == Volume.State.Ready) {
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VOLUME_DELETE, volume.getAccountId(), volume.getDataCenterId(), volume.getId(),
volume.getName());