1 person found this helpful
You have a couple options.
If you are attempting to create DNS/AD in PRE-BuildingMachine and it fails because the records already exist for another machine, the provisioning will finish all remaining subscriptions in PRE-BuildingMachine and then move to PRE-Disposing. As a result you should have your cleanup activity for AD/DNS occur in the lifecycle state PRE-UnprovisionMachine (if you need blocking) or POST-UnprovisionMachine (no blocking) if it can only occur after the VM is destroyed; these subscriptions will never run in the above use case. This could be an issue if you do legitimately create new records in DNS/AD but another blocking subscription within PRE-BuildingMachine fails; it will never move to PRE-UnprovisionMachine as the VM was never created and thus will not clean up your created records.
If you can't or don't want the cleanup to occur within PRE-MachineProvisioned then you will need to extend your VM with a custom property. During the EBS that is supposed to create the DNS/AD records, add a custom property to your IaaS VM (vCAC:Entity) with the result (e.g., needToCleanRecords=true). Then ether filter your PRE-Disposing subscription by that property (if it has no need to run at all) or check it within the vRO workflow itself.
Of course this entire problem is solved when you're generating new names for every VM you provision. Forcing state changes will not help you in this case and I generally recommend never doing it.
I had to read it a couple of times. going by everything you said I think my solution is the advise you mention above:
you're saying my AD/DNS cleanup operations should only ever be in pre-unprovisionmachine, so they only run when there is actually a VM removed. I think that would solve my problems. If it fails in pre-build, then that workflow will not run
on another note. we had issues when importing. when import failed (during machine provisioned we had some tagging workflows), it also ran workflows it shouldn (in dispose).
this solution (use pre-unprovision instead of dispose) could also be a solution for this problem as well