diskimage-builder/diskimage_builder/block_device/tests/config/rollback.yaml
Ian Wienand 1d1e4ccb3e Move rollback into NodeBase object
Currently we pass a reference to a global "rollback" list to create()
to keep rollback functions.  Other nodes don't need to know about
global rollback state, and by passing by reference we're giving them
the chance to mess it up for everyone else.

Add a "add_rollback()" function in NodeBase for create() calls to
register rollback calls within themselves.  As they hit rollback
points they can add a new entry.  lambda v arguments is much of a
muchness -- but this is similar to the standard atexit() call so with
go with that pattern.  A new "rollback()" call is added that the
driver will invoke on each node as it works its way backwards in case
of failure.

On error, nodes will have rollback() called in reverse order (which
then calls registered rollbacks in reverse order).

A unit test is added to test rollback behaviour

Change-Id: I65214e72c7ef607dd08f750a6d32a0b10fe97ac3
2017-06-08 17:14:20 +10:00

29 lines
No EOL
552 B
YAML

- test_a:
name: test_node_a
rollback_one_arg: down
rollback_two_arg: you
- test_b:
base: test_node_a
name: test_node_b
rollback_one_arg: let
rollback_two_arg: gonna
- test_a:
base: test_node_b
name: test_node_aa
rollback_one_arg: never
rollback_two_arg: up
- test_b:
base: test_node_aa
name: test_node_bb
rollback_one_arg: you
rollback_two_arg: give
- test_a:
base: test_node_bb
name: test_node_aaa
rollback_one_arg: gonna
rollback_two_arg: never
trigger_rollback: yes