Volume status changed from error to available

Bug #1785050 reported by Dudu granada
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
Fix Released
Medium
Matt Riedemann
Nominated for Pike by Matt Riedemann
Nominated for Queens by Matt Riedemann
OpenStack Compute (nova)
Invalid
Undecided
Unassigned

Bug Description

Description
===========
After creating a volume which resulted with status = "error", an attempt to attach the volume to VM will fail and will change the volume status to - "available".

Steps to reproduce
==================
1. Create volume with status = "error".
2. Try to attach the volume to the VM.
3. Check the volume status.

Expected result
===============
1. Volume will be created with status = "error".
2. Attachment to VM will failed.
3. Volume status will be - "error"

Actual result
=============
1. Volume created in status = "error".
2. Attachment attempt to VM will fail.
3. Volume status changed from "error" to "available".

Environment
===========
[stack@undercloud~(tm5)]$ openstack --version
openstack 3.14.2

[stack@undercloud~(tm5)]$ rpm -qa --last | grep nova
openstack-nova-scheduler-17.0.6-0.20180704141006.3163c93.el7.noarch Mon 09 Jul 2018 07:38:21 PM UTC
openstack-nova-placement-api-17.0.6-0.20180704141006.3163c93.el7.noarch Mon 09 Jul 2018 07:38:21 PM UTC
openstack-nova-conductor-17.0.6-0.20180704141006.3163c93.el7.noarch Mon 09 Jul 2018 07:38:21 PM UTC
openstack-nova-api-17.0.6-0.20180704141006.3163c93.el7.noarch Mon 09 Jul 2018 07:38:21 PM UTC
openstack-nova-compute-17.0.6-0.20180704141006.3163c93.el7.noarch Mon 09 Jul 2018 07:38:20 PM UTC
python-nova-17.0.6-0.20180704141006.3163c93.el7.noarch Mon 09 Jul 2018 07:38:18 PM UTC
openstack-nova-common-17.0.6-0.20180704141006.3163c93.el7.noarch Mon 09 Jul 2018 07:38:18 PM UTC
python2-novaclient-10.1.0-0.20180605113302.ed73aad.el7.noarch Mon 09 Jul 2018 07:37:49 PM UTC
puppet-nova-12.4.1-0.20180617130812.b5284f1.el7.noarch Mon 09 Jul 2018 07:33:17 PM UTC
[stack@undercloud~(tm5)]$
[stack@undercloud~(tm5)]$ rpm -qa --last | grep cinder
python2-cinderclient-3.5.0-0.20180211213738.1de605c.el7.centos.noarch Mon 09 Jul 2018 07:37:49 PM UTC
puppet-cinder-12.4.1-0.20180628102250.641e036.el7.noarch Mon 09 Jul 2018 07:33:17 PM UTC
[stack@undercloud~(tm5)]$

[stack@undercloud~(tm5)]$ sudo dmidecode | egrep -i 'manufacturer|product|vendor'
        Vendor: Seabios
        Manufacturer: Red Hat
        Product Name: KVM
        Manufacturer: Bochs

Storage:
ceph version 12.2.4

Revision history for this message
Dudu granada (dgranada) wrote :
Revision history for this message
Dudu granada (dgranada) wrote :
tags: added: volumes
Revision history for this message
Matt Riedemann (mriedem) wrote :

OK so nova and cinder are both at the queens release, which means when you attach the volume to the server, the compute API should create a volume attachment record on the given volume. If the volume is in 'error' status I'd expect that to fail like how the old volume reserve action would fail for a volume in error status.

Looking at the cinder volume attachment create code, it should fail if the volume isn't in 'available' or 'downloading' status:

https://github.com/openstack/cinder/blob/9bc9a528ef46522fd727a2a047da435c658a15c5/cinder/volume/api.py#L2084

It seems that this is the problem - because there is an instance_uuid, override=True:

https://github.com/openstack/cinder/blob/9bc9a528ef46522fd727a2a047da435c658a15c5/cinder/volume/api.py#L2093

And then the volume statis us changed to reserved:

https://github.com/openstack/cinder/blob/9bc9a528ef46522fd727a2a047da435c658a15c5/cinder/volume/api.py#L2111

Then once the attach on the compute actually fails, we'd delete the attachment from the nova side and the volume will be back in 'available' status because it no longer has any attachments:

https://github.com/openstack/cinder/blob/9bc9a528ef46522fd727a2a047da435c658a15c5/cinder/volume/api.py#L2193

Compare that to how the volume "reserve" action works:

https://github.com/openstack/cinder/blob/9bc9a528ef46522fd727a2a047da435c658a15c5/cinder/volume/api.py#L690

If the volume isn't 'available' it will fail.

Revision history for this message
Matt Riedemann (mriedem) wrote :

Furthermore we won't get here if:

https://github.com/openstack/cinder/blob/9bc9a528ef46522fd727a2a047da435c658a15c5/cinder/volume/api.py#L2100

If the volume doesn't have any attachments. Looks like that for loop should have an else clause to set override back to False.

This is a cinder bug so I've changed the project.

Changed in nova:
status: New → Invalid
Changed in cinder:
status: New → Triaged
importance: Undecided → Medium
Matt Riedemann (mriedem)
Changed in cinder:
assignee: nobody → Matt Riedemann (mriedem)
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/590037

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

Reviewed: https://review.openstack.org/590037
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=9c0123eb70b0928786d81469cc3ccbd4f30f38fe
Submitter: Zuul
Branch: master

commit 9c0123eb70b0928786d81469cc3ccbd4f30f38fe
Author: Matt Riedemann <email address hidden>
Date: Wed Aug 8 16:44:33 2018 -0400

    Fix _attachment_reserve to not allow attaching an invalid status volume

    It is currently possible to create a volume attachment for a server
    when the volume is in error status because of the override logic
    in the _attachment_reserve method. What results is that the volume
    attach operation fails in nova-compute which rolls back and deletes
    the volume attachment, which puts the volume into 'available' status
    because it no longer has any attachments, which in fact it should
    have never allowed the attachment create/reserve in the first place.

    This updates the override logic such that a volume without any
    attachments which is in an invalid status will result in an error
    being raised.

    Change-Id: Id9cf2f510684cd296ffbcaf53d11889cfe8973b9
    Closes-Bug: #1785050

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

Fix proposed to branch: stable/queens
Review: https://review.openstack.org/590327

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 13.0.0.0rc1

This issue was fixed in the openstack/cinder 13.0.0.0rc1 release candidate.

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

Reviewed: https://review.openstack.org/590327
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=1c06339d6a805146e777cdba8ef550f14bada9b2
Submitter: Zuul
Branch: stable/queens

commit 1c06339d6a805146e777cdba8ef550f14bada9b2
Author: Matt Riedemann <email address hidden>
Date: Wed Aug 8 16:44:33 2018 -0400

    Fix _attachment_reserve to not allow attaching an invalid status volume

    It is currently possible to create a volume attachment for a server
    when the volume is in error status because of the override logic
    in the _attachment_reserve method. What results is that the volume
    attach operation fails in nova-compute which rolls back and deletes
    the volume attachment, which puts the volume into 'available' status
    because it no longer has any attachments, which in fact it should
    have never allowed the attachment create/reserve in the first place.

    This updates the override logic such that a volume without any
    attachments which is in an invalid status will result in an error
    being raised.

    Change-Id: Id9cf2f510684cd296ffbcaf53d11889cfe8973b9
    Closes-Bug: #1785050
    (cherry picked from commit 9c0123eb70b0928786d81469cc3ccbd4f30f38fe)

tags: added: in-stable-queens
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (stable/pike)

Fix proposed to branch: stable/pike
Review: https://review.openstack.org/592212

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

Reviewed: https://review.openstack.org/592212
Committed: https://git.openstack.org/cgit/openstack/cinder/commit/?id=aae373d7d58b8c964d30b3cd709fe03fee15195a
Submitter: Zuul
Branch: stable/pike

commit aae373d7d58b8c964d30b3cd709fe03fee15195a
Author: Matt Riedemann <email address hidden>
Date: Wed Aug 8 16:44:33 2018 -0400

    Fix _attachment_reserve to not allow attaching an invalid status volume

    It is currently possible to create a volume attachment for a server
    when the volume is in error status because of the override logic
    in the _attachment_reserve method. What results is that the volume
    attach operation fails in nova-compute which rolls back and deletes
    the volume attachment, which puts the volume into 'available' status
    because it no longer has any attachments, which in fact it should
    have never allowed the attachment create/reserve in the first place.

    This updates the override logic such that a volume without any
    attachments which is in an invalid status will result in an error
    being raised.

    Conflicts:
        cinder/tests/unit/volume/test_volume.py
        cinder/volume/api.py

    Change-Id: Id9cf2f510684cd296ffbcaf53d11889cfe8973b9
    Closes-Bug: #1785050
    (cherry picked from commit 9c0123eb70b0928786d81469cc3ccbd4f30f38fe)
    (cherry picked from commit 1c06339d6a805146e777cdba8ef550f14bada9b2)

tags: added: in-stable-pike
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 12.0.4

This issue was fixed in the openstack/cinder 12.0.4 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/cinder 11.2.0

This issue was fixed in the openstack/cinder 11.2.0 release.

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.