Compare commits

...

6 Commits

Author SHA1 Message Date
Suresh Kumar Anaparti 4866de488f
Merge 4b317829d7 into bce3e54a7e 2026-01-22 15:20:26 +01:00
Daman Arora bce3e54a7e
improve error handling for template upload notifications (#12412)
Co-authored-by: Daman Arora <daman.arora@shapeblue.com>
2026-01-22 15:02:46 +01:00
Nicolas Vazquez 6a9835904c
Fix for zoneids parameters length on updateAPIs (#12440) 2026-01-22 14:57:46 +01:00
Nicolas Vazquez 6846619a6f
Fix update network offering domainids size limitation (#12431) 2026-01-22 14:32:46 +01:00
Vishesh d1eb2822d9
Remove redundant Exceptions from logs for vm schedules (#12428) 2026-01-22 14:29:35 +01:00
Suresh Kumar Anaparti 4b317829d7
Autoscale VM load balancing rules improvements 2026-01-16 11:50:50 +05:30
14 changed files with 137 additions and 146 deletions

View File

@ -78,6 +78,7 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
@Parameter(name = ApiConstants.DOMAIN_ID,
type = CommandType.STRING,
length = 4096,
description = "The ID of the containing domain(s) as comma separated string, public for public offerings")
private String domainIds;

View File

@ -75,6 +75,7 @@ public class UpdateDiskOfferingCmd extends BaseCmd {
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.STRING,
description = "The ID of the containing zone(s) as comma separated string, all for all zones offerings",
length = 4096,
since = "4.13")
private String zoneIds;

View File

@ -69,6 +69,7 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.STRING,
description = "The ID of the containing zone(s) as comma separated string, all for all zones offerings",
length = 4096,
since = "4.13")
private String zoneIds;

View File

@ -65,6 +65,7 @@ public class UpdateVPCOfferingCmd extends BaseAsyncCmd {
@Parameter(name = ApiConstants.ZONE_ID,
type = CommandType.STRING,
description = "The ID of the containing zone(s) as comma separated string, all for all zones offerings",
length = 4096,
since = "4.13")
private String zoneIds;

View File

@ -42,5 +42,6 @@ public interface LoadBalancerVMMapDao extends GenericDao<LoadBalancerVMMapVO, Lo
LoadBalancerVMMapVO findByLoadBalancerIdAndVmIdVmIp(long loadBalancerId, long instanceId, String instanceIp);
void remove(long id, long instanceId, String instanceIp, Boolean revoke);
int expungeByVmList(List<Long> vmIds, Long batchSize);
}

View File

@ -64,7 +64,6 @@ public class LoadBalancerVMMapDaoImpl extends GenericDaoBase<LoadBalancerVMMapVO
expunge(sc);
}
@Override
public List<LoadBalancerVMMapVO> listByInstanceId(long instanceId) {
SearchCriteria<LoadBalancerVMMapVO> sc = createSearchCriteria();

View File

@ -31,4 +31,6 @@ public interface VMScheduledJobDao extends GenericDao<VMScheduledJobVO, Long> {
int expungeJobsForSchedules(List<Long> scheduleId, Date dateAfter);
int expungeJobsBefore(Date currentTimestamp);
VMScheduledJobVO findByScheduleAndTimestamp(long scheduleId, Date scheduledTimestamp);
}

View File

@ -39,6 +39,8 @@ public class VMScheduledJobDaoImpl extends GenericDaoBase<VMScheduledJobVO, Long
private final SearchBuilder<VMScheduledJobVO> expungeJobForScheduleSearch;
private final SearchBuilder<VMScheduledJobVO> scheduleAndTimestampSearch;
static final String SCHEDULED_TIMESTAMP = "scheduled_timestamp";
static final String VM_SCHEDULE_ID = "vm_schedule_id";
@ -58,6 +60,11 @@ public class VMScheduledJobDaoImpl extends GenericDaoBase<VMScheduledJobVO, Long
expungeJobForScheduleSearch.and(VM_SCHEDULE_ID, expungeJobForScheduleSearch.entity().getVmScheduleId(), SearchCriteria.Op.IN);
expungeJobForScheduleSearch.and(SCHEDULED_TIMESTAMP, expungeJobForScheduleSearch.entity().getScheduledTime(), SearchCriteria.Op.GTEQ);
expungeJobForScheduleSearch.done();
scheduleAndTimestampSearch = createSearchBuilder();
scheduleAndTimestampSearch.and(VM_SCHEDULE_ID, scheduleAndTimestampSearch.entity().getVmScheduleId(), SearchCriteria.Op.EQ);
scheduleAndTimestampSearch.and(SCHEDULED_TIMESTAMP, scheduleAndTimestampSearch.entity().getScheduledTime(), SearchCriteria.Op.EQ);
scheduleAndTimestampSearch.done();
}
/**
@ -92,4 +99,12 @@ public class VMScheduledJobDaoImpl extends GenericDaoBase<VMScheduledJobVO, Long
sc.setParameters(SCHEDULED_TIMESTAMP, date);
return expunge(sc);
}
@Override
public VMScheduledJobVO findByScheduleAndTimestamp(long scheduleId, Date scheduledTimestamp) {
SearchCriteria<VMScheduledJobVO> sc = scheduleAndTimestampSearch.create();
sc.setParameters(VM_SCHEDULE_ID, scheduleId);
sc.setParameters(SCHEDULED_TIMESTAMP, scheduledTimestamp);
return findOneBy(sc);
}
}

View File

@ -2002,7 +2002,7 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
}
private boolean assignLBruleToNewVm(long vmId, AutoScaleVmGroupVO asGroup) {
List<Long> lstVmId = new ArrayList<Long>();
List<Long> vmIds = new ArrayList<>();
long lbId = asGroup.getLoadBalancerId();
List<LoadBalancerVMMapVO> lbVmMapVos = lbVmMapDao.listByLoadBalancerId(lbId);
@ -2015,9 +2015,9 @@ public class AutoScaleManagerImpl extends ManagerBase implements AutoScaleManage
}
}
}
lstVmId.add(new Long(vmId));
vmIds.add(new Long(vmId));
try {
return loadBalancingRulesService.assignToLoadBalancer(lbId, lstVmId, new HashMap<>(), true);
return loadBalancingRulesService.assignToLoadBalancer(lbId, vmIds, new HashMap<>(), true);
} catch (CloudRuntimeException ex) {
logger.warn("Caught exception: ", ex);
return false;

View File

@ -196,9 +196,9 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
@Inject
LoadBalancerVMMapDao _lb2VmMapDao;
@Inject
LBStickinessPolicyDao _lb2stickinesspoliciesDao;
LBStickinessPolicyDao _lb2StickinessPoliciesDao;
@Inject
LBHealthCheckPolicyDao _lb2healthcheckDao;
LBHealthCheckPolicyDao _lb2HealthCheckDao;
@Inject
UserVmDao _vmDao;
@Inject
@ -581,7 +581,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
/* Validation : check for the multiple policies to the rule id */
List<LBStickinessPolicyVO> stickinessPolicies = _lb2stickinesspoliciesDao.listByLoadBalancerId(cmd.getLbRuleId(), false);
List<LBStickinessPolicyVO> stickinessPolicies = _lb2StickinessPoliciesDao.listByLoadBalancerId(cmd.getLbRuleId(), false);
if (stickinessPolicies.size() > 1) {
throw new InvalidParameterValueException("Failed to create Stickiness policy: Already two policies attached " + cmd.getLbRuleId());
}
@ -633,7 +633,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
if (forDisplay != null) {
policy.setDisplay(forDisplay);
}
policy = _lb2stickinesspoliciesDao.persist(policy);
policy = _lb2StickinessPoliciesDao.persist(policy);
return policy;
}
@ -676,7 +676,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
/* Validation : check for the multiple hc policies to the rule id */
List<LBHealthCheckPolicyVO> hcPolicies = _lb2healthcheckDao.listByLoadBalancerId(cmd.getLbRuleId(), false);
List<LBHealthCheckPolicyVO> hcPolicies = _lb2HealthCheckDao.listByLoadBalancerId(cmd.getLbRuleId(), false);
if (hcPolicies.size() > 0) {
throw new InvalidParameterValueException(String.format("Failed to create HealthCheck policy: Already policy attached for the LB Rule:%s", loadBalancer));
}
@ -702,7 +702,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
policy.setDisplay(forDisplay);
}
policy = _lb2healthcheckDao.persist(policy);
policy = _lb2HealthCheckDao.persist(policy);
return policy;
}
@ -737,7 +737,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, loadBalancer);
List<LBStickinessPolicyVO> stickinessPolicies = _lb2stickinesspoliciesDao.listByLoadBalancerId(cmd.getLbRuleId(), false);
List<LBStickinessPolicyVO> stickinessPolicies = _lb2StickinessPoliciesDao.listByLoadBalancerId(cmd.getLbRuleId(), false);
for (LBStickinessPolicyVO stickinessPolicy : stickinessPolicies) {
if (stickinessPolicy.getId() == cmd.getEntityId()) {
backupState = loadBalancer.getState();
@ -746,7 +746,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
} else {
oldStickinessPolicyId = stickinessPolicy.getId();
stickinessPolicy.setRevoke(true);
_lb2stickinesspoliciesDao.persist(stickinessPolicy);
_lb2StickinessPoliciesDao.persist(stickinessPolicy);
}
}
try {
@ -761,9 +761,9 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
} else {
deleteLBStickinessPolicy(cmd.getEntityId(), false);
if (oldStickinessPolicyId != 0) {
LBStickinessPolicyVO stickinessPolicy = _lb2stickinesspoliciesDao.findById(oldStickinessPolicyId);
LBStickinessPolicyVO stickinessPolicy = _lb2StickinessPoliciesDao.findById(oldStickinessPolicyId);
stickinessPolicy.setRevoke(false);
_lb2stickinesspoliciesDao.persist(stickinessPolicy);
_lb2StickinessPoliciesDao.persist(stickinessPolicy);
try {
if (backupState.equals(FirewallRule.State.Active))
applyLoadBalancerConfig(cmd.getLbRuleId());
@ -816,7 +816,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
boolean success = true;
CallContext caller = CallContext.current();
LBStickinessPolicyVO stickinessPolicy = _lb2stickinesspoliciesDao.findById(stickinessPolicyId);
LBStickinessPolicyVO stickinessPolicy = _lb2StickinessPoliciesDao.findById(stickinessPolicyId);
if (stickinessPolicy == null) {
throw new InvalidParameterValueException("Invalid Stickiness policy id value: " + stickinessPolicyId);
@ -838,7 +838,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
boolean backupStickyState = stickinessPolicy.isRevoke();
stickinessPolicy.setRevoke(true);
_lb2stickinesspoliciesDao.persist(stickinessPolicy);
_lb2StickinessPoliciesDao.persist(stickinessPolicy);
logger.debug("Set load balancer rule for revoke: rule {}, stickinesspolicy {}", loadBalancer, stickinessPolicy);
try {
@ -850,7 +850,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
} catch (ResourceUnavailableException e) {
if (isRollBackAllowedForProvider(loadBalancer)) {
stickinessPolicy.setRevoke(backupStickyState);
_lb2stickinesspoliciesDao.persist(stickinessPolicy);
_lb2StickinessPoliciesDao.persist(stickinessPolicy);
loadBalancer.setState(backupState);
_lbDao.persist(loadBalancer);
logger.debug("LB Rollback rule: {} while deleting sticky policy: {}", loadBalancer, stickinessPolicy);
@ -859,7 +859,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
success = false;
}
} else {
_lb2stickinesspoliciesDao.expunge(stickinessPolicyId);
_lb2StickinessPoliciesDao.expunge(stickinessPolicyId);
}
return success;
}
@ -871,7 +871,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
boolean success = true;
CallContext caller = CallContext.current();
LBHealthCheckPolicyVO healthCheckPolicy = _lb2healthcheckDao.findById(healthCheckPolicyId);
LBHealthCheckPolicyVO healthCheckPolicy = _lb2HealthCheckDao.findById(healthCheckPolicyId);
if (healthCheckPolicy == null) {
throw new InvalidParameterValueException("Invalid HealthCheck policy id value: " + healthCheckPolicyId);
@ -892,7 +892,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
boolean backupStickyState = healthCheckPolicy.isRevoke();
healthCheckPolicy.setRevoke(true);
_lb2healthcheckDao.persist(healthCheckPolicy);
_lb2HealthCheckDao.persist(healthCheckPolicy);
logger.debug("Set health check policy to revoke for loadbalancing rule : {}, healthCheckpolicy {}", loadBalancer, healthCheckPolicy);
// removing the state of services set by the monitor.
@ -919,7 +919,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
} catch (ResourceUnavailableException e) {
if (isRollBackAllowedForProvider(loadBalancer)) {
healthCheckPolicy.setRevoke(backupStickyState);
_lb2healthcheckDao.persist(healthCheckPolicy);
_lb2HealthCheckDao.persist(healthCheckPolicy);
loadBalancer.setState(backupState);
_lbDao.persist(loadBalancer);
logger.debug("LB Rollback rule: {} while deleting healthcheck policy: {}", loadBalancer, healthCheckPolicy);
@ -928,7 +928,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
success = false;
}
} else {
_lb2healthcheckDao.remove(healthCheckPolicy.getLoadBalancerId());
_lb2HealthCheckDao.remove(healthCheckPolicy.getLoadBalancerId());
}
return success;
}
@ -1003,14 +1003,11 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
private boolean isRollBackAllowedForProvider(LoadBalancerVO loadBalancer) {
Network network = _networkDao.findById(loadBalancer.getNetworkId());
List<Provider> provider = _networkMgr.getProvidersForServiceInNetwork(network, Service.Lb);
if (provider == null || provider.size() == 0) {
if (provider == null || provider.isEmpty()) {
return false;
}
if (provider.get(0) == Provider.Netscaler || provider.get(0) == Provider.F5BigIp ||
provider.get(0) == Provider.VirtualRouter || provider.get(0) == Provider.VPCVirtualRouter) {
return true;
}
return false;
return provider.get(0) == Provider.Netscaler || provider.get(0) == Provider.F5BigIp ||
provider.get(0) == Provider.VirtualRouter || provider.get(0) == Provider.VPCVirtualRouter;
}
@Override
@ -1044,34 +1041,26 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
//only instanceids list passed
if (instanceIds != null && vmIdIpMap.isEmpty()){
vmIdIpMap = new HashMap<Long, List<String>>();
vmIdIpMap = new HashMap<>();
for (long instanceId: instanceIds){
vmIdIpMap.put(instanceId, null);
}
}
List<LoadBalancerVMMapVO> mappedInstances = _lb2VmMapDao.listByLoadBalancerId(loadBalancerId, false);
Set<Long> mappedInstanceIds = new HashSet<Long>();
for (LoadBalancerVMMapVO mappedInstance : mappedInstances) {
mappedInstanceIds.add(Long.valueOf(mappedInstance.getInstanceId()));
}
Map<Long, List<String>> existingVmIdIps = new HashMap<Long, List<String>>();
Map<Long, List<String>> existingVmIdIps = new HashMap<>();
// now get the ips of vm and add it to map
for (LoadBalancerVMMapVO mappedInstance : mappedInstances) {
List<String> ipsList = null;
if (existingVmIdIps.containsKey(mappedInstance.getInstanceId())) {
ipsList = existingVmIdIps.get(mappedInstance.getInstanceId());
} else {
ipsList = new ArrayList<String>();
ipsList = new ArrayList<>();
}
ipsList.add(mappedInstance.getInstanceIp());
existingVmIdIps.put(mappedInstance.getInstanceId(), ipsList);
}
final List<UserVm> vmsToAdd = new ArrayList<UserVm>();
// check for conflict
Set<Long> passedInstanceIds = vmIdIpMap.keySet();
for (Long instanceId : passedInstanceIds) {
@ -1110,7 +1099,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
throw ex;
}
String priIp = nicInSameNetwork.getIPv4Address();
String primaryIp = nicInSameNetwork.getIPv4Address();
if (existingVmIdIps.containsKey(instanceId)) {
// now check for ip address
@ -1118,8 +1107,8 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
List<String> newIps = vmIdIpMap.get(instanceId);
if (newIps == null) {
newIps = new ArrayList<String>();
newIps.add(priIp);
newIps = new ArrayList<>();
newIps.add(primaryIp);
}
for (String newIp: newIps) {
@ -1130,31 +1119,28 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
List<String> vmIpsList = vmIdIpMap.get(instanceId);
String vmLbIp = null;
if (vmIpsList != null) {
//check if the ips belongs to nic secondary ip
for (String ip: vmIpsList) {
// skip the primary ip from vm secondary ip comparisions
if (ip.equals(priIp)) {
// skip the primary ip from vm secondary ip comparison
if (ip.equals(primaryIp)) {
continue;
}
if(_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) {
if (_nicSecondaryIpDao.findByIp4AddressAndNicId(ip,nicInSameNetwork.getId()) == null) {
throw new InvalidParameterValueException("Instance IP "+ ip + " specified does not belong to " +
"NIC in Network " + nicInSameNetwork.getNetworkId());
}
}
} else {
vmIpsList = new ArrayList<String>();
vmIpsList.add(priIp);
vmIpsList = new ArrayList<>();
vmIpsList.add(primaryIp);
}
// when vm id is passed in instance ids and in vmidipmap
// assign for primary ip and ip passed in vmidipmap
if (instanceIds != null ) {
if (instanceIds.contains(instanceId)) {
vmIpsList.add(priIp);
vmIpsList.add(primaryIp);
}
}
@ -1163,7 +1149,6 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
if (logger.isDebugEnabled()) {
logger.debug("Adding " + vm + " to the load balancer pool");
}
vmsToAdd.add(vm);
}
final Set<Long> vmIds = vmIdIpMap.keySet();
@ -1172,7 +1157,6 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(TransactionStatus status) {
for (Long vmId : vmIds) {
final Set<String> lbVmIps = new HashSet<String>(newMap.get(vmId));
for (String vmIp: lbVmIps) {
@ -1226,7 +1210,6 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
// right VO object or table name.
throw ex;
}
}
return success;
@ -1408,8 +1391,6 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
}
boolean success = false;
FirewallRule.State backupState = loadBalancer.getState();
Set<Long> vmIds = vmIdIpMap.keySet();
@ -1434,12 +1415,11 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
+ " for LB rule id " + loadBalancerId);
}
for (LoadBalancerVMMapVO lbvm: lbVms) {
lbvm.setRevoke(true);
_lb2VmMapDao.persist(lbvm);
for (LoadBalancerVMMapVO lbVm: lbVms) {
lbVm.setRevoke(true);
_lb2VmMapDao.persist(lbVm);
}
logger.debug("Set load balancer rule for revoke: rule {}, vm {}", loadBalancer::toString, () -> _vmDao.findById(instanceId));
} else {
for (String vmIp: lbVmIps) {
LoadBalancerVMMapVO map = _lb2VmMapDao.findByLoadBalancerIdAndVmIdVmIp (loadBalancerId, instanceId, vmIp);
@ -1448,7 +1428,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
map.setRevoke(true);
_lb2VmMapDao.persist(map);
logger.debug("Set load balancer rule for revoke: rule {}, vmId {}, vmip {}", loadBalancer::toString, () -> _vmDao.findById(instanceId), vmIp::toString);
logger.debug("Set load balancer rule for revoke: rule {}, vmId {}, vmIp {}", loadBalancer::toString, () -> _vmDao.findById(instanceId), vmIp::toString);
}
}
}
@ -1480,7 +1460,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
map.setRevoke(false);
_lb2VmMapDao.persist(map);
logger.debug("LB Rollback rule: {},while removing vmId {}", loadBalancer, instanceId);
}else {
} else {
for (String vmIp: lbVmIps) {
LoadBalancerVMMapVO map = _lb2VmMapDao.findByLoadBalancerIdAndVmIdVmIp (loadBalancerId, instanceId, vmIp);
map.setRevoke(true);
@ -1507,36 +1487,35 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
@Override
public boolean removeVmFromLoadBalancers(long instanceId) {
boolean success = true;
List<LoadBalancerVMMapVO> maps = _lb2VmMapDao.listByInstanceId(instanceId);
if (maps == null || maps.isEmpty()) {
List<LoadBalancerVMMapVO> lb2VmMaps = _lb2VmMapDao.listByInstanceId(instanceId);
if (lb2VmMaps == null || lb2VmMaps.isEmpty()) {
return true;
}
Map<Long, List<Long>> lbsToReconfigure = new HashMap<Long, List<Long>>();
Map<Long, List<Long>> lbsToReconfigure = new HashMap<>();
// first set all existing lb mappings with Revoke state
for (LoadBalancerVMMapVO map : maps) {
long lbId = map.getLoadBalancerId();
for (LoadBalancerVMMapVO lb2VmMap : lb2VmMaps) {
long lbId = lb2VmMap.getLoadBalancerId();
List<Long> instances = lbsToReconfigure.get(lbId);
if (instances == null) {
instances = new ArrayList<Long>();
instances = new ArrayList<>();
}
instances.add(map.getInstanceId());
instances.add(lb2VmMap.getInstanceId());
lbsToReconfigure.put(lbId, instances);
map.setRevoke(true);
_lb2VmMapDao.persist(map);
logger.debug("Set load balancer rule for revoke: rule {}, vm {}", () -> _lbDao.findById(map.getLoadBalancerId()), () -> _vmDao.findById(instanceId));
lb2VmMap.setRevoke(true);
_lb2VmMapDao.persist(lb2VmMap);
logger.debug("Set load balancer rule for revoke: rule {}, vm {}", () -> _lbDao.findById(lb2VmMap.getLoadBalancerId()), () -> _vmDao.findById(instanceId));
}
// Reapply all lbs that had the vm assigned
if (lbsToReconfigure != null) {
for (Map.Entry<Long, List<Long>> lb : lbsToReconfigure.entrySet()) {
if (!removeFromLoadBalancerInternal(lb.getKey(), lb.getValue(), false, new HashMap<>(), false)) {
success = false;
}
for (Map.Entry<Long, List<Long>> lb : lbsToReconfigure.entrySet()) {
if (!removeFromLoadBalancerInternal(lb.getKey(), lb.getValue(), false, new HashMap<>(), false)) {
success = false;
}
}
return success;
}
@ -1604,10 +1583,10 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
}
List<LBHealthCheckPolicyVO> hcPolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(loadBalancerId, null);
List<LBHealthCheckPolicyVO> hcPolicies = _lb2HealthCheckDao.listByLoadBalancerIdAndDisplayFlag(loadBalancerId, null);
for (LBHealthCheckPolicyVO lbHealthCheck : hcPolicies) {
lbHealthCheck.setRevoke(true);
_lb2healthcheckDao.persist(lbHealthCheck);
_lb2HealthCheckDao.persist(lbHealthCheck);
}
if (generateUsageEvent) {
@ -2037,35 +2016,31 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
// remove LB-Vm mappings that were state to revoke
List<LoadBalancerVMMapVO> lbVmMaps = _lb2VmMapDao.listByLoadBalancerId(lb.getId(), true);
List<Long> instanceIds = new ArrayList<Long>();
for (LoadBalancerVMMapVO lbVmMap : lbVmMaps) {
instanceIds.add(lbVmMap.getInstanceId());
_lb2VmMapDao.remove(lb.getId(), lbVmMap.getInstanceId(), lbVmMap.getInstanceIp(), null);
List<LoadBalancerVMMapVO> lbVmMapsToRevoke = _lb2VmMapDao.listByLoadBalancerId(lb.getId(), true);
for (LoadBalancerVMMapVO lbVmMapToRevoke : lbVmMapsToRevoke) {
_lb2VmMapDao.remove(lb.getId(), lbVmMapToRevoke.getInstanceId(), lbVmMapToRevoke.getInstanceIp(), null);
logger.debug("Load balancer rule {} is removed for Instance {} and IP {}",
lb, lbVmMap.getInstanceId(), lbVmMap.getInstanceIp());;
lb, lbVmMapToRevoke.getInstanceId(), lbVmMapToRevoke.getInstanceIp());;
}
if (_lb2VmMapDao.listByLoadBalancerId(lb.getId()).isEmpty()) {
lb.setState(FirewallRule.State.Add);
_lbDao.persist(lb);
logger.debug("LB rule {} state is set to Add as there are no more active LB-VM mappings", lb);
logger.debug("Load balancer rule {} state is set to Add as there are no more active LB-VM mappings", lb);
}
// remove LB-Stickiness policy mapping that were state to revoke
List<LBStickinessPolicyVO> stickinesspolicies = _lb2stickinesspoliciesDao.listByLoadBalancerId(lb.getId(), true);
if (!stickinesspolicies.isEmpty()) {
_lb2stickinesspoliciesDao.remove(lb.getId(), true);
List<LBStickinessPolicyVO> stickinessPolicies = _lb2StickinessPoliciesDao.listByLoadBalancerId(lb.getId(), true);
if (!stickinessPolicies.isEmpty()) {
_lb2StickinessPoliciesDao.remove(lb.getId(), true);
logger.debug("Load balancer rule {} is removed stickiness policies", lb);
}
// remove LB-HealthCheck policy mapping that were state to
// revoke
List<LBHealthCheckPolicyVO> healthCheckpolicies = _lb2healthcheckDao.listByLoadBalancerId(lb.getId(), true);
List<LBHealthCheckPolicyVO> healthCheckpolicies = _lb2HealthCheckDao.listByLoadBalancerId(lb.getId(), true);
if (!healthCheckpolicies.isEmpty()) {
_lb2healthcheckDao.remove(lb.getId(), true);
_lb2HealthCheckDao.remove(lb.getId(), true);
logger.debug("Load balancer rule {} is removed health check monitors policies", lb);
}
@ -2159,7 +2134,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
@Override
public List<LbStickinessPolicy> getStickinessPolicies(long lbId) {
List<LbStickinessPolicy> stickinessPolicies = new ArrayList<LbStickinessPolicy>();
List<LBStickinessPolicyVO> sDbpolicies = _lb2stickinesspoliciesDao.listByLoadBalancerId(lbId, false);
List<LBStickinessPolicyVO> sDbpolicies = _lb2StickinessPoliciesDao.listByLoadBalancerId(lbId, false);
for (LBStickinessPolicyVO sDbPolicy : sDbpolicies) {
LbStickinessPolicy sPolicy = new LbStickinessPolicy(sDbPolicy.getMethodName(), sDbPolicy.getParams(), sDbPolicy.isRevoke());
@ -2171,7 +2146,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
@Override
public List<LbHealthCheckPolicy> getHealthCheckPolicies(long lbId) {
List<LbHealthCheckPolicy> healthCheckPolicies = new ArrayList<LbHealthCheckPolicy>();
List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(lbId, null);
List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2HealthCheckDao.listByLoadBalancerIdAndDisplayFlag(lbId, null);
for (LBHealthCheckPolicyVO policy : hcDbpolicies) {
String pingpath = policy.getpingpath();
@ -2301,7 +2276,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
Boolean applied = cmd.isApplied();
if (applied == null) {
logger.info(String.format("The [%s] parameter was not passed. Using the default value [%s].", ApiConstants.APPLIED, Boolean.TRUE));
logger.info("The [{}] parameter was not passed. Using the default value [{}].", ApiConstants.APPLIED, Boolean.TRUE);
applied = Boolean.TRUE;
}
@ -2320,7 +2295,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
List<String> serviceStates = new ArrayList<>();
List<LoadBalancerVMMapVO> vmLoadBalancerMappings = _lb2VmMapDao.listByLoadBalancerId(loadBalancerId);
if (vmLoadBalancerMappings == null) {
if (vmLoadBalancerMappings == null || vmLoadBalancerMappings.isEmpty()) {
String msg = String.format("Unable to find map of VMs related to load balancer [%s].", loadBalancerAsString);
logger.error(msg);
throw new CloudRuntimeException(msg);
@ -2337,6 +2312,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
List<UserVmVO> userVms = _vmDao.listByIds(appliedInstanceIdList);
for (UserVmVO userVm : userVms) {
String userVmAsString = ReflectionToStringBuilderUtils.reflectOnlySelectedFields(userVm, "uuid", "name");
// if the VM is destroyed, being expunged, in an error state, or in
// an unknown state, skip it
switch (userVm.getState()) {
@ -2344,24 +2320,23 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
case Expunging:
case Error:
case Unknown:
logger.debug("Skipping adding service state from the user VM [{}] to the service state list, as the VM is in state: {}. ", userVmAsString, userVm.getState());
continue;
}
String userVmAsString = ReflectionToStringBuilderUtils.reflectOnlySelectedFields(userVm, "uuid", "name");
boolean isApplied = appliedInstanceIdList.contains(userVm.getId());
String isAppliedMsg = isApplied ? "is applied" : "is not applied";
logger.debug(String.format("The user VM [%s] %s to a rule of the load balancer [%s].", userVmAsString, isAppliedMsg, loadBalancerAsString));
logger.debug("The user VM [{}] {} to a rule of the load balancer [{}].", userVmAsString, isAppliedMsg, loadBalancerAsString);
if (isApplied != applied) {
logger.debug(String.format("Skipping adding service state from the user VM [%s] to the service state list. This happens because the VM %s to the load "
+ "balancer rule and the [%s] parameter was passed as [%s].", userVmAsString, isAppliedMsg, ApiConstants.APPLIED, applied));
logger.debug("Skipping adding service state from the user VM [{}] to the service state list. This happens because the VM {} to the load "
+ "balancer rule and the [{}] parameter was passed as [{}].", userVmAsString, isAppliedMsg, ApiConstants.APPLIED, applied);
continue;
}
loadBalancerInstances.add(userVm);
String serviceState = vmServiceState.get(userVm.getId());
logger.debug(String.format("Adding the service state [%s] from the user VM [%s] to the service state list.", serviceState, userVmAsString));
logger.debug("Adding the service state [{}] from the user VM [{}] to the service state list.", serviceState, userVmAsString);
serviceStates.add(serviceState);
}
@ -2371,26 +2346,25 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
@Override
public List<String> listLbVmIpAddress (long id, long vmId) {
List <LoadBalancerVMMapVO> listLbvmMapVo = _lb2VmMapDao.listByLoadBalancerIdAndVmId(id, vmId);
List <LoadBalancerVMMapVO> listLbVmMapVo = _lb2VmMapDao.listByLoadBalancerIdAndVmId(id, vmId);
List <String> vmIps = new ArrayList<String>();
for (LoadBalancerVMMapVO lbVmVo : listLbvmMapVo) {
List <String> vmIps = new ArrayList<>();
for (LoadBalancerVMMapVO lbVmVo : listLbVmMapVo) {
vmIps.add(lbVmVo.getInstanceIp());
}
return vmIps;
}
@Override
public List<LbStickinessMethod> getStickinessMethods(long networkid) {
String capability = getLBCapability(networkid, Capability.SupportedStickinessMethods.getName());
public List<LbStickinessMethod> getStickinessMethods(long networkId) {
String capability = getLBCapability(networkId, Capability.SupportedStickinessMethods.getName());
if (capability == null) {
return null;
}
Gson gson = new Gson();
java.lang.reflect.Type listType = new TypeToken<List<LbStickinessMethod>>() {
}.getType();
List<LbStickinessMethod> result = gson.fromJson(capability, listType);
return result;
return gson.fromJson(capability, listType);
}
@Override
@ -2414,9 +2388,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
_accountMgr.checkAccess(caller, null, true, loadBalancer);
List<LBStickinessPolicyVO> sDbpolicies = _lb2stickinesspoliciesDao.listByLoadBalancerIdAndDisplayFlag(loadBalancer.getId(), forDisplay);
return sDbpolicies;
return _lb2StickinessPoliciesDao.listByLoadBalancerIdAndDisplayFlag(loadBalancer.getId(), forDisplay);
}
@Override
@ -2425,7 +2397,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
Long loadBalancerId = cmd.getLbRuleId();
Long policyId = cmd.getId();
boolean forDisplay = cmd.getDisplay();
if(loadBalancerId == null) {
if (loadBalancerId == null) {
loadBalancerId = findLBIdByHealtCheckPolicyId(policyId);
}
LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
@ -2434,9 +2406,8 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
_accountMgr.checkAccess(caller, null, true, loadBalancer);
List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(loadBalancerId, forDisplay);
return hcDbpolicies;
return _lb2HealthCheckDao.listByLoadBalancerIdAndDisplayFlag(loadBalancerId, forDisplay);
}
@Override
@ -2559,7 +2530,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
@Override
public LoadBalancerVO findLbByStickinessId(long stickinessPolicyId) {
LBStickinessPolicyVO stickinessPolicy = _lb2stickinesspoliciesDao.findById(stickinessPolicyId);
LBStickinessPolicyVO stickinessPolicy = _lb2StickinessPoliciesDao.findById(stickinessPolicyId);
if (stickinessPolicy == null) {
return null;
@ -2574,7 +2545,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
public boolean applyLbRules(List<LoadBalancingRule> rules, boolean continueOnError) throws ResourceUnavailableException {
if (rules == null || rules.size() == 0) {
if (rules == null || rules.isEmpty()) {
logger.debug("There are no Load Balancing Rules to forward to the network elements");
return true;
}
@ -2593,7 +2564,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
}
// rules can not programmed unless IP is associated with network
// service provider, so run IP assoication for
// service provider, so run IP association for
// the network so as to ensure IP is associated before applying
// rules (in add state)
_ipAddrMgr.applyIpAssociations(network, false, continueOnError, publicIps);
@ -2633,10 +2604,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
@Override
public boolean isLbRuleMappedToVmGuestIp(String vmSecondaryIp) {
List<LoadBalancerVMMapVO> lbVmMap = _lb2VmMapDao.listByInstanceIp(vmSecondaryIp);
if (lbVmMap == null || lbVmMap.isEmpty()) {
return false;
}
return true;
return lbVmMap != null && !lbVmMap.isEmpty();
}
@Override
@ -2681,7 +2649,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
@Override
@ActionEvent(eventType = EventTypes.EVENT_LB_STICKINESSPOLICY_UPDATE, eventDescription = "updating lb stickiness policy", async = true)
public StickinessPolicy updateLBStickinessPolicy(long id, String customId, Boolean forDisplay) {
LBStickinessPolicyVO policy = _lb2stickinesspoliciesDao.findById(id);
LBStickinessPolicyVO policy = _lb2StickinessPoliciesDao.findById(id);
if (policy == null) {
throw new InvalidParameterValueException("Fail to find stickiness policy with " + id);
}
@ -2701,14 +2669,14 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
policy.setDisplay(forDisplay);
}
_lb2stickinesspoliciesDao.update(id, policy);
return _lb2stickinesspoliciesDao.findById(id);
_lb2StickinessPoliciesDao.update(id, policy);
return _lb2StickinessPoliciesDao.findById(id);
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_LB_HEALTHCHECKPOLICY_UPDATE, eventDescription = "updating lb healthcheck policy", async = true)
public HealthCheckPolicy updateLBHealthCheckPolicy(long id, String customId, Boolean forDisplay) {
LBHealthCheckPolicyVO policy = _lb2healthcheckDao.findById(id);
LBHealthCheckPolicyVO policy = _lb2HealthCheckDao.findById(id);
if (policy == null) {
throw new InvalidParameterValueException("Fail to find stickiness policy with " + id);
}
@ -2728,17 +2696,16 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
policy.setDisplay(forDisplay);
}
_lb2healthcheckDao.update(id, policy);
return _lb2healthcheckDao.findById(id);
_lb2HealthCheckDao.update(id, policy);
return _lb2HealthCheckDao.findById(id);
}
@Override
public Long findLBIdByHealtCheckPolicyId(long lbHealthCheckPolicy) {
LBHealthCheckPolicyVO policy= _lb2healthcheckDao.findById(lbHealthCheckPolicy);
if(policy != null) {
LBHealthCheckPolicyVO policy= _lb2HealthCheckDao.findById(lbHealthCheckPolicy);
if (policy != null) {
return policy.getLoadBalancerId();
}
return null;
}
}

View File

@ -162,7 +162,13 @@ public class VMSchedulerImpl extends ManagerBase implements VMScheduler, Configu
}
Date scheduledDateTime = Date.from(ts.toInstant());
VMScheduledJobVO scheduledJob = new VMScheduledJobVO(vmSchedule.getVmId(), vmSchedule.getId(), vmSchedule.getAction(), scheduledDateTime);
VMScheduledJobVO scheduledJob = vmScheduledJobDao.findByScheduleAndTimestamp(vmSchedule.getId(), scheduledDateTime);
if (scheduledJob != null) {
logger.trace("Job is already scheduled for schedule {} at {}", vmSchedule, scheduledDateTime);
return scheduledDateTime;
}
scheduledJob = new VMScheduledJobVO(vmSchedule.getVmId(), vmSchedule.getId(), vmSchedule.getAction(), scheduledDateTime);
try {
vmScheduledJobDao.persist(scheduledJob);
ActionEventUtils.onScheduledActionEvent(User.UID_SYSTEM, vm.getAccountId(), actionEventMap.get(vmSchedule.getAction()),

View File

@ -74,8 +74,8 @@ public class UpdateLoadBalancerTest {
_lbMgr._autoScaleVmGroupDao = Mockito.mock(AutoScaleVmGroupDao.class);
_lbMgr._networkDao = netDao;
_lbMgr._networkModel = netModel;
_lbMgr._lb2healthcheckDao = Mockito.mock(LBHealthCheckPolicyDao.class);
_lbMgr._lb2stickinesspoliciesDao = Mockito.mock(LBStickinessPolicyDao.class);
_lbMgr._lb2HealthCheckDao = Mockito.mock(LBHealthCheckPolicyDao.class);
_lbMgr._lb2StickinessPoliciesDao = Mockito.mock(LBStickinessPolicyDao.class);
_lbMgr._lb2VmMapDao = Mockito.mock(LoadBalancerVMMapDao.class);
_lbMgr._lbCertMapDao = Mockito.mock(LoadBalancerCertMapDao.class);
_lbMgr._lbDao = lbDao;

View File

@ -218,18 +218,19 @@ export const notifierPlugin = {
if (error.response.status) {
msg = `${i18n.global.t('message.request.failed')} (${error.response.status})`
}
if (error.message) {
desc = error.message
}
if (error.response.headers && 'x-description' in error.response.headers) {
if (error.response.headers?.['x-description']) {
desc = error.response.headers['x-description']
}
if (desc === '' && error.response.data) {
} else if (error.response.data) {
const responseKey = _.findKey(error.response.data, 'errortext')
if (responseKey) {
desc = error.response.data[responseKey].errortext
} else if (typeof error.response.data === 'string') {
desc = error.response.data
}
}
if (!desc && error.message) {
desc = error.message
}
}
let countNotify = store.getters.countNotify
countNotify++

View File

@ -638,11 +638,7 @@ export default {
this.$emit('refresh-data')
this.closeAction()
}).catch(e => {
this.$notification.error({
message: this.$t('message.upload.failed'),
description: `${this.$t('message.upload.template.failed.description')} - ${e}`,
duration: 0
})
this.$notifyError(e)
})
},
fetchCustomHypervisorName () {