In which flow the exception occurs – while provisioning OR while decommissioning?
In both the flows, on exception the destructor flow gets called, but if decommissioning succeeds, then destructor operation is not called.
In case of provisioning flow - VirtualGuest_Destructor will not be called unless VirtualGuest_Constructor succeeds (i.e. failure happens post VG_Constructor call).
So if the exception occurs while in VirtualGuest_Constructor, then it will not be called. The primary reason for this is – we do not get VG reference to persist in CloudDB in case of failure and hence can’t really do anything in VG_Destructor.
There are 2 options based on your use-case –
- You can attach callout to ComputeContainer_Destructor, but in case of VirtualGuest_Constructor failure, you will not get VG reference. Rest all cases will work fine and you can still do other cleanups where VG reference is not needed.
- You can attach Post callout to VG_Constructor itself. It will need to check for failure OR success. In case of failure, you can do the cleanup based on the information available (which again might be limiting)
If you clarify the nature of cleanup, it will be more clear..
To be more concrete, the case that the provisioning flow fails due to unknown exceptions (such as AO callout returns a failure, or BSA VGP job execution fails for any reason).
In our scenario, DNS records are created pre-provisioning so that the VGP process is successful (particularly, the USP job success as we are enrolling in BSA based on hostname).
The problem is that if the provisioning flow fails due to one of the above mentioned exceptions (ao, vgp job failure, etc), the DNS record will remain as orphan. This can cause consecutive provisioning attempts to fail as the DNS record (and A record/PTR records) already exist. I want to clean up the DNS management if a failed provisioning occurs. I already do this clean up doing a successful decommissioning flow.
Hope this makes better sense.
Thanks Vinnie. Then ComputeContainer_Destructor seems the right place to me. You can have the cleanup hooked as post-callout there.