mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fix issue with allocator not considering subsequent clusters (#10603)
* Fix issue with allocator not considering subsequent clusters * add missing return * remove unused import * update as per inputs
This commit is contained in:
parent
0af887bce1
commit
0da243d660
@ -94,15 +94,17 @@ public class RandomAllocator extends AdapterBase implements HostAllocator {
|
|||||||
return suitableHosts;
|
return suitableHosts;
|
||||||
}
|
}
|
||||||
String offeringHostTag = offering.getHostTag();
|
String offeringHostTag = offering.getHostTag();
|
||||||
|
|
||||||
VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
|
VMTemplateVO template = (VMTemplateVO)vmProfile.getTemplate();
|
||||||
String templateTag = template.getTemplateTag();
|
String templateTag = template.getTemplateTag();
|
||||||
String hostTag = null;
|
String hostTag = null;
|
||||||
if (ObjectUtils.anyNull(offeringHostTag, templateTag)) {
|
if (ObjectUtils.anyNotNull(offeringHostTag, templateTag)) {
|
||||||
hostTag = offeringHostTag;
|
hostTag = ObjectUtils.allNotNull(offeringHostTag, templateTag) ?
|
||||||
hostTag = hostTag == null ? templateTag : String.format("%s, %s", hostTag, templateTag);
|
String.format("%s, %s", offeringHostTag, templateTag) :
|
||||||
logger.debug(String.format("Looking for hosts in dc [%s], pod [%s], cluster [%s] and complying with host tag(s): [%s]", dcId, podId, clusterId, hostTag));
|
ObjectUtils.firstNonNull(offeringHostTag, templateTag);
|
||||||
|
logger.debug("Looking for hosts in dc [{}], pod [{}], cluster [{}] and complying with host tag(s): [{}]", dcId, podId, clusterId, hostTag);
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Looking for hosts in dc: " + dcId + " pod:" + podId + " cluster:" + clusterId);
|
logger.debug("Looking for hosts in dc: {} pod: {} cluster: {}", dcId , podId, clusterId);
|
||||||
}
|
}
|
||||||
if (hosts != null) {
|
if (hosts != null) {
|
||||||
// retain all computing hosts, regardless of whether they support routing...it's random after all
|
// retain all computing hosts, regardless of whether they support routing...it's random after all
|
||||||
|
|||||||
@ -25,7 +25,6 @@ import java.util.Map;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.naming.ConfigurationException;
|
import javax.naming.ConfigurationException;
|
||||||
|
|
||||||
import com.cloud.utils.exception.CloudRuntimeException;
|
|
||||||
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
|
||||||
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
import org.apache.cloudstack.utils.reflectiontostringbuilderutils.ReflectionToStringBuilderUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -130,8 +129,8 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
|
|||||||
// FirstFitAllocator should be used for user VMs only since it won't care whether the host is capable of routing or not
|
// FirstFitAllocator should be used for user VMs only since it won't care whether the host is capable of routing or not
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
String paramAsStringToLog = String.format("zone [%s], pod [%s], cluster [%s]", dcId, podId, clusterId);
|
||||||
logger.debug("Looking for hosts in zone [{}], pod [{}], cluster [{}]", dcId, podId, clusterId);
|
logger.debug("Looking for hosts in {}", paramAsStringToLog);
|
||||||
|
|
||||||
String hostTagOnOffering = offering.getHostTag();
|
String hostTagOnOffering = offering.getHostTag();
|
||||||
String hostTagOnTemplate = template.getTemplateTag();
|
String hostTagOnTemplate = template.getTemplateTag();
|
||||||
@ -203,8 +202,8 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator {
|
|||||||
|
|
||||||
|
|
||||||
if (clusterHosts.isEmpty()) {
|
if (clusterHosts.isEmpty()) {
|
||||||
logger.error("No suitable host found for vm [{}] with tags [{}].", vmProfile, hostTagOnOffering);
|
logger.warn("No suitable host found for VM [{}] with tags {} in {}.", vmProfile, hostTagOnOffering, paramAsStringToLog);
|
||||||
throw new CloudRuntimeException(String.format("No suitable host found for vm [%s].", vmProfile));
|
return null;
|
||||||
}
|
}
|
||||||
// add all hosts that we are not considering to the avoid list
|
// add all hosts that we are not considering to the avoid list
|
||||||
List<HostVO> allhostsInCluster = _hostDao.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId, null);
|
List<HostVO> allhostsInCluster = _hostDao.listAllUpAndEnabledNonHAHosts(type, clusterId, podId, dcId, null);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user