CLOUDSTACK-7835: Deleted volumes with null UUID and no removed timestamp in database still appear.

Also removed CREATING -> DESTROY via DESTROYREQUESTED, which was causing the volume to get stuck in expunging
state.
This commit is contained in:
Sanjay Tripathi 2014-11-04 13:27:17 +05:30
parent 9168d826da
commit a53d39c1b6
2 changed files with 14 additions and 6 deletions

View File

@ -69,7 +69,6 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
s_fsm.addTransition(Creating, Event.OperationRetry, Creating);
s_fsm.addTransition(Creating, Event.OperationFailed, Allocated);
s_fsm.addTransition(Creating, Event.OperationSucceeded, Ready);
s_fsm.addTransition(Creating, Event.DestroyRequested, Destroy);
s_fsm.addTransition(Creating, Event.CreateRequested, Creating);
s_fsm.addTransition(Ready, Event.ResizeRequested, Resizing);
s_fsm.addTransition(Resizing, Event.OperationSucceeded, Ready);

View File

@ -1021,11 +1021,20 @@ public class VolumeServiceImpl implements VolumeService {
srcVolume.processEvent(Event.OperationSuccessed);
destVolume.processEvent(Event.OperationSuccessed, result.getAnswer());
_volumeDao.updateUuid(srcVolume.getId(), destVolume.getId());
destroyVolume(srcVolume.getId());
srcVolume = volFactory.getVolume(srcVolume.getId());
AsyncCallFuture<VolumeApiResult> destroyFuture = expungeVolumeAsync(srcVolume);
destroyFuture.get();
future.complete(res);
try {
destroyVolume(srcVolume.getId());
srcVolume = volFactory.getVolume(srcVolume.getId());
AsyncCallFuture<VolumeApiResult> destroyFuture = expungeVolumeAsync(srcVolume);
// If volume destroy fails, this could be because of vdi is still in use state, so wait and retry.
if (destroyFuture.get().isFailed()) {
Thread.sleep(5 * 1000);
destroyFuture = expungeVolumeAsync(srcVolume);
destroyFuture.get();
}
future.complete(res);
} catch (Exception e) {
s_logger.debug("failed to clean up volume on storage", e);
}
return null;
} catch (Exception e) {
s_logger.debug("Failed to process copy volume callback", e);