Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
scheduler: HE policy fiters hosts with worse score than curent one
During balancing, the HE VM should not be migrated to
a host with worse score, because the ha-agent could
migrate it back. Creating a migration cycle.

If the hosted engine is in global maintenance,
this check is skipped.

Change-Id: I7c00cab775ba5180ecc860e9e7c8077fd8ef6591
Bug-Url: https://bugzilla.redhat.com/1583968
Signed-off-by: Andrej Krejcir <akrejcir@redhat.com>
  • Loading branch information
akrejcir authored and smelamud committed Nov 16, 2018
1 parent fee3524 commit 7da11d8
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
Expand Up @@ -4,6 +4,8 @@
import java.util.List;
import java.util.Map;

import javax.inject.Inject;

import org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl;
import org.ovirt.engine.core.bll.scheduling.SchedulingUnit;
import org.ovirt.engine.core.bll.scheduling.pending.PendingResourceManager;
Expand All @@ -14,6 +16,7 @@
import org.ovirt.engine.core.common.scheduling.PerHostMessages;
import org.ovirt.engine.core.common.scheduling.PolicyUnit;
import org.ovirt.engine.core.common.scheduling.PolicyUnitType;
import org.ovirt.engine.core.dao.VdsDao;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -26,6 +29,11 @@
public class HostedEngineHAClusterFilterPolicyUnit extends PolicyUnitImpl {
private static final Logger log = LoggerFactory.getLogger(HostedEngineHAClusterFilterPolicyUnit.class);

private static final int MIGRATION_THRESHOLD_SCORE = 800;

@Inject
private VdsDao vdsDao;

public HostedEngineHAClusterFilterPolicyUnit(PolicyUnit policyUnit,
PendingResourceManager pendingResourceManager) {
super(policyUnit, pendingResourceManager);
Expand All @@ -36,7 +44,7 @@ public List<VDS> filter(Cluster cluster, List<VDS> hosts, VM vm, Map<String, Str

// The filter is relevant only for Hosted Engine VM
if (vm.isHostedEngine()) {

int haScoreMin = getMinScore(vm);
List<VDS> hostsToRunOn = new ArrayList<>();
for (VDS host : hosts) {
if (!host.isHostedEngineConfigured()) {
Expand All @@ -46,21 +54,42 @@ public List<VDS> filter(Cluster cluster, List<VDS> hosts, VM vm, Map<String, Str
}

int haScore = host.getHighlyAvailableScore();
if (haScore > 0) {
hostsToRunOn.add(host);
log.debug("Host '{}' wasn't filtered out as it has a score of {}",
host.getName(),
haScore);
} else {
if (haScore <= 0) {
log.debug("Host '{}' was filtered out as it doesn't have a positive score (the score is {})",
host.getName(), haScore);
messages.addMessage(host.getId(), EngineMessage.VAR__DETAIL__HE_HOST_NOT_POSITIVE_SCORE.name());
continue;
}

if (haScore <= haScoreMin) {
log.debug("Host '{}' was filtered out as it has much lower score than the current host (the score is {}, must be more than {})",
host.getName(), haScore, haScoreMin);
messages.addMessage(host.getId(), EngineMessage.VAR__DETAIL__HE_HOST_LOW_SCORE.name());
continue;
}

hostsToRunOn.add(host);
log.debug("Host '{}' wasn't filtered out as it has a score of {}",
host.getName(),
haScore);
}

return hostsToRunOn;
} else {
return hosts;
}
}

private int getMinScore(VM vm) {
if (vm.getRunOnVds() == null) {
return 0;
}

VDS currentHost = vdsDao.get(vm.getRunOnVds());
if (currentHost.getHighlyAvailableGlobalMaintenance()) {
return 0;
}

return Math.max(currentHost.getHighlyAvailableScore() - MIGRATION_THRESHOLD_SCORE, 0);
}
}
Expand Up @@ -1473,6 +1473,7 @@ public enum EngineMessage {
VAR__DETAIL__NUMA_PINNING_FAILED,
VAR__DETAIL__NOT_HE_HOST,
VAR__DETAIL__HE_HOST_NOT_POSITIVE_SCORE,
VAR__DETAIL__HE_HOST_LOW_SCORE,
VAR__DETAIL__NOT_ENOUGH_HE_SPARES,
VAR__DETAIL__SAME_HOST,
VAR__DETAIL__HOSTDEV_DISABLED,
Expand Down
Expand Up @@ -2637,6 +2637,8 @@ public interface AppErrors extends ConstantsWithLookup {

String VAR__DETAIL__HE_HOST_NOT_POSITIVE_SCORE();

String VAR__DETAIL__HE_HOST_LOW_SCORE();

String VAR__DETAIL__NOT_ENOUGH_HE_SPARES();

String VAR__DETAIL__SAME_HOST();
Expand Down
Expand Up @@ -1205,6 +1205,7 @@ VAR__DETAIL__NOT_ENOUGH_HUGE_PAGES=$detailMessage there are not enough free huge
VAR__DETAIL__NOT_ENOUGH_MEMORY=$detailMessage its available memory is too low (${availableMem} MB) to run the VM
VAR__DETAIL__NOT_HE_HOST=$detailMessage it is not a Hosted Engine host.
VAR__DETAIL__HE_HOST_NOT_POSITIVE_SCORE=$detailMessage it doesn't have a positive Hosted Engine score.
VAR__DETAIL__HE_HOST_LOW_SCORE=$detailMessage it has much lower Hosted Engine score than the current host.
VAR__DETAIL__NUMA_NOT_SUPPORTED=$detailMessage does not support NUMA
VAR__DETAIL__NOT_MEMORY_PINNED_NUMA=$detailMessage cannot accommodate memory of VM's pinned virtual NUMA nodes within host's physical NUMA nodes.
VAR__DETAIL__NO_SUITABLE_VF=$detailMessage there are no free virtual functions which are suitable for virtual nic(s) ${vnicNames}. A virtual function is considered as suitable if the VF's configuration of its physical function contains the virtual nic's network/network label
Expand Down

0 comments on commit 7da11d8

Please sign in to comment.