From 1bcb9afa89b546a5c02b88ac9428c419caefbc11 Mon Sep 17 00:00:00 2001 From: Koushik Das Date: Fri, 13 Jul 2012 11:13:00 +0530 Subject: [PATCH] Fix for CS-15279. Issue happens when ROOT volume gets created and there is subsequent failure in starting the VM. During retry if allocator assigns a different storage pool the scenario was not handled. Now in case of local storage the volume get recreated on the newly assigned pool and old one gets cleaned up. In case of shared storage the existing volume is migrated to new storage pool. Reviewed-by: Prachi, Edison, Nitin --- .../com/cloud/storage/StorageManagerImpl.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 26654ed54ca..146b8d3bf47 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -3207,10 +3207,25 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag } else { if (assignedPool.getId() != vol.getPoolId()) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Volume " + vol + " is not recreatable! Cannot recreate on storagepool: " + assignedPool); + s_logger.debug("Mismatch in storage pool " + assignedPool + " assigned by deploymentPlanner and the one associated with volume " + vol); + } + if (vm.getServiceOffering().getUseLocalStorage()) + { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Local volume " + vol + " will be recreated on storage pool " + assignedPool + " assigned by deploymentPlanner"); + } + recreateVols.add(vol); + } else { + if (s_logger.isDebugEnabled()) { + s_logger.debug("Shared volume " + vol + " will be migrated on storage pool " + assignedPool + " assigned by deploymentPlanner"); + } + try { + Volume migratedVol = migrateVolume(vol.getId(), assignedPool.getId()); + vm.addDisk(new VolumeTO(migratedVol, assignedPool)); + } catch (ConcurrentOperationException e) { + throw new StorageUnavailableException("Volume migration failed for " + vol, Volume.class, vol.getId()); + } } - throw new StorageUnavailableException("Volume is not recreatable, Unable to create " + vol, Volume.class, vol.getId()); - // copy volume usecase - not yet developed. } else { StoragePoolVO pool = _storagePoolDao.findById(vol.getPoolId()); vm.addDisk(new VolumeTO(vol, pool));