Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4936,8 +4936,9 @@ private void handlePowerOffReportWithNoPendingJobsOnVM(final VMInstanceVO vm) {
EventTypes.EVENT_VM_STOP, "Out of band VM power off", vm.getId(), getApiCommandResourceTypeForVm(vm).toString());
case Migrating:
logger.info("VM {} is at {} and we received a {} report while there is no pending jobs on it"
, vm, vm.getState(), vm.getPowerState());
if((HighAvailabilityManager.ForceHA.value() || vm.isHaEnabled()) && vm.getState() == State.Running
, vm.getInstanceName(), vm.getState(), vm.getPowerState());
Pair<Long, Long> clusterHostPair = findClusterAndHostIdForVm(vm, false);
if ((HighAvailabilityManager.ForceHA.valueIn(clusterHostPair.first()) || vm.isHaEnabled()) && vm.getState() == State.Running
&& HaVmRestartHostUp.value()
&& vm.getHypervisorType() != HypervisorType.VMware
&& vm.getHypervisorType() != HypervisorType.Hyperv) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import javax.inject.Inject;
import javax.naming.ConfigurationException;

import com.cloud.utils.Pair;
import org.apache.cloudstack.api.ApiCommandResourceType;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.engine.orchestration.service.VolumeOrchestrationService;
Expand Down Expand Up @@ -479,7 +480,9 @@ public void scheduleRestart(VMInstanceVO vm, boolean investigate, ReasonType rea
alertType = AlertManager.AlertType.ALERT_TYPE_SSVM;
}

if (!(ForceHA.value() || vm.isHaEnabled())) {

Pair<Long, Long> clusterHostPair = _itMgr.findClusterAndHostIdForVm(vm, false);
if (!(ForceHA.valueIn(clusterHostPair.first()) || vm.isHaEnabled())) {
String hostDesc = "id:" + vm.getHostId() + ", availability zone id:" + vm.getDataCenterId() + ", pod id:" + vm.getPodIdToDeployIn();
_alertMgr.sendAlert(alertType, vm.getDataCenterId(), vm.getPodIdToDeployIn(), "VM (name: " + vm.getHostName() + ", id: " + vm.getId() +
") stopped unexpectedly on host " + hostDesc, "Virtual Machine " + vm.getHostName() + " (id: " + vm.getId() + ") running on host [" + vm.getHostId() +
Expand Down Expand Up @@ -722,7 +725,7 @@ protected Long restart(final HaWorkVO work) {

vm = _itMgr.findById(vm.getId());

if (!ForceHA.value() && !vm.isHaEnabled()) {
if (!ForceHA.valueIn(host.getClusterId()) && !vm.isHaEnabled()) {
if (logger.isDebugEnabled()) {
logger.debug("VM is not HA enabled so we're done.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,6 @@ public void doInTransactionWithoutResult(final TransactionStatus status) {

host.setGuid(null);
final Long clusterId = host.getClusterId();
host.setClusterId(null);
_hostDao.update(host.getId(), host);

Host hostRemoved = _hostDao.findById(hostId);
Expand Down Expand Up @@ -2852,7 +2851,7 @@ public void deleteRoutingHost(final HostVO host, final boolean isForced, final b
logger.debug("Cannot transmit host {} to Disabled state", host, e);
}
for (final VMInstanceVO vm : vms) {
if ((!HighAvailabilityManager.ForceHA.value() && !vm.isHaEnabled()) || vm.getState() == State.Stopping) {
if ((!HighAvailabilityManager.ForceHA.valueIn(host.getClusterId()) && !vm.isHaEnabled()) || vm.getState() == State.Stopping) {
logger.debug(String.format("Stopping %s as a part of hostDelete for %s",vm, host));
try {
_haMgr.scheduleStop(vm, host.getId(), WorkType.Stop);
Expand All @@ -2861,7 +2860,7 @@ public void deleteRoutingHost(final HostVO host, final boolean isForced, final b
logger.debug(errorMsg, e);
throw new UnableDeleteHostException(errorMsg + "," + e.getMessage());
}
} else if ((HighAvailabilityManager.ForceHA.value() || vm.isHaEnabled()) && (vm.getState() == State.Running || vm.getState() == State.Starting)) {
} else if ((HighAvailabilityManager.ForceHA.valueIn(host.getClusterId()) || vm.isHaEnabled()) && (vm.getState() == State.Running || vm.getState() == State.Starting)) {
logger.debug(String.format("Scheduling restart for %s, state: %s on host: %s.", vm, vm.getState(), host));
_haMgr.scheduleRestart(vm, false);
}
Expand Down
Loading