Arik Hadas has uploaded a new change for review. Change subject: core: persistent in-memory lock for remove template ......................................................................
core: persistent in-memory lock for remove template This patch replace the existing exclusive lock of the remove template command with a persistent (isReleaseAtEndOfExecute = false) exclusive lock. there's also a new customized error message attached to the modified lock. Note that the lock of the template in DB remains so all the places that check whether the template is locked according to the status in the DB will still get valid result. Change-Id: I6cec457a44e4059e21c344acdaf8d17c9d26c686 Signed-off-by: Arik Hadas <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 6 files changed, 16 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/13100/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java index da0c373..7cbc085 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RemoveVmTemplateCommand.java @@ -22,6 +22,7 @@ import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VmTemplate; +import org.ovirt.engine.core.common.locks.LockingGroup; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.VdcBllMessages; @@ -32,7 +33,7 @@ @DisableInPrepareMode @NonTransactiveCommandAttribute(forceCompensation = true) -@LockIdNameAttribute +@LockIdNameAttribute(isReleaseAtEndOfExecute = false) public class RemoveVmTemplateCommand<T extends VmTemplateParametersBase> extends VmTemplateCommand<T> implements QuotaStorageDependent { @@ -190,7 +191,6 @@ protected void executeCommand() { // Set VM to lock status immediately, for reducing race condition. VmTemplateHandler.lockVmTemplateInTransaction(getVmTemplateId(), getCompensationContext()); - freeLock(); // if for some reason template doesn't have images, remove it now and not in end action final boolean hasImages = imageTemplates.size() > 0; if (hasImages) { @@ -212,7 +212,13 @@ @Override protected Map<String, Pair<String, String>> getExclusiveLocks() { return Collections.singletonMap(getVmTemplateId().toString(), - LockMessagesMatchUtil.TEMPLATE); + LockMessagesMatchUtil.makeLockingPair(LockingGroup.TEMPLATE, getTemplateExclusiveLockMessage())); + } + + private String getTemplateExclusiveLockMessage() { + return new StringBuilder(VdcBllMessages.ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_REMOVED.name()) + .append(String.format("$TemplateName %1$s", getVmTemplate().getName())) + .toString(); } private void RemoveTemplateFromDb() { diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java index 716df16..3e3fcc6 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java @@ -533,6 +533,7 @@ ACTION_TYPE_FAILED_TEMPLATE_IS_USED_FOR_CREATE_VM, ACTION_TYPE_FAILED_DISK_IS_USED_FOR_CREATE_VM, ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED, + ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_REMOVED, VM_OR_TEMPLATE_ILLEGAL_PRIORITY_VALUE, NETWORK_ADDR_IN_STATIC_IP_BAD_FORMAT, diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index b651a71..8e55c2f 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -500,6 +500,7 @@ ACTION_TYPE_FAILED_TEMPLATE_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This template is currently in use to create VM ${VmName}. ACTION_TYPE_FAILED_DISK_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This disk is currently in use to create VM ${VmName}. ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED=Cannot ${action} ${type}. Disk ${DiskName} is being removed. +ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_REMOVED=Cannot ${action} ${type}. Template ${TemplateName} is being removed. NETWORK_BOND_HAVE_ATTACHED_VLANS=Bond attached to vlan, remove bonds vlan first NETWORK_INTERFACE_CONNECT_TO_VLAN=Cannot attach non vlan network to vlan interface NETWORK_CANNOT_REMOVE_NETWORK_IN_USE_BY_VM=Cannot remove network '${NetworkName}', it's in use by a VM diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index 85a5706..42decfc 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -1348,6 +1348,9 @@ @DefaultStringValue("Cannot ${action} ${type}. Disk ${DiskName} is being removed.") String ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED(); + @DefaultStringValue("Cannot ${action} ${type}. Template ${TemplateName} is being removed.") + String ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_REMOVED(); + @DefaultStringValue("Bond attached to vlan, remove bonds vlan first") String NETWORK_BOND_HAVE_ATTACHED_VLANS(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index ed7071d..4e0b2e1 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -497,6 +497,7 @@ ACTION_TYPE_FAILED_TEMPLATE_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This template is currently in use to create VM ${VmName}. ACTION_TYPE_FAILED_DISK_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This disk is currently in use to create VM ${VmName}. ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED=Cannot ${action} ${type}. Disk ${DiskName} is being removed. +ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_REMOVED=Cannot ${action} ${type}. Template ${TemplateName} is being removed. NETWORK_BOND_HAVE_ATTACHED_VLANS=Bond attached to vlan, remove bonds vlan first NETWORK_INTERFACE_CONNECT_TO_VLAN=Cannot attach non vlan network to vlan interface NETWORK_CANNOT_REMOVE_NETWORK_IN_USE_BY_VM=Cannot remove network '${NetworkName}', it's in use by a VM diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index a3c6040..954ecfb 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -494,6 +494,7 @@ ACTION_TYPE_FAILED_TEMPLATE_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This template is currently in use to create VM ${VmName}. ACTION_TYPE_FAILED_DISK_IS_USED_FOR_CREATE_VM=Cannot ${action} ${type}. This disk is currently in use to create VM ${VmName}. ACTION_TYPE_FAILED_DISK_IS_BEING_REMOVED=Cannot ${action} ${type}. Disk ${DiskName} is being removed. +ACTION_TYPE_FAILED_TEMPLATE_IS_BEING_REMOVED=Cannot ${action} ${type}. Template ${TemplateName} is being removed. NETWORK_BOND_HAVE_ATTACHED_VLANS=Bond attached to vlan, remove bonds vlan first NETWORK_INTERFACE_CONNECT_TO_VLAN=Cannot attach non vlan network to vlan interface NETWORK_CANNOT_REMOVE_NETWORK_IN_USE_BY_VM=Cannot remove network '${NetworkName}', it's in use by a VM -- To view, visit http://gerrit.ovirt.org/13100 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6cec457a44e4059e21c344acdaf8d17c9d26c686 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
