azure-sdk-for-python icon indicating copy to clipboard operation
azure-sdk-for-python copied to clipboard

Disk snapshot delete fails with - Please remove the lock and try again

Open nitishkochhiveritas opened this issue 7 years ago • 9 comments

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.

nitishkochhiveritas avatar Sep 12 '19 17:09 nitishkochhiveritas

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @mjconnection, @Drewm3

ghost avatar Sep 12 '19 20:09 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @mjconnection, @Drewm3

ghost avatar Sep 12 '19 20:09 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure

ghost avatar Sep 17 '19 00:09 ghost

@kaerm , this should go to the ARM team because it is an issue with locks and not specific to managed snapshots owned by Compute.

Drewm3 avatar Sep 17 '19 01:09 Drewm3

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?

vladimirjoanovic avatar Sep 17 '19 01:09 vladimirjoanovic

Adding @Tiano2017 who was investigating this.

ifeoluwaokunoren avatar Oct 01 '19 23:10 ifeoluwaokunoren

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.

Tiano2017 avatar Oct 02 '19 21:10 Tiano2017

Thanks for working with Microsoft on GitHub! Tell us how you feel about your experience using the reactions on this comment.

ghost avatar Oct 02 '19 22:10 ghost

@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.

nitishkochhiveritas avatar Oct 18 '19 05:10 nitishkochhiveritas