add an maintenance prepare error event#13669
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds a new CloudStack event type to record failures while preparing a host for maintenance, and extends unit tests to validate event emission and entity mapping.
Changes:
- Introduce
MAINT.PREPARE.ERRORevent type and map it toHostentity. - Emit an error ActionEvent when a host enters
PrepareForMaintenanceWithErrors. - Add/extend unit tests validating the emitted event and entity mapping.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| server/src/main/java/com/cloud/resource/ResourceManagerImpl.java | Emits a new error event when host preparation for maintenance fails due to VM/migration issues. |
| api/src/main/java/com/cloud/event/EventTypes.java | Adds the new maintenance prepare error event constant and maps it to Host. |
| server/src/test/java/com/cloud/resource/ResourceManagerImplTest.java | Verifies the new event is emitted and mapped to the correct entity class. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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); |
| 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); |
| 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))); |
| public static final String EVENT_MAINTENANCE_CANCEL = "MAINT.CANCEL"; | ||
| public static final String EVENT_MAINTENANCE_CANCEL_PRIMARY_STORAGE = "MAINT.CANCEL.PS"; | ||
| public static final String EVENT_MAINTENANCE_PREPARE = "MAINT.PREPARE"; | ||
| public static final String EVENT_MAINTENANCE_PREPARE_ERROR = "MAINT.PREPARE.ERROR"; |
|



Description
This PR...
Fixes: #13324
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?
How did you try to break this feature and the system with this change?