CSNAPC-5960: RetentionByCount fails when Resource Group contains HANA HSR instances and Application Volume
Issue
When a Resource Group contains HANA HSR and Application Volumes, and the retention policy is set to RetentionByCount, the retention process mistakenly sets the RetentionCount to 0(from the code).
This causes all available backups to be marked for deletion. Since the current backup, which is part of the ongoing workflow, is included in this deletion list, an error occurs:
Error: Remove Snapshot '<SnapShot_Name>' failed on volume '<Volume_Name>'. This Snapshot copy is currently used as a reference Snapshot copy by one or more SnapMirror relationships. Deleting the Snapshot copy can cause future SnapMirror operations to fail.
The underlying error in the backup SMCore log shows the error happening when calling RemoveAzureVolumeSnapshot:
2024-12-09T08:22:48.0441876+00:00 DEBUG SMCore_2229 PID=[8108] TID=[145] Enter RemoveAzureVolumeSnapshot
2024-12-09T08:22:48.0579056+00:00 DEBUG SMCore_2229 PID=[8108] TID=[145] Enter RemoveSnapshot
2024-12-09T08:22:48.0579150+00:00 DEBUG SMCore_2229 PID=[8108] TID=[145] Enter GetVolumeResource
2024-12-09T08:22:48.0579179+00:00 INFO SMCore_2229 PID=[8108] TID=[145] resourceGroupName: rg-sap-anf, netAppAccountName: SAP-PROD-NETAPP, capacityPoolName: PRDStoragePool-U, volumeName: SP2-HA-data-mnt00001
2024-12-09T08:22:48.2413921+00:00 DEBUG SMCore_2229 PID=[8108] TID=[145] Exit GetVolumeResource
2024-12-09T08:22:48.2413985+00:00 INFO SMCore_2229 PID=[8108] TID=[145] resourceGroupName: rg-sap-anf, netAppAccountName: SAP-PROD-NETAPP, capacityPoolName: PRDStoragePool-U, volumeName: SP2-HA-data-mnt00001, snapshotName: Prod_HP2_ukspds4hhdb02_12-09-2024_08_00_27_3341
2024-12-09T08:22:48.4065943+00:00 ERROR SMCore_2229 PID=[8108] TID=[145] Azure.RequestFailedException: The scope '/subscriptions/5327fb43-6868-4985-b12f-ca47b32ff946/resourceGroups/rg-sap-anf/providers/Microsoft.NetApp/netAppAccounts/SAP-PROD-NETAPP/capacityPools/PRDStoragePool-U/volumes/SP2-HA-data-mnt00001/snapshots/Prod_HP2_ukspds4hhdb02_12-09-2024_08_00_27_3341' cannot perform delete operation because following scope(s) are locked: '/subscriptions/5327fb43-6868-4985-b12f-ca47b32ff946/resourcegroups/rg-sap-anf'. Please remove the lock and try again.
Status: 409 (Conflict)
ErrorCode: ScopeLocked