Admin context is required to delete a temporary volume from DB

Bug #1502460 reported by Masaki Kanno
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Undecided
Masaki Kanno

Bug Description

Non-disruptive backup creates a temporary volume.
Information of the volume is deleted from DB if the volume cannot be
created. [1]
Admin context is necessary to delete the information. [2]
However, the context that is used to delete the information is not
admin context. We must elevate the context to admin context.

cinder/volume/driver.py
1223 def _create_temp_cloned_volume(self, context, volume):
1224 temp_volume = {
1225 'size': volume['size'],
1226 'display_name': 'backup-vol-%s' % volume['id'],
1227 'host': volume['host'],
1228 'user_id': context.user_id,
1229 'project_id': context.project_id,
1230 'status': 'creating',
1231 }
1232 temp_vol_ref = self.db.volume_create(context, temp_volume)
1233 try:
1234 self.create_cloned_volume(temp_vol_ref, volume)
1235 except Exception:
1236 with excutils.save_and_reraise_exception():
1237 self.db.volume_destroy(context, temp_vol_ref['id']) ... [1]
1238
1239 self.db.volume_update(context, temp_vol_ref['id'],
1240 {'status': 'available'})
1241 return temp_vol_ref
1242

cinder/db/sqlalchemy/api.py
1228 @require_admin_context ... [2]
1229 @_retry_on_deadlock
1230 def volume_destroy(context, volume_id):
1231 session = get_session()
1232 now = timeutils.utcnow()
1233 with session.begin():
1234 model_query(context, models.Volume, session=session).\
1235 filter_by(id=volume_id).\
1236 update({'status': 'deleted',
1237 'deleted': True,
1238 'deleted_at': now,
1239 'updated_at': literal_column('updated_at'),
1240 'migration_status': None})
<<snip>>

Changed in cinder:
assignee: nobody → Masaki Kanno (kanno-masaki)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.openstack.org/230792

Changed in cinder:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/230792
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=1f546af6ffc8f51f7ac2546fb9456cdac86082b1
Submitter: Jenkins
Branch: master

commit 1f546af6ffc8f51f7ac2546fb9456cdac86082b1
Author: Masaki Kanno <email address hidden>
Date: Sun Oct 4 15:57:22 2015 +0900

    Delete a temporary volume in DB with admin context

    Non-disruptive backup creates a temporary volume. Information
    of the volume will be deleted from DB if the volume cannot be
    created by drivers. volume_destroy method is used in order to
    delete the information. We must elevate the context to admin
    context because the method requests admin context.

    Change-Id: Ie5cd935cdd9e13c261708e504fa6fb2622a8aebb
    Closes-Bug: 1502460

Changed in cinder:
status: In Progress → Fix Committed
Revision history for this message
Thierry Carrez (ttx) wrote : Fix included in openstack/cinder 8.0.0.0b1

This issue was fixed in the openstack/cinder 8.0.0.0b1 development milestone.

Thierry Carrez (ttx)
Changed in cinder:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.