We need to implement some sort of rollback in our StateMachines, but I cannot figure out how we would implement that, without going insane.,
Let’s say I have two StateMachines
ProvisionMyService prov1 prov2 prov3 RetireMyService retire3 retire2 retire1
The steps are written that
retire3 undos whatever
prov2 and so on.
Now the Code in
prov2 recognizes, that the request is invalid and the request cannot be processed any further. The problem is that
prov1 has already run and the StateMachine needs to rollback those changes and also needs to skip
Has anybody implemented something like this? Any ideas how one would go about it?
We currently have one StateMachine that has specific ErrorHandling States we can jump to using
$evm.root['ae_next_state'], but it is only one StateMachine and this apporach is not scaleable
I know that setting
$evm.root['ae_next_state'] = 'state2' allows me to jump within a StateMachine.
As far as I know it cannot be used to jump to another StateMachine. At least by reading the code it seems to not be possible (https://github.com/ManageIQ/manageiq-automation_engine/blob/master/lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_state_machine.rb)
I am not aware of anything built-in in ManageIQ that would allow to jump between state machines
Ideas I have got so far
- Use some very generic embedded methods in on_entry, on_exit and on_error steps, to kick of the Retirement/Clenaup StateMachine, if the StateMachine was on _error at some point.
- Use some clever
$evm.instantiate()-call to do the cleanup in one go and just exit with MIQ_ABORT. However I think instantiate is not able to handle retries…