Microsoft Virtualization Discussions

Invoke-NcSnapMirrorBreak - Another SnapMirror operation is in progress.

MRoney
3,078 Views

I am trying to script the snapmirror failover process using PTK.

 

When I run the following set of commands,

# Update Existing SnapMirror and then Break it off
Invoke-NcSnapMirrorUpdate -Controller $DstCtrl -DestinationVserver $DstSVM -DestinationVolume $DstVol -ErrorAction stop
Watch-Command { Get-NcSnapMirror -Controller $DstCtrl -DestinationVserver $DstSVM -DestinationVolume $DstVol | Select Status } -Until "idle"
Invoke-NcSnapMirrorQuiesce -Controller $DstCtrl -DestinationVserver $DstSVM -DestinationVolume $DstVol -ErrorAction stop
Watch-Command { Get-NcSnapMirror -Controller $DstCtrl -DestinationVserver $DstSVM -DestinationVolume $DstVol | Select Status } -Until "quiesced"
Invoke-NcSnapMirrorBreak -Controller $DstCtrl -DestinationVserver $DstSVM -DestinationVolume $DstVol -Confirm:$false -ErrorAction stop

 

the Invoke-NcSnapMirrorBreak sometime returns with an error:

Invoke-NcSnapMirrorBreak : Another SnapMirror operation is in progress.
At Z:\Software\NetApp\Powershell Toolkit\Scripts\SnapMirror-Reverse-v3.ps1:119 char:1
+ Invoke-NcSnapMirrorBreak -Controller $DstCtrl -DestinationVserver $Ds ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (apfas8200:NcController) [Invoke-NcSnapmirrorBreak], EANOTHER_OP_ACTIVE
+ FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Snapmirror.InvokeNcSnapmirrorBreak

 

Why does it report another operation is in progress?  I just checked the status, and it was quiesced.

It does not fail every time it runs, just some of the time.  I have many snapmirrors where I perform this operation repeatedly.  Many work just fine and then others seem to fail nearly all the time.  I can sometimes just resume the snapmirror and start the script again and it runs without any issues on the same snapmirror.

 

Is there some code I can add to check and try again... like maybe 3 times before aborting?

 

Or better yet, does anyone know what I am not doing correctly to make sure the snapmirror is not performing another operation before I request the snapmirror break?

1 ACCEPTED SOLUTION

aladd
2,939 Views

I'm not seeing anything wrong with the script. But adding a 3 second wait time following each watch-command may be helpful.

 

incorporating Python may help.

https://docs.netapp.com/us-en/ontap-select/concept_api_before_python.html

 

and I found the below on creating a time delay in Python.

 

https://realpython.com/python-sleep/#adding-a-python-sleep-call-with-timesleep

View solution in original post

3 REPLIES 3

aladd
2,940 Views

I'm not seeing anything wrong with the script. But adding a 3 second wait time following each watch-command may be helpful.

 

incorporating Python may help.

https://docs.netapp.com/us-en/ontap-select/concept_api_before_python.html

 

and I found the below on creating a time delay in Python.

 

https://realpython.com/python-sleep/#adding-a-python-sleep-call-with-timesleep

NetApp_SR
2,931 Views

I agree with aladd that adding a delay after the "Watch-Command" lines is good practice. Power shell has a built in command to add the delay. The scripts I see add 15-30 seconds.

Start-Sleep -s 15

 

MRoney
2,819 Views

Thank you for the feedback.  I am adding the delay and will let you know how that worked out.

Public