bug 8062: fixed releasing vnet when corresponding network is shutdown. Used to happen because reservation_id for the network didn't match reservation_id for the vnet, and cleanup thread couldn't find vnet to cleanup

status 8062: resolved fixed

Also set broadcastUri to null when shutdown the corresponding network.
This commit is contained in:
alena 2011-01-18 11:20:11 -08:00
parent e526875669
commit f20c725827
3 changed files with 15 additions and 2 deletions

View File

@ -145,5 +145,7 @@ public interface NetworkManager extends NetworkService {
List<NetworkVO> listNetworksUsedByVm(long vmId, boolean isSystem);
<T extends VMInstanceVO> void prepareNicForMigration(VirtualMachineProfile<T> vm, DeployDestination dest);
void resetBroadcastUri(long networkId);
}

View File

@ -1019,7 +1019,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
NetworkOfferingVO offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
network.setState(Network.State.Implementing);
network.setReservationId(context.getReservationId());
_networksDao.update(networkId, network);
Network result = guru.implement(network, offering, dest, context);
@ -1038,6 +1038,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
element.implement(network, offering, dest, context);
}
network.setReservationId(context.getReservationId());
network.setState(Network.State.Implemented);
_networksDao.update(network.getId(), network);
implemented.set(guru, network);
@ -1675,6 +1676,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
txn.start();
if (success) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Network id=" + networkId + " is shutdown successfully, cleaning up corresponding resources now.");
}
NetworkGuru guru = _networkGurus.get(network.getGuruName());
guru.destroy(network, _networkOfferingDao.findById(network.getNetworkOfferingId()));
@ -1732,7 +1734,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
s_logger.debug("We found network " + networkId + " to be free for the first time. Adding it to the list: " + currentTime);
}
stillFree.put(networkId, currentTime);
} else if (time < (currentTime + _networkGcWait)) {
} else if (time > (currentTime - _networkGcWait)) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Network " + networkId + " is still free but it's not time to shutdown yet: " + time);
}
@ -1920,5 +1922,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return networks;
}
@Override
public void resetBroadcastUri(long networkId) {
NetworkVO network = _networksDao.findById(networkId);
network.setBroadcastUri(null);
_networksDao.update(networkId, network);
}
}

View File

@ -241,7 +241,9 @@ public class GuestNetworkGuru extends AdapterBase implements NetworkGuru {
@Override
public void destroy(Network network, NetworkOffering offering) {
s_logger.debug("Releasing vnet for the network id=" + network.getId());
_dcDao.releaseVnet(network.getBroadcastUri().getHost(), network.getDataCenterId(), network.getAccountId(), network.getReservationId());
_networkMgr.resetBroadcastUri(network.getId());
}
@Override