Yair Zaslavsky has posted comments on this change. Change subject: Moving provision call into transaction ......................................................................
Patch Set 1: Code-Review-1 (1 comment) http://gerrit.ovirt.org/#/c/34860/1/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java: Line 115: log.error("Failed to provision: Host group cannot be empty"); Line 116: throw new VdcBLLException(VdcBllErrors.PROVIDER_PROVISION_MISSING_HOSTGROUP); Line 117: } Line 118: Line 119: TransactionSupport.executeInNewTransaction(new TransactionMethod<Void>() { Please don't - Golden rule - have transactions as short as possible. No need to run provisioning in transaction. Compensation creates a context of "logging persistency changes" , similar to a transaction log. The fact the command is annoted with forceCompensation=true means that it has compensation. So all you need to do is make your foreman call (FYI - this is true also with calls to VDSM), and have the db related stuff before the call in a transaction.. the exception in the provision will propagate , and there is a handling in CommandBase to revert all the data that was kept on the compensation context. I hope it's more clear now. Line 120: @Override Line 121: public Void runInTransaction() { Line 122: // Adding vdsStatic first to have vdsId before calling to provision Line 123: AddVdsStaticToDb(); -- To view, visit http://gerrit.ovirt.org/34860 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I635d87d09eec0dd052d86329d2b6b7f0a1658836 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim <[email protected]> Gerrit-Reviewer: Yair Zaslavsky <[email protected]> Gerrit-Reviewer: [email protected] Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
