Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.4k
add a maintenance prepare error event#13669
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
base:4.20
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1726,6 +1726,9 @@ protected boolean setHostIntoErrorInPrepareForMaintenance(HostVO host, List<VMIn | ||
| logger.debug("Host {} entering in PrepareForMaintenanceWithErrors state", host); | ||
| configureVncAccessForKVMHostFailedMigrations(host, errorVms); | ||
| resourceStateTransitTo(host, ResourceState.Event.UnableToMigrate, _nodeId); | ||
| ActionEventUtils.onCompletedActionEvent(CallContext.current().getCallingUserId(), CallContext.current().getCallingAccountId(), | ||
| EventVO.LEVEL_ERROR, EventTypes.EVENT_MAINTENANCE_PREPARE_ERROR, | ||
| String.format("failed to prepare host %s for maintenance due to migration or VM state errors", host), host.getId(), null, 0); | ||
DaanHoogland marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. DaanHoogland marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| return false; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -22,6 +22,8 @@ | ||
| import com.cloud.agent.api.GetVncPortCommand; | ||
| import com.cloud.capacity.dao.CapacityDao; | ||
| import com.cloud.event.ActionEventUtils; | ||
| import com.cloud.event.EventTypes; | ||
| import com.cloud.event.EventVO; | ||
| import com.cloud.exception.InvalidParameterValueException; | ||
| import com.cloud.ha.HighAvailabilityManager; | ||
| import com.cloud.host.Host; | ||
| @@ -78,6 +80,7 @@ | ||
| import static org.mockito.ArgumentMatchers.anyLong; | ||
| import static org.mockito.ArgumentMatchers.anyString; | ||
| import static org.mockito.ArgumentMatchers.eq; | ||
| import static org.mockito.ArgumentMatchers.isNull; | ||
| import static org.mockito.Mockito.never; | ||
| import static org.mockito.Mockito.times; | ||
| import static org.mockito.Mockito.verify; | ||
| @@ -442,16 +445,26 @@ private void verifyErrorInMaintenanceCalls() throws NoTransitionException { | ||
| } | ||
| private void verifyErrorInPrepareForMaintenanceCalls() throws NoTransitionException { | ||
| when(host.getResourceState()).thenReturn(ResourceState.PrepareForMaintenance); | ||
| boolean enterMaintenanceMode = resourceManager.checkAndMaintain(hostId); | ||
| verify(resourceManager).attemptMaintain(host); | ||
| verify(resourceManager).setHostIntoErrorInPrepareForMaintenance(eq(host), any()); | ||
| verify(resourceManager, never()).setHostIntoMaintenance(any()); | ||
| verify(resourceManager, never()).setHostIntoErrorInMaintenance(any(), any()); | ||
| verify(resourceManager, never()).setHostIntoPrepareForMaintenanceAfterErrorsFixed(any()); | ||
| verify(resourceManager).resourceStateTransitTo(eq(host), eq(UnableToMigrate), anyLong()); | ||
| String expectedDescription = String.format("failed to prepare host %s for maintenance due to migration or VM state errors", host); | ||
| actionEventUtilsMocked.verify(() -> ActionEventUtils.onCompletedActionEvent( | ||
| anyLong(), anyLong(), eq(EventVO.LEVEL_ERROR), eq(EventTypes.EVENT_MAINTENANCE_PREPARE_ERROR), | ||
| eq(expectedDescription), eq(hostId), isNull(), eq(0L))); | ||
DaanHoogland marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Assert.assertFalse(enterMaintenanceMode); | ||
| } | ||
| @Test | ||
| public void testMaintenancePrepareErrorEventMapsToHostEntity() { | ||
| Assert.assertEquals(Host.class, EventTypes.getEntityClassForEvent(EventTypes.EVENT_MAINTENANCE_PREPARE_ERROR)); | ||
| } | ||
| private void verifyReturnToPrepareForMaintenanceCalls() throws NoTransitionException { | ||
| boolean enterMaintenanceMode = resourceManager.checkAndMaintain(hostId); | ||
| verify(resourceManager).attemptMaintain(host); | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.