From 6a7fd4d96c01a25220fffde74be0de226d39ac20 Mon Sep 17 00:00:00 2001 From: prachi Date: Mon, 23 Jan 2012 17:57:59 -0800 Subject: [PATCH] Bug 13248 - NPE: DeployVMCmd fired during 2.2.x regression test on Acton build Changes: - After deployment of Router failed, we did not throw out the error inorder to retry the start using another hypervisorType. - But there is no other hypervisor to try, causing the failed and expunged router to be passed on further leading to an NPE later - So in case there are no more hypervisors to retry the router start, we should throw out the original error. --- .../router/VirtualNetworkApplianceManagerImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index e2e6068be76..4fde78c1b54 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -24,6 +24,7 @@ import java.util.Comparator; import java.util.Date; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -1340,7 +1341,10 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian int allocateRetry = 0; int startRetry = 0; - for (HypervisorType hType : supportedHypervisors) { + + + for (Iterator iter = supportedHypervisors.iterator();iter.hasNext();) { + HypervisorType hType = iter.next(); try { s_logger.debug("Allocating the domR with the hypervisor type " + hType); VMTemplateVO template = _templateDao.findRoutingTemplate(hType); @@ -1361,7 +1365,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian router.setRole(Role.VIRTUAL_ROUTER); router = _itMgr.allocate(router, template, routerOffering, networks, plan, null, owner); } catch (InsufficientCapacityException ex) { - if (allocateRetry < 2) { + if (allocateRetry < 2 && iter.hasNext()) { s_logger.debug("Failed to allocate the domR with hypervisor type " + hType + ", retrying one more time"); continue; } else { @@ -1375,7 +1379,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian router = startVirtualRouter(router, _accountMgr.getSystemUser(), _accountMgr.getSystemAccount(), params); break; } catch (InsufficientCapacityException ex) { - if (startRetry < 2) { + if (startRetry < 2 && iter.hasNext()) { s_logger.debug("Failed to start the domR " + router + " with hypervisor type " + hType + ", destroying it and recreating one more time"); //destroy the router destroyRouter(router.getId());