Attaching the same multiattach volume to the same instance twice leaves the volume in 'Attaching' state

Bug #1449980 reported by Shyama
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Medium
Shyama
Kilo
Fix Released
Medium
Mike Perez

Bug Description

Calling reserve_volume and the attach api in sequence two times for the same instance and same multiattach volume leaves the volume in attaching state

First time
- reserve_volume sets the volume status to 'Attaching'
- attach api updates db with attachment information and marks the volume as 'In-Use'

Second time
- reserve_volume sets the volume to 'Attaching'
- cinder/volume/manager.py checks if the volume is already attached to the same instance and returns, but the volume is left in 'attaching' state

            if instance_uuid:
                attachment = \
                    self.db.volume_attachment_get_by_instance_uuid(
                        context, volume_id, instance_uuid)
            else:
                attachment = \
                    self.db.volume_attachment_get_by_host(context, volume_id,
                                                          host_name_sanitized)
            if attachment is not None:
                return ==> this return leaves the volume in attaching state

The fix would be to revert the state back to in-use before return
@@ -785,6 +785,11 @@
                     self.db.volume_attachment_get_by_host(context, volume_id,
                                                           host_name_sanitized)
             if attachment is not None:
+ # In the case where volume is already attached to this instance
+ # we need to update the volume status from 'attaching' to
+ # 'in-use'
+ self.db.volume_update(context, volume_id,
+ {'status': 'in-use'})
                 return

             self._notify_about_volume_usage(context, volume,

Mike Perez (thingee)
Changed in cinder:
status: New → Confirmed
milestone: none → liberty-1
importance: Undecided → Medium
tags: added: kilo-backport-potential
Changed in cinder:
assignee: nobody → Walt Boring (walter-boring)
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/179019

Changed in cinder:
assignee: Walt Boring (walter-boring) → Shyama (shyvenug)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (master)

Reviewed: https://review.openstack.org/179019
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=709949d904c7f1d0e13b41bf6723d71bcf6b5652
Submitter: Jenkins
Branch: master

commit 709949d904c7f1d0e13b41bf6723d71bcf6b5652
Author: Shyama Venugopal <email address hidden>
Date: Thu Apr 30 12:22:27 2015 +0200

    Revert state if attachment already exists

    When attach is called twice for the same volume and instance the
    attach_volume checks if the attachment already exists and returns.
    This leaves the volume in 'Attaching' state. The volume status should
    be reset to 'in-use' if we see the attachment already exists.

    Change-Id: I2a2d28de59af234300082ab4655b0bc10699d54c
    Closes-Bug: #1449980

Changed in cinder:
status: In Progress → Fix Committed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (stable/kilo)

Fix proposed to branch: stable/kilo
Review: https://review.openstack.org/179207

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cinder (stable/kilo)

Reviewed: https://review.openstack.org/179207
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=a5908fdbcb2b80fdd7cecc04c82abf7c88d1a75e
Submitter: Jenkins
Branch: stable/kilo

commit a5908fdbcb2b80fdd7cecc04c82abf7c88d1a75e
Author: Shyama Venugopal <email address hidden>
Date: Thu Apr 30 12:22:27 2015 +0200

    Revert state if attachment already exists

    When attach is called twice for the same volume and instance the
    attach_volume checks if the attachment already exists and returns.
    This leaves the volume in 'Attaching' state. The volume status should
    be reset to 'in-use' if we see the attachment already exists.

    Change-Id: I2a2d28de59af234300082ab4655b0bc10699d54c
    Closes-Bug: #1449980
    (cherry picked from commit 709949d904c7f1d0e13b41bf6723d71bcf6b5652)

Thierry Carrez (ttx)
Changed in cinder:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in cinder:
milestone: liberty-1 → 7.0.0
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.