From c6c299523151345bbc3c97614c8ac995676e229b Mon Sep 17 00:00:00 2001 From: Murali Reddy Date: Mon, 16 Dec 2013 19:00:29 +0530 Subject: [PATCH] CLOUDSTACK-4616: When system Vms fail to start when host is down , link local Ip addresses do not get released resulting in all the link local Ip addresses being consumed eventually. fix ensure Nics with reservation strategy 'Start' should go through release phase in the Nic life cycle so that release is performed before Nic is removed to avoid resource leaks. --- .../engine/orchestration/NetworkOrchestrator.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java index cbe02ff0941..1505d4166d2 100755 --- a/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java +++ b/engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java @@ -1517,6 +1517,17 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra } protected void removeNic(VirtualMachineProfile vm, NicVO nic) { + + if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start && nic.getState() != Nic.State.Allocated) { + // Nics with reservation strategy 'Start' should go through release phase in the Nic life cycle. + // Ensure that release is performed before Nic is to be removed to avoid resource leaks. + try { + releaseNic(vm, nic.getId()); + } catch (Exception ex) { + s_logger.warn("Failed to release nic: " + nic.toString() + " as part of remove operation due to", ex ); + } + } + nic.setState(Nic.State.Deallocating); _nicDao.update(nic.getId(), nic); NetworkVO network = _networksDao.findById(nic.getNetworkId());