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
(cherry picked from commit 8d9f862901)
(cherry picked from commit 23729bdda4)
This commit is contained in:
Alan Bishop 2018-06-26 16:37:12 -04:00
parent f8212217e9
commit 9bd60bbdb9
2 changed files with 13 additions and 4 deletions

View File

@ -737,11 +737,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

View File

@ -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 <https://bugs.launchpad.net/tripleo/+bug/1778774>`__.