Skip to content

Commit 277dfb2

Browse files
author
Daan Hoogland
committed
emit error event on ErrorInMaintenance, not just ErrorInPrepareForMaintenance
1 parent 8d44b43 commit 277dfb2

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎server/src/main/java/com/cloud/resource/ResourceManagerImpl.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,9 @@ protected boolean setHostIntoErrorInMaintenance(HostVO host, List<VMInstanceVO>
17231723
_haMgr.cancelScheduledMigrations(host);
17241724
configureVncAccessForKVMHostFailedMigrations(host, errorVms);
17251725
resourceStateTransitTo(host, ResourceState.Event.UnableToMaintain, _nodeId);
1726+
ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(),
1727+
EventVO.LEVEL_ERROR, EventTypes.EVENT_MAINTENANCE_PREPARE_ERROR,
1728+
String.format("failed to put host %s into maintenance due to running VMs that could not be migrated or VMs in error state", host), host.getId(), null, 0);
17261729
return false;
17271730
}
17281731

‎server/src/test/java/com/cloud/resource/ResourceManagerImplTest.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,13 +524,17 @@ private void setupErrorVms() {
524524
}
525525

526526
private void verifyErrorInMaintenanceCalls() throws NoTransitionException {
527+
when(host.getResourceState()).thenReturn(ResourceState.PrepareForMaintenance);
527528
boolean enterMaintenanceMode = resourceManager.checkAndMaintain(hostId);
528529
verify(resourceManager).attemptMaintain(host);
529530
verify(resourceManager).setHostIntoErrorInMaintenance(eq(host), any());
530531
verify(resourceManager, never()).setHostIntoMaintenance(any());
531532
verify(resourceManager, never()).setHostIntoErrorInPrepareForMaintenance(any(), any());
532533
verify(resourceManager, never()).setHostIntoPrepareForMaintenanceAfterErrorsFixed(any());
533534
verify(resourceManager).resourceStateTransitTo(eq(host), eq(UnableToMaintain), anyLong());
535+
actionEventUtilsMocked.verify(() -> ActionEventUtils.onCompletedActionEvent(
536+
anyLong(), anyLong(), eq(EventVO.LEVEL_ERROR), eq(EventTypes.EVENT_MAINTENANCE_PREPARE_ERROR),
537+
anyString(), eq(hostId), isNull(), eq(0L)));
534538
Assert.assertFalse(enterMaintenanceMode);
535539
}
536540

0 commit comments

Comments
 (0)