Skip to content

server: prevent duplicate HA works and alerts #10624

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 4.19
Choose a base branch
from
Draft
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 @@ -265,6 +265,7 @@
s_logger.warn("Scheduling restart for VMs on host " + host.getId() + "-" + host.getName());

final List<VMInstanceVO> vms = _instanceDao.listByHostId(host.getId());
final List<HaWorkVO> pendingHaWorks = _haDao.listPendingHAWorkForHost(host.getId());
final DataCenterVO dcVO = _dcDao.findById(host.getDataCenterId());

// send an email alert that the host is down
Expand Down Expand Up @@ -294,6 +295,10 @@
"Host [" + hostDesc + "] is down." + ((sb != null) ? sb.toString() : ""));

for (VMInstanceVO vm : reorderedVMList) {
VMInstanceVO finalVm = vm;
if (pendingHaWorks.stream().anyMatch(h -> h.getInstanceId() == finalVm.getId())) {
continue;

Check warning on line 300 in server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/ha/HighAvailabilityManagerImpl.java#L300

Added line #L300 was not covered by tests
}
ServiceOfferingVO vmOffering = _serviceOfferingDao.findById(vm.getServiceOfferingId());
if (_itMgr.isRootVolumeOnLocalStorage(vm.getId())) {
if (s_logger.isDebugEnabled()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,6 @@ public interface HighAvailabilityDao extends GenericDao<HaWorkVO, Long> {
List<HaWorkVO> listPendingHaWorkForVm(long vmId);

List<HaWorkVO> listPendingMigrationsForVm(long vmId);

List<HaWorkVO> listPendingHAWorkForHost(long hostId);
}
11 changes: 11 additions & 0 deletions server/src/main/java/com/cloud/ha/dao/HighAvailabilityDaoImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,15 @@

return update(vo, sc);
}

@Override
public List<HaWorkVO> listPendingHAWorkForHost(long hostId) {
SearchBuilder<HaWorkVO> sb = createSearchBuilder();
sb.and("hostId", sb.entity().getHostId(), Op.EQ);
sb.and("type", sb.entity().getWorkType(), Op.EQ);
SearchCriteria<HaWorkVO> sc = sb.create();
sc.setParameters("hostId", hostId);
sc.setParameters("type", WorkType.HA);
return listBy(sc);
}

Check warning on line 273 in server/src/main/java/com/cloud/ha/dao/HighAvailabilityDaoImpl.java

View check run for this annotation

Codecov / codecov/patch

server/src/main/java/com/cloud/ha/dao/HighAvailabilityDaoImpl.java#L265-L273

Added lines #L265 - L273 were not covered by tests
}