From 8d9f8629013bcb880fb3e33f03b274c10befdab0 Mon Sep 17 00:00:00 2001 From: Alan Bishop Date: Tue, 26 Jun 2018 16:37:12 -0400 Subject: [PATCH] Fix quota error when deleting temporary volume When deleting a volume, always use the admin context to fetch the admin_metadata that indicates whether it's a temporary volume. This fixes a bug where a non-admin user failed to retrieve the admin_metadata, which caused the volume to not be treated as temporary. This, in turn, caused quota usage to be incorrectly updated. Closes-Bug: #1778774 Change-Id: I8e6b0c726dc6498b28795a1ea0520ef05e53f047 --- cinder/volume/manager.py | 9 +++++---- ...quota-deleting-temporary-volume-274e371b425e92cc.yaml | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fix-quota-deleting-temporary-volume-274e371b425e92cc.yaml diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index eff70bec100..33cd396160a 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -763,11 +763,12 @@ class VolumeManager(manager.CleanableManager, # To backup a snapshot or a 'in-use' volume, create a temp volume # from the snapshot or in-use volume, and back it up. - # Get admin_metadata to detect temporary volume. + # Get admin_metadata (needs admin context) to detect temporary volume. is_temp_vol = False - if volume.admin_metadata.get('temporary', 'False') == 'True': - is_temp_vol = True - LOG.info("Trying to delete temp volume: %s", volume.id) + with volume.obj_as_admin(): + if volume.admin_metadata.get('temporary', 'False') == 'True': + is_temp_vol = True + LOG.info("Trying to delete temp volume: %s", volume.id) # The status 'deleting' is not included, because it only applies to # the source volume to be deleted after a migration. No quota diff --git a/releasenotes/notes/fix-quota-deleting-temporary-volume-274e371b425e92cc.yaml b/releasenotes/notes/fix-quota-deleting-temporary-volume-274e371b425e92cc.yaml new file mode 100644 index 00000000000..33d31982278 --- /dev/null +++ b/releasenotes/notes/fix-quota-deleting-temporary-volume-274e371b425e92cc.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Fix a quota usage error triggered by a non-admin user backing up an + in-use volume. The forced backup uses a temporary volume, and quota + usage was incorrectly updated when the temporary volume was deleted + after the backup operation completed. + Fixes `bug 1778774 `__.