Liron Ar has uploaded a new change for review. Change subject: [wip] core: move image group command ......................................................................
[wip] core: move image group command Added MoveImageGroupCommand - making MoveOrCopyImageGroup command to be used for copy only (CopyImageGroup). Reasons for that change: 1. When moving a image and attempting to delete with wipe - the operation will be faster rather then waiting to the wipe to complete. 2. Moving toward lowering the SPM involvement in the copy/move process. 3. The engine will be able to tell on what part of the "move" operation an error occured. 4. Move operation on vdsm should be deprecated. Known issues and reasoning: * The whole operations can be slower for moving image groups without wipe as the delete part is quick (and now we will have two vdsm calls rather then one) - this issue is known and accepted as part of this RFE. * The code hasn't been optimized for moving few 'related' disks at once as MoveVm/MoveVmTemplate are deprecated. Change-Id: Id9068d66df3986c9bb16b266bb5bef396964a706 Bug-Url: https://bugzilla.redhat.com/753549 Signed-off-by: Liron Aravot <[email protected]> --- A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveImageGroupCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.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/action/VdcActionType.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties 9 files changed, 90 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/42/13042/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveImageGroupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveImageGroupCommand.java new file mode 100644 index 0000000..a1e6a1e --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveImageGroupCommand.java @@ -0,0 +1,60 @@ +package org.ovirt.engine.core.bll; + +import org.ovirt.engine.core.bll.job.ExecutionHandler; +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.MoveOrCopyImageGroupParameters; +import org.ovirt.engine.core.common.action.RemoveImageParameters; +import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.action.VdcReturnValueBase; +import org.ovirt.engine.core.common.businessentities.ImageStorageDomainMapId; +import org.ovirt.engine.core.common.businessentities.PerformOperationStage; +import org.ovirt.engine.core.compat.TransactionScopeOption; +import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector; +import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase; +import org.ovirt.engine.core.utils.transaction.TransactionMethod; +import org.ovirt.engine.core.utils.transaction.TransactionSupport; + +@SuppressWarnings("serial") +@InternalCommandAttribute +public class MoveImageGroupCommand<T extends MoveOrCopyImageGroupParameters> extends MoveOrCopyImageGroupCommand<T> { + public MoveImageGroupCommand(T parameters) { + super(parameters); + } + + private void removeImage() { + RemoveImageParameters removeImageParams = + new RemoveImageParameters(getParameters().getImageId()); + removeImageParams.setStorageDomainId(getParameters().getSourceDomainId().getValue()); + removeImageParams.setEntityId(new ImageStorageDomainMapId(getParameters().getImageId(), getParameters().getSourceDomainId().getValue())); + removeImageParams.setParentCommand(VdcActionType.RemoveImage); + removeImageParams.setPerformDbOperationsStage(PerformOperationStage.NEVER); + VdcReturnValueBase returnValue = Backend.getInstance().runInternalAction( + VdcActionType.RemoveImage, + removeImageParams, + ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); + if (returnValue.getSucceeded()) { + startPollingAsyncTasks(returnValue.getInternalTaskIdList()); + } else { + addAuditLogOnRemoveFailue(); + } + } + + @Override + protected void endSuccessfully() { + TransactionSupport.executeInScope(TransactionScopeOption.Suppress, new TransactionMethod<Void>() { + @Override + public Void runInTransaction() { + removeImage(); + return null; + } + }); + super.endSuccessfully(); + } + + private void addAuditLogOnRemoveFailue() { + AuditLogableBase logable = new AuditLogableBase(); + logable.addCustomValue("DiskAlias", getDiskImage().getDiskAlias()); + logable.addCustomValue("StorageDomainName", getStorageDomain().getStorageName()); + AuditLogDirector.log(logable, AuditLogType.MOVE_IMAGE_GROUP_FAILED_TO_DELETE_SRC_IMAGE); + } +} diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java index 507b8e8..60066e0 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyDiskCommand.java @@ -260,11 +260,18 @@ return getDbFacade().getVmDeviceDao(); } + protected VdcActionType getImagesActionType() { + if (getParameters().getOperation() == ImageOperation.Move) { + return VdcActionType.MoveImageGroup; + } + return VdcActionType.MoveOrCopyImageGroup; + } + @Override protected void executeCommand() { overrideParameters(); VdcReturnValueBase vdcRetValue = getBackend().runInternalAction( - VdcActionType.MoveOrCopyImageGroup, + getImagesActionType(), getParameters(), ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); if (!vdcRetValue.getSucceeded()) { @@ -276,6 +283,21 @@ } } + private void endCommandActions() { + getBackend().EndAction(getImagesActionType(), getParameters()); + setSucceeded(true); + } + + @Override + protected void endSuccessfully() { + endCommandActions(); + } + + @Override + protected void endWithFailure() { + endCommandActions(); + } + @Override public AuditLogType getAuditLogTypeValue() { switch (getActionState()) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java index 5fa3e44..35b6364 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyImageGroupCommand.java @@ -93,7 +93,7 @@ .getId(), getParameters().getStorageDomainId(), getParameters().getContainerId(), - getParameters().getOperation(), + ImageOperation.Copy, isWipeAfterDelete(), getParameters().getForceOverride(), getStoragePool() diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java index 280b375..51518ca 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveOrCopyTemplateCommand.java @@ -179,7 +179,7 @@ p.setSourceDomainId(imageFromSourceDomainMap.get(disk.getId()).getStorageIds().get(0)); p.setParentParameters(getParameters()); VdcReturnValueBase vdcRetValue = getBackend().runInternalAction( - VdcActionType.MoveOrCopyImageGroup, + getImagesActionType(), p, ExecutionHandler.createDefaultContexForTasks(getExecutionContext())); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java index a32642d..8aff944 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MoveVmCommand.java @@ -227,6 +227,6 @@ @Override protected VdcActionType getImagesActionType() { - return VdcActionType.MoveOrCopyImageGroup; + return VdcActionType.MoveImageGroup; } } 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 111d400..a9237b1 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 @@ -175,6 +175,7 @@ USER_FAILED_ADD_DISK(2023), // Used only from SQL script, therefor should not have severity & message USER_RUN_UNLOCK_ENTITY_SCRIPT(2024), + MOVE_IMAGE_GROUP_FAILED_TO_DELETE_SRC_IMAGE(2025), // Quota audit logs USER_ADD_QUOTA(3000), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index be9b22b..5cf6de5 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -115,6 +115,7 @@ RemoveSnapshotSingleDisk(227, QuotaDependency.STORAGE), CreateCloneOfTemplate(229, QuotaDependency.STORAGE), RemoveDisk(230, QuotaDependency.STORAGE), + MoveImageGroup(231, QuotaDependency.STORAGE), // VmPoolCommands AddVmPool(301, QuotaDependency.NONE), AddVmPoolWithVms(304, ActionGroup.CREATE_VM_POOL, QuotaDependency.BOTH), diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java index 8ce4043..3bb644b 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java @@ -499,6 +499,7 @@ severities.put(AuditLogType.USER_ADD_DISK_FINISHED_SUCCESS, AuditLogSeverity.NORMAL); severities.put(AuditLogType.USER_ADD_DISK_FINISHED_FAILURE, AuditLogSeverity.ERROR); severities.put(AuditLogType.USER_FAILED_ADD_DISK, AuditLogSeverity.ERROR); + severities.put(AuditLogType.MOVE_IMAGE_GROUP_FAILED_TO_DELETE_SRC_IMAGE, AuditLogSeverity.WARNING); severities.put(AuditLogType.USER_REMOVE_DISK_FROM_VM, AuditLogSeverity.NORMAL); severities.put(AuditLogType.USER_FAILED_REMOVE_DISK_FROM_VM, AuditLogSeverity.ERROR); severities.put(AuditLogType.USER_MOVED_VM, AuditLogSeverity.NORMAL); 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 997bd6f..927d007 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -76,6 +76,7 @@ USER_ADD_DISK_FINISHED_SUCCESS=The disk '${DiskAlias}' was successfully added. USER_ADD_DISK_FINISHED_FAILURE=Operation Add-Disk failed to complete. USER_FAILED_ADD_DISK=Operation Add-Disk failed (User: ${UserName}). +MOVE_IMAGE_GROUP_FAILED_TO_DELETE_SRC_IMAGE=Possible failure when deleting ${DiskAlias} from the source Storage Domain ${StorageDomainName} during the move operation. the Storage Domain may be manually cleaned-up from possible leftovers. USER_REMOVE_DISK_FROM_VM=Disk was removed from VM ${VmName} by ${UserName}. USER_FAILED_REMOVE_DISK_FROM_VM=Failed to remove Disk from VM ${VmName} (User: ${UserName}). USER_UPDATE_VM_DISK=VM ${VmName} ${DiskAlias} disk was updated by ${UserName}. -- To view, visit http://gerrit.ovirt.org/13042 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id9068d66df3986c9bb16b266bb5bef396964a706 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liron Ar <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
