Active IQ Unified Manager Discussions

How to Clean WFA Reservation automatically on a command failure: The solution

sinhaa
8,411 Views

This question has been asked numerous times and Its been long existing pain that if a command execution fails, the reservation of the elements don't don't get cleared automatically. Users need to manually find out the reservation of the failed comamnd and the subsequent commands that didn't run and delete then. WFA hasn't provided any feature to do this. Till they do here is how you can solve it.

 

I'm giving solution on how to make the command do it on its own. Its a smart command.  I'll also explain the logic I've used.

 

  1. Prerequisties:

    You need PowerShell 3.0 on your WFA server. I could have done it for PoSH2.0 as well, but life for web interfaces using PowerShell is so much easier with Posh3.0. Posh3.0 is a big jump from 2.0. WFA is fully supported to work on Posh3.0. Its available by default in Win2012, Win2008 can be upgraded, Win2003 users can't use it. If I get time, I'll post one for Posh2.0 as well.

  2. Add credentials of a WFA Admin/Architect in you WFA itself with Name/IP: localhost

    Match: Exact
    Type: Other
    Name/IP: localhost
    Username: <WFA Admin/Architect Username>
    Password: <User Password>  

    Credentials_localhost.png


    That's all.



  3. Define a trap for your command and it becomes a smart command.  Trap is very useful error handling utility in powershell. Just copy paste the below code at the end of your command. That's all. 

    trap {

    Get-WFALogger -Info -message "Clearing the Reservation on this job for the Failed Command and the commands which haven't been executed."
    $myWfaCreds = Get-WfaCredentials -Host "localhost"
    $workflowName = Get-WfaRestParameter "workflowName"
    $jobId = Get-WfaRestParameter "jobId"


    #Get the WFA http port
    $REGISTRY = "HKLM:\SOFTWARE\Wow6432Node\Apache Software Foundation\Procrun 2.0\NA_WFA_SRV\Parameters\Java"
    $httpPort = (Get-ItemProperty $REGISTRY |select -ExpandProperty Options|where {$_ -match "-Dhttp.port"}).split("=")[1]

    $Url= 'http://localhost:' + $httpPort + '/rest/workflows?name=' + $WorkflowName


    #Get UUID of the workflow
    $uuid=(Invoke-RestMethod -Method get -Uri $url -Credential $myWfaCreds).collection.workflow.uuid


    #Prepare the new URL to clean reservation
    $Url2="http://localhost:" + $httpPort +"/rest/workflows/"+ $uuid + "/jobs/" + $jobId +"/reservation"


    #Invoke REST api.
    Invoke-RestMethod -Method Delete -Uri $Url2 -Credential $myWfaCreds
    Get-WfaLogger -Info -Messag "Reservation cleaned successfully"

    }



    This code will work for any command without the need of any change. The Logic: If the command fails, the trap section of the code is executed. I get the current job ID, the workflow's UUID and call the api to clean up the reservation. If the comamnd passed, trap is not executed and things work as before.

An Example:

 

1. I have a workflow with 3 commands, Create Qtree, Create Volume and Create Lun. For Create Volume, I've provide size= 1 MB so that it failes during execution, But Planning and hence reservations for all 3 will pass. Execute it now.

 

Clean Reservation.png

 

 

Verify it in Execution->Reservation. Our job ID was as below.

 

Clean Reservation 3.png

 

Reservation existing for the passed comand "Create Qtree". But Reservations for "Create Volume" and the unexecuted command "Create Lun" have been deleted.

 

Clean Reservation 2.png

 

 

 

Adding a sample command .dar file with command " Create Volume with auto clean reservation upon failure" which can be downloaded in WFA2.2 or above. Also in txt format.

 

sinhaa

 

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
6 REPLIES 6

sinhaa
8,083 Views

There were some requests for a varient in the above solution perhaps due to its need for changing the existing command code. New commands sure can use it but users may not want to modify their old existing commands. Or they can't even do so if using the WFA certified commands or else lose certification by cloning it.

 

So is it possible for a Reservation cleaning workflow which when executed cleans up reservation of all the failed commands in all the execution jobs which failed and do it for all the workflows?

 

Attaching the solution  workflow which can be imported in wfa2.2 or above. Also the command code in text format.

 

If you provide the Parameter workflowName, it will clean reservations for all failed jobs of this particular workflow. If you leave it empty it does so for all the workflows.

 

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

jauling_chou
6,328 Views

I'm runinng WFA 4.2.0.0.1, and noticed in the WFA Configuration 'Other' tab there is an option called Immediate reservation purge for failed/partially successful workflows. I have this checked, but I still see reservations for failed workflows.

 

Does this mean this option isn't working, or is there some other explanation?

 

sinhaa
6,249 Views

In my opinion, stay on WFA 4.1 for production sytems. 4.2 hasn't given anything important to upgrade. But is having many bugs.

 

 

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.

jauling_chou
6,141 Views

I think we upgraded to 4.2 to support a newer ONTAP version, but I'm not 100% sure. I think you hit the nail on the head though - when I enabled this feature, mysqld started throwing lots of deadlock errors. Turning off the feature stopped the deadlocks. Go figure. Will be reporting this as a bug for sure.

 

Would it be possible for you to refactor your workflow dar so that I can import it into WFA 4.x?

arvindasingh
5,930 Views

Hi,

 

I have a Windows 2016 Virtual Machine with WFA 4.2, when i try to clean the reservation i get below error also at same time i see CPU utilization is above 95 %.

 

org.hibernate.exception.GenericJDBCException: Error

 

Any clue, also when i try to impact the workflow, i get below message.

 

The version of .dar file used to import is 2.2.0.2.6. The supported WFA version from which a .dar file can be imported is 3.0 (V3.0.0.38.1) or later.
To use the data from this .dar file, import the .dar file to WFA 3.0 (V3.0.0.38.1) and then export a .dar file in that WFA version. You can then use the new .dar file for import in this WFA version.

 

Can you please proivde the lastest dar that i can use in 4.2 version.

 

Thank You.

Arvind Singh

sinhaa
5,899 Views

@arvindasingh

 

Please read the solution carefully. You don't need to download and import the dar file. That was an example of how to use it. The code is given in the solution and also as .txt .

 

sinhaa

If this post resolved your issue, help others by selecting ACCEPT AS SOLUTION or adding a KUDO.
Public