CLOUDSTACK-6374: Remove entries from lb vm map when lb rule apply fails

This commit is contained in:
Kishan Kavala 2014-04-10 14:41:52 +05:30
parent 85072cb6b9
commit 16ab5ce76c
1 changed files with 10 additions and 9 deletions

View File

@ -1095,7 +1095,10 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
applyLoadBalancerConfig(loadBalancerId);
success = true;
} catch (ResourceUnavailableException e) {
if (isRollBackAllowedForProvider(loadBalancer)) {
s_logger.warn("Unable to apply the load balancer config because resource is unavaliable.", e);
success = false;
} finally {
if (!success) {
final List<Long> vmInstanceIds = new ArrayList<Long>();
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
@ -1111,16 +1114,14 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
loadBalancer.setState(backupState);
_lbDao.persist(loadBalancer);
CloudRuntimeException ex = new CloudRuntimeException("Failed to add specified loadbalancerruleid for vms "
+ instanceIds);
ex.addProxyObject(loadBalancer.getUuid(), "loadBalancerId");
// TBD: Also pack in the instanceIds in the exception using the
// right VO object or table name.
throw ex;
}
s_logger.warn("Unable to apply the load balancer config because resource is unavaliable.", e);
}
if (!success) {
CloudRuntimeException ex = new CloudRuntimeException("Failed to add specified loadbalancerruleid for vms " + instanceIds);
ex.addProxyObject(loadBalancer.getUuid(), "loadBalancerId");
// TBD: Also pack in the instanceIds in the exception using the
// right VO object or table name.
throw ex;
}
return success;