From 394371eba6fdf87e45584ee879e9365ad9a2bfcd Mon Sep 17 00:00:00 2001 From: anthony Date: Wed, 29 Sep 2010 18:30:57 -0700 Subject: [PATCH] bug 6326: correctly update poolsToAvoid status 6326: resolved fixed --- .../com/cloud/storage/StorageManagerImpl.java | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 950aba34f39..6e271772efb 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -431,11 +431,13 @@ public class StorageManagerImpl implements StorageManager { DiskCharacteristicsTO dskCh = createDiskCharacteristics(volume, template, dc, diskOffering); - + int retry = 0; // Determine what pod to store the volume in while ((pod = _agentMgr.findPod(null, null, dc, account.getId(), podsToAvoid)) != null) { + podsToAvoid.add(pod.first().getId()); // Determine what storage pool to store the volume in while ((pool = findStoragePool(dskCh, dc, pod.first(), null, null, null, null, poolsToAvoid)) != null) { + poolsToAvoid.add(pool); volumeFolder = pool.getPath(); if (s_logger.isDebugEnabled()) { s_logger.debug("Attempting to create volume from snapshotId: " + snapshot.getId() + " on storage pool " + pool.getName()); @@ -453,6 +455,15 @@ public class StorageManagerImpl implements StorageManager { } success = true; break; // break out of the "find storage pool" loop + } else { + retry++; + if( retry >= 3 ) { + _volsDao.delete(volumeId); + String msg = "Unable to create volume from snapshot " + snapshot.getId() + " after retrying 3 times, due to " + details; + s_logger.debug(msg); + throw new CloudRuntimeException(msg); + + } } s_logger.warn("Unable to create volume on pool " + pool.getName() + ", reason: " + details); @@ -461,11 +472,16 @@ public class StorageManagerImpl implements StorageManager { if (success) { break; // break out of the "find pod" loop - } else { - podsToAvoid.add(pod.first().getId()); - } + } } + if( !success ) { + _volsDao.delete(volumeId); + String msg = "Unable to create volume from snapshot " + snapshot.getId() + " due to " + details; + s_logger.debug(msg); + throw new CloudRuntimeException(msg); + + } // Update the volume in the database Transaction txn = Transaction.currentTxn(); txn.start();