Disk snapshot delete fails with - Please remove the lock and try again
We use Azure python SDK APIs to create and delete disk snapshots. When we create a snapshot we also create a lock on the snapshot. While deletion on snapshot we have seen sometimes that it fails with an error like this - 'The scope '/subscriptions/6cf87370-7a9a-43b7-8a75-429f6f8d8814/resourceGroups/anirg/providers/Microsoft.Compute/snapshots/nbu7474989985348636988snap1565612042' cannot perform delete operation because following scope(s) are locked: '/subscriptions/6cf87370-7a9a-43b7-8a75-429f6f8d8814/resourcegroups/anirg/providers/Microsoft.Compute/snapshots/nbu7474989985348636988snap1565612042'. Please remove the lock and try again.'
Note: we actually call the API to delete the lock first before issuing snapshot delete request. So most of the times snapshots get deleted.
I am attaching a script with which this issue can be easily reproduced and a log file which shows the same azure_support_1.zip
I have worked with Azure Customer support to identify the following -
Problem When using the Azure SDK for Python APIs to manage your snapshot, you are experiencing sporadic issues when deleting snapshots due to resource locks, despite removing them beforehand.
Root Cause We suspect that the Python APIs might be affected by a bug that makes the checks for resource locks to fail when using the method locks.list_at_resource_level.
Resolution We recommend that you submit an issue report to the official GitHub repository to inform the development team about this.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @mjconnection, @Drewm3
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @mjconnection, @Drewm3
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure
@kaerm , this should go to the ARM team because it is an issue with locks and not specific to managed snapshots owned by Compute.
thanks @nitishkochhiveritas for the feedback. i suspect this could be due to a timing problem from removing the delete lock to when performing the delete operation as data like this is cached in the first ARM layer your request is processed and not something unique to the python SDK. @ifeoluwaokunoren can you confirm this behaviour?
Adding @Tiano2017 who was investigating this.
From service logs we don't see a DELETE request for the lock on the snapshot. Even in the log I see "creating snapshot", "created lock", and then "deleting snapshot". I don't see a log deleting the lock. You may need to double check your script.
Will close the issue.
Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.
@ifeoluwaokunoren : the script contains the API call to delete lock before issuing snapshot deletion request. Also the logs has "result from lock_delete" which shows that the delete on lock was called. Please double check.