Add more details to VM deployment failure alert messages (#12939)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Erik Böck <89930804+erikbocks@users.noreply.github.com>
This commit is contained in:
GaOrtiga 2026-07-04 11:26:08 -03:00 committed by GitHub
parent 2032bbd7f6
commit b7d4df0a11
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 6 deletions

View File

@ -160,6 +160,7 @@ import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.logging.log4j.ThreadContext;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@ -2775,22 +2776,29 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
if (vm != null) {
if (vm.getState().equals(State.Stopped)) {
HostVO host = _hostDao.findById(hostId);
logger.debug("Destroying vm {} as it failed to create on Host: {} with id {}", vm, host, hostId);
logger.debug("Destroying VM [{}] as it was unable to be deployed on Host: {}.", vm, host);
try {
_itMgr.stateTransitTo(vm, VirtualMachine.Event.OperationFailedToError, null);
} catch (NoTransitionException e1) {
logger.warn(e1.getMessage());
logger.error("Error when transitioning state of [{}].", vm, e1);
}
// destroy associated volumes for vm in error state
// get all volumes in non destroyed state
logger.debug("Destroying associated volumes of [{}] as it was unable to be deployed.", vm);
List<VolumeVO> volumesForThisVm = _volsDao.findUsableVolumesForInstance(vm.getId());
for (VolumeVO volume : volumesForThisVm) {
if (volume.getState() != Volume.State.Destroy) {
logger.trace("Destroying volume [{}] as its VM was unable to be deployed.", volume);
volumeMgr.destroyVolume(volume);
}
}
String msg = String.format("Failed to deploy Vm %s, on Host %s with Id: %d", vm, host, hostId);
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), msg, msg);
String subject = String.format("Failed to deploy Instance [ID: %s]", vm.getUuid());
String body = String.format("Failed to deploy [%s]%s. To troubleshoot, please check the logs with [logid:%s].",
vm,
hostId != null ? String.format(" on host [%s]", hostId) : "",
ThreadContext.get("logcontextid"));
_alertMgr.sendAlert(AlertManager.AlertType.ALERT_TYPE_USERVM, vm.getDataCenterId(), vm.getPodIdToDeployIn(), subject, body);
// Get serviceOffering and template for Virtual Machine
ServiceOfferingVO offering = serviceOfferingDao.findById(vm.getId(), vm.getServiceOfferingId());
@ -2802,8 +2810,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
}
}
private class VmIpFetchTask extends ManagedContextRunnable {
@Override