mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-8091: Stale entry exists for a VM NIC even after an exception while adding a new nic to vm
(cherry picked from commit 4821bfffe2813ffb43761246e75cc7cf73291d27) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
7d1ced7400
commit
54d08a8e29
@ -1045,16 +1045,27 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
||||
}
|
||||
|
||||
NicProfile guestNic = null;
|
||||
boolean cleanUp = true;
|
||||
|
||||
try {
|
||||
guestNic = _itMgr.addVmToNetwork(vmInstance, network, profile);
|
||||
cleanUp = false;
|
||||
} catch (ResourceUnavailableException e) {
|
||||
throw new CloudRuntimeException("Unable to add NIC to " + vmInstance + ": " + e);
|
||||
} catch (InsufficientCapacityException e) {
|
||||
throw new CloudRuntimeException("Insufficient capacity when adding NIC to " + vmInstance + ": " + e);
|
||||
} catch (ConcurrentOperationException e) {
|
||||
throw new CloudRuntimeException("Concurrent operations on adding NIC to " + vmInstance + ": " + e);
|
||||
} finally {
|
||||
if(cleanUp) {
|
||||
try {
|
||||
_itMgr.removeVmFromNetwork(vmInstance, network, null);
|
||||
} catch (ResourceUnavailableException e) {
|
||||
throw new CloudRuntimeException("Error while cleaning up NIC " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (guestNic == null) {
|
||||
throw new CloudRuntimeException("Unable to add NIC to " + vmInstance);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user