VMware Cloud Community
orian
Hot Shot
Hot Shot

Subscription fail

Hi,

I have a subscription configured to run a workflow:

Data > Lifecycle state > Lifecycle state name equals VMPSMasterWorkflow32.Requested

Data > lifecycle state > State phase equals PRE

I also chose the folowing checkboxs: Blocking and Stop processing if the workflow fails.

However, If the workflow fails, the deployment continues and does not stop with a fail error.

Any idea?

Thanks!

Tags (2)
Reply
0 Kudos
2 Replies
qc4vmware
Virtuoso
Virtuoso

I struggled with this for a long time.  I'm at version 7.3.1 so I can only speak for versions up of 7.x up to this.  Well, truthfully I've just upgraded everything to 7.5 but I've not gone back to test some of the documented ways to gracefully fail out of a deployment.  I can tell you what ended up working well for me.  At each stage of the deployment where I have subscriptions I set custom properties that track what has been done (grabbing an address from IPAM, creating a machine record in AD, modifying group lists etc).  At any point there is a failure I have error handling that sets a flag to fail out during the MachineBuilding PRE phase.  In that subscription if the flag is detected an error is thrown and the default error handler in that workflow checks for the other things that I track and cleans them up (remove an ip reservation, remove a machine object, etc).  Throwing an error here also triggers disposal of the vm so whatever subscriptions you have for disposing will also get triggered.

Hope this helps... during the machine building phase was the only way I found success but others who've more experience past 7.3.1 might have a different story to share.

Paul

Reply
0 Kudos
xian_
Expert
Expert

This is the expected behavior according to Configuring the Error Behavior for States and Events

You have three options:

1. Assign your workflows to the listed states (jumping to Error State)

State Where Error OccursError State
PRE MachineProvisionedUnprovisionMachine
PRE BuildingMachineDisposing
PRE RegisterMachineFinalized

This is working out of the box, but may be too late for your usecase.

2. Add custom properties to the machine for any events or states where you want to trigger an event or force a state change (Extensibility.Lifecycle.Error.Event.{Workflow}.{State} and Extensibility.Lifecycle.Error.State.{Workflow}.{State})

I have not tried those myself but if you search in the forum for these you'll find that it is not easy to find the correct state to jump into. Some discussions on the topic:

Cancel provisioning process

Fail VRA deployment when event broker workflow fails

3. Setting virtualMachineEvent to BuildFailure or BuildSuccess

Exploring the vRealize Automation 7.0 Event Broker – Part 2  - section Changing the progression of a workflow

Transfer Custom Properties between vRA and vRO [Geir's Wiki of things to remember]

Re: How do I stop/block/fail a VM provisioning from entering BuildingMachine event (while developing...

I believe the last forum thread is the closest to what you want. Christopher's idea should work, but I have not tried myself (yet).

In the same thread you'll see a warning from VMware:

"Hard changing the state of the master workflow (by using workflowNextState or the corresponding property) is not recommended because the state transitions are ‘encoded’ in the workflow itself – it goes through pre-defined paths during the provisioning. Those paths have been tested and verified to be working. Changing the state directly may force the workflow into unpredictable paths which may not work or cause unpredictable behavior.

That’s why it is better to use events – most of them are like triggering D2O from the UI. There are some exceptions – events that are used internally by vRA, like BuildSuccess."