I'm in the process of writing a "Delete NFS Volume" workflow in WFA v2.2 that will be called via the REST API from our own Storage Service. Here is how it currently works:
Establish some variables with the No-Op command (cluster name, vserver, etc).
Then move onto another modified No-Op command that includes a reference to export rules where I try to find any export rules that exist in the named export policy.
Then execute the Remove Volume command only if I did not find any export rules in step 2 (in Advanced tab I test if I did not find the export_rule1 variable).
Then execute the Remove Export Policy command only if I did not find any export rules in step 2 (in Advanced tab I test if I did not find the export_rule1 variable).
For steps 3 & 4 we don't want to remove the volume & its export policy if any rules exist because we want to protect naive end-users from destroying their own data. The idea is that they will need to explicitly remove all export rules from the policy first with the "Modify NFS Volume" workflow first.
Right now the Remove Volume & Remove Export Policy commands become disabled if any export rules are found - good in the sense that the workflow doesn't delete the volume as desired but bad because the overall workflow exits successfully. Therein lies the problem - I want to abort the workflow if I find any export rules and I'm not sure how to abort a workflow if I find something. It's only clear to me how to abort a workflow if I don't find what I'm looking for.
Can someone let me know how it might be possible to abort a workflow if I find something (and in this case exit with a custom error message)? I'm playing around with conditional execution but haven't figured it out yet...
Could you try something like this in your workflow:
- Add a return parameter to your workflow with a value that errors out if the export rule was found. Something like this screenshot:
The value used above is:
export_rule1._found ? throwException("The volume is associated with an export policy that has active rules. Use Modify NFS Volume workflow to fix that before attempting to destroy the volume") : "No problem"
When the workflow is executed on a volume associated with an export policy with rules, then it errors out as shown below. Unfortunately, the error message, shows the complete expression string also.
When executed on a volume which is associated with an export policy with no rules, it succeeds.
The same can also be tried in the Advanced tab->Conditional Execution -> If the following expression is true.
If there is an easier way to achieve this case, then we will get back again.