Sahina Bose has uploaded a new change for review. Change subject: engine: Log detection of orphan gluster tasks ......................................................................
engine: Log detection of orphan gluster tasks When tasks no longer exist in gluster CLI, these are marked as Unknown and ended. Added audit log for these. Change-Id: Ia9cc4658dc4ed5700ce93463f4480d65e7d71c12 Bug-Url: https://bugzilla.redhat.com/1040973 Signed-off-by: Sahina Bose <sab...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/tasks/GlusterTaskUtils.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties A packaging/dbscripts/upgrade/03_04_0240_gluster_async_tasks_stop_fromcli_event_map.sql 7 files changed, 48 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/22364/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java index 5df229b..d60f4aa 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJob.java @@ -270,6 +270,22 @@ getGlusterLogUtil().logAuditMessage(cluster.getId(), vol, null, logType, values); } + private void logTaskStoppedFromCLI(Step step, GlusterVolumeEntity vol) { + AuditLogType logType; + switch (step.getStepType()) { + case REBALANCING_VOLUME: + logType = AuditLogType.GLUSTER_VOLUME_REBALANCE_STOP_DETECTED_FROM_CLI; + break; + case REMOVING_BRICKS: + logType = AuditLogType.STOP_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI; + break; + default: + logType = AuditLogType.UNASSIGNED; + break; + } + getGlusterLogUtil().logAuditMessage(vol.getClusterId(), vol, null, logType, null); + } + protected GlusterAuditLogUtil getGlusterLogUtil() { return GlusterAuditLogUtil.getInstance(); } @@ -326,7 +342,17 @@ for (Step step: steps) { step.markStepEnded(JobExecutionStatus.UNKNOWN); step.setStatus(JobExecutionStatus.UNKNOWN); + + Map<String, String> values = new HashMap<String, String>(); + values.put(GlusterConstants.CLUSTER, vol == null ? "" :vol.getVdsGroupName()); + values.put(GlusterConstants.VOLUME, vol == null ? "" : vol.getName()); + values.put(GlusterConstants.JOB_STATUS, JobExecutionStatus.UNKNOWN.toString()); + values.put(GlusterConstants.JOB_INFO, " "); + step.setDescription(ExecutionMessageDirector.resolveStepMessage(step.getStepType(), values)); getGlusterTaskUtils().endStepJob(step); + if (vol != null) { + logTaskStoppedFromCLI(step, vol); + } } getGlusterTaskUtils().releaseVolumeLock(taskId); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/tasks/GlusterTaskUtils.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/tasks/GlusterTaskUtils.java index 8e3de2b..db91d5e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/tasks/GlusterTaskUtils.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/tasks/GlusterTaskUtils.java @@ -14,8 +14,6 @@ import org.ovirt.engine.core.bll.job.JobRepositoryFactory; import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask; -import org.ovirt.engine.core.common.utils.SizeConverter; -import org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit; import org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters; import org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType; import org.ovirt.engine.core.common.businessentities.VDSGroup; @@ -30,6 +28,8 @@ import org.ovirt.engine.core.common.job.StepEnum; import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.core.common.utils.SizeConverter; +import org.ovirt.engine.core.common.utils.SizeConverter.SizeUnit; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dal.dbbroker.auditloghandling.gluster.GlusterAuditLogUtil; @@ -232,9 +232,11 @@ return; } } - if (JobExecutionStatus.ABORTED == task.getStatus() || JobExecutionStatus.FINISHED == task.getStatus() || JobExecutionStatus.FAILED == task.getStatus()){ + if (JobExecutionStatus.ABORTED == task.getStatus() || JobExecutionStatus.FINISHED == task.getStatus() + || JobExecutionStatus.FAILED == task.getStatus() || JobExecutionStatus.UNKNOWN == task.getStatus()){ if(oldStatus != task.getStatus()){ - logMessage(cluster.getId(), volume , taskTypeStrMap.get(task.getType()), task.getStatus().name().toLowerCase(), taskTypeAuditMsg.get(task.getType())); + logMessage(cluster.getId(), volume , taskTypeStrMap.get(task.getType()), + task.getStatus().name().toLowerCase(), taskTypeAuditMsg.get(task.getType())); } } } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java index 4107eda..27faa2f 100755 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/gluster/GlusterTasksSyncJobTest.java @@ -32,6 +32,7 @@ import org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask; import org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskParameters; import org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType; +import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; @@ -88,6 +89,7 @@ private GlusterTaskUtils taskUtils; + @Mock private GlusterAuditLogUtil logUtil; private GlusterTasksSyncJob tasksSyncJob; @@ -104,7 +106,6 @@ public void init() { MockitoAnnotations.initMocks(this); tasksSyncJob = Mockito.spy(GlusterTasksSyncJob.getInstance()); - logUtil = Mockito.spy(GlusterAuditLogUtil.getInstance()); taskUtils = Mockito.spy(GlusterTaskUtils.getInstance()); doNothing().when(logUtil).logClusterMessage(any(Guid.class), any(AuditLogType.class)); @@ -118,10 +119,16 @@ doReturn(jobRepository).when(taskUtils).getJobRepository(); doReturn(backend).when(tasksSyncJob).getBackend(); doReturn(taskUtils).when(tasksSyncJob).getGlusterTaskUtils(); + doReturn(logUtil).when(tasksSyncJob).getGlusterLogUtil(); doNothing().when(taskUtils).releaseLock(any(Guid.class)); doNothing().when(taskUtils).endStepJob(any(Step.class)); doReturn(null).when(provider).getMonitoredTaskIDsInDB(); doNothing().when(taskUtils).logEventMessage(any(GlusterAsyncTask.class), any(JobExecutionStatus.class), any(VDSGroup.class)); + doNothing().when(logUtil).logAuditMessage(any(Guid.class), + any(GlusterVolumeEntity.class), + any(VDS.class), + any(AuditLogType.class), + any(HashMap.class)); } @Test diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index 51faf1c..095c7ca 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -310,6 +310,8 @@ GLUSTER_HOST_UUID_ALREADY_EXISTS(4089), GLUSTER_VOLUME_REBALANCE_START_DETECTED_FROM_CLI(4089), START_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI(4090), + GLUSTER_VOLUME_REBALANCE_STOP_DETECTED_FROM_CLI(4091), + STOP_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI(4092), USER_FORCE_SELECTED_SPM(159), USER_VDS_RESTART(41), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java index 33f2c70..3f560b3 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/VdcEventNotificationUtils.java @@ -85,6 +85,8 @@ AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_REPLACE_BRICK_START_FAILED); AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_REBALANCE_START_DETECTED_FROM_CLI); AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.START_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.GLUSTER_VOLUME_REBALANCE_STOP_DETECTED_FROM_CLI); + AddEventNotificationEntry(EventNotificationEntity.GlusterVolume, AuditLogType.STOP_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI); AddEventNotificationEntry(EventNotificationEntity.Host, AuditLogType.GLUSTER_SERVER_ADD_FAILED); AddEventNotificationEntry(EventNotificationEntity.Host, AuditLogType.GLUSTER_SERVER_REMOVE); AddEventNotificationEntry(EventNotificationEntity.Host, AuditLogType.GLUSTER_SERVER_REMOVE_FAILED); diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties index dd92ebc..8fbd80e 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -632,6 +632,8 @@ GLUSTER_SERVER_ADD_FAILED=Failed to add gluster server ${VdsName} into Cluster ${VdsGroupName}. GLUSTER_VOLUME_REBALANCE_START_DETECTED_FROM_CLI=Detected start of rebalance on volume ${glusterVolumeName} of Cluster ${VdsGroupName} from CLI. START_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI=Detected start of brick removal for bricks ${brick} on volume ${glusterVolumeName} of Cluster ${VdsGroupName} from CLI. +GLUSTER_VOLUME_REBALANCE_STOP_DETECTED_FROM_CLI=Could not find information for rebalance on volume ${glusterVolumeName} of Cluster ${VdsGroupName} from CLI. Marking it as unknown. +STOP_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI=Could not find information for remove brick on volume ${glusterVolumeName} of Cluster ${VdsGroupName} from CLI. Marking it as unknown. GLUSTER_SERVER_REMOVE=Gluster server ${VdsName} removed from Cluster ${VdsGroupName}. GLUSTER_SERVER_REMOVE_FAILED=Failed to remove gluster server ${VdsName} from Cluster ${VdsGroupName}. GLUSTER_SERVERS_LIST_FAILED=Failed to fetch gluster peer list from server ${VdsName} on Cluster ${VdsGroupName}. diff --git a/packaging/dbscripts/upgrade/03_04_0240_gluster_async_tasks_stop_fromcli_event_map.sql b/packaging/dbscripts/upgrade/03_04_0240_gluster_async_tasks_stop_fromcli_event_map.sql new file mode 100644 index 0000000..898a4fb --- /dev/null +++ b/packaging/dbscripts/upgrade/03_04_0240_gluster_async_tasks_stop_fromcli_event_map.sql @@ -0,0 +1,2 @@ +insert into event_map(event_up_name, event_down_name) values('GLUSTER_VOLUME_REBALANCE_STOP_DETECTED_FROM_CLI', 'UNASSIGNED'); +insert into event_map(event_up_name, event_down_name) values('STOP_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI', 'UNASSIGNED'); -- To view, visit http://gerrit.ovirt.org/22364 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia9cc4658dc4ed5700ce93463f4480d65e7d71c12 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sahina Bose <sab...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches