Dan Kenigsberg has submitted this change and it was merged.

Change subject: DeferableContext: Change to RollbackContext for easy undoing
......................................................................


DeferableContext: Change to RollbackContext for easy undoing

We often need to perform a series of operations:
    op[0], op[1], ... op[N]
These operations may allocate files, locks, connections, and op[K] may
depend on op[K-1] 's result

Sometimes it's not feasible to create context manager for each resource,
because the number of the resource involved in a transaction can be a
variable, for example, reading from a configuration file, but there is no
way to use a variable number of the "with" statement, and
contextlib.nested is being deprecated. So we need a concise framework
to do rollback.

This patch subclass DeferableContext and proposes an idiom to do this
kind of rollback. DeferableContext re-raises the last exception, while
this patch re-raises the first exception, for the earliest exception
may be the root cause and most helpful when investigate the problem.

Change-Id: Ibc932637dd81c3becf92de34ea647c1cea136111
Signed-off-by: Zhou Zheng Sheng <[email protected]>
---
M tests/miscTests.py
M vdsm/storage/misc.py
M vdsm/storage/resourceManager.py
3 files changed, 51 insertions(+), 37 deletions(-)

Approvals:
  Dan Kenigsberg: Looks good to me, approved
  Zhou Zheng Sheng: Verified; Looks good to me, but someone else must approve


--
To view, visit http://gerrit.ovirt.org/8671
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ibc932637dd81c3becf92de34ea647c1cea136111
Gerrit-PatchSet: 8
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Zhou Zheng Sheng <[email protected]>
Gerrit-Reviewer: Dan Kenigsberg <[email protected]>
Gerrit-Reviewer: Royce Lv <[email protected]>
Gerrit-Reviewer: Ryan Harper <[email protected]>
Gerrit-Reviewer: Saggi Mizrahi <[email protected]>
Gerrit-Reviewer: ShaoHe Feng <[email protected]>
Gerrit-Reviewer: Vinzenz Feenstra <[email protected]>
Gerrit-Reviewer: Zhou Zheng Sheng <[email protected]>
Gerrit-Reviewer: oVirt Jenkins CI Server
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to