OpenStack Block Storage (Cinder)
Go to file
Gorka Eguileor 2ec2222841 Fix: Race between attachment and volume deletion
There are cases where requests to delete an attachment made by Nova can
race other third-party requests to delete the overall volume.

This has been observed when running cinder-csi, where it first requests
that Nova detaches a volume before itself requesting that the overall
volume is deleted once it becomes `available`.

This is a cinder race condition, and like most race conditions is not
simple to explain.

Some context on the issue:

- Cinder API uses the volume "status" field as a locking mechanism to
  prevent concurrent request processing on the same volume.

- Most cinder operations are asynchronous, so the API returns before the
  operation has been completed by the cinder-volume service, but the
  attachment operations such as creating/updating/deleting an attachment
  are synchronous, so the API only returns to the caller after the
  cinder-volume service has completed the operation.

- Our current code **incorrectly** modifies the status of the volume
  both on the cinder-volume and the cinder-api services on the
  attachment delete operation.

The actual set of events that leads to the issue reported in this bug
are:

[Cinder-CSI]
- Requests Nova to detach volume (Request R1)

[Nova]
- R1: Asks cinder-api to delete the attachment and **waits**

[Cinder-API]
- R1: Checks the status of the volume
- R1: Sends terminate connection request (R1) to cinder-volume and
  **waits**

[Cinder-Volume]
- R1: Ask the driver to terminate the connection
- R1: The driver asks the backend to unmap and unexport the volume
- R1: The last attachment is removed from the DB and the status of the
      volume is changed in the DB to "available"

[Cinder-CSI]
- Checks that there are no attachments in the volume and asks Cinder to
  delete it (Request R2)

[Cinder-API]

- R2: Check that the volume's status is valid. It doesn't have
  attachments and is available, so it can be deleted.
- R2: Tell cinder-volume to delete the volume and return immediately.

[Cinder-Volume]
- R2: Volume is deleted and DB entry is deleted
- R1: Finish the termination of the connection

[Cinder-API]
- R1: Now that cinder-volume has finished the termination the code
  continues
- R1: Try to modify the volume in the DB
- R1: DB layer raises VolumeNotFound since the volume has been deleted
  from the DB
- R1: VolumeNotFound is converted to HTTP 404 status code which is
  returned to Nova

[Nova]
- R1: Cinder responds with 404 on the attachment delete request
- R1: Nova leaves the volume as attached, since the attachment delete
  failed

At this point the Cinder and Nova DBs are out of sync, because Nova
thinks that the attachment is connected and Cinder has detached the
volume and even deleted it.

Hardening is also being done on the Nova side [2] to accept that the
volume attachment may be gone.

This patch fixes the issue mentioned above, but there is a request on
Cinder-CSI [1] to use Nova as the source of truth regarding its
attachments that, when implemented, would also fix the issue.

[1]: https://github.com/kubernetes/cloud-provider-openstack/issues/1645
[2]: https://review.opendev.org/q/topic:%2522bug/1937084%2522+project:openstack/nova

Closes-Bug: #1937084
Change-Id: Iaf149dadad5791e81a3c0efd089d0ee66a1a5614
2021-10-15 17:47:38 +02:00
api-ref/source Snapshot in-use volumes without force flag 2021-08-31 14:48:32 -04:00
cinder Fix: Race between attachment and volume deletion 2021-10-15 17:47:38 +02:00
contrib/block-box Remove Block Storage API v2 2021-06-04 17:21:28 -04:00
doc Merge "PowerMax Docs - Xena release notes" 2021-10-12 15:57:05 +00:00
etc/cinder Merge "Implement user visible extra specs" 2021-09-02 23:59:59 +00:00
playbooks Native multibackend-matrix Zuul v3 job 2021-09-08 01:05:44 +02:00
rally-jobs Remove Block Storage API v2 2021-06-04 17:21:28 -04:00
releasenotes Fix: Race between attachment and volume deletion 2021-10-15 17:47:38 +02:00
roles Native multibackend-matrix Zuul v3 job 2021-09-08 01:05:44 +02:00
tools Native multibackend-matrix Zuul v3 job 2021-09-08 01:05:44 +02:00
.coveragerc Update .coveragerc after the removal of openstack directory 2016-10-17 19:09:37 +05:30
.gitignore Add mypy tox env 2020-10-14 08:24:13 -04:00
.gitreview OpenDev Migration Patch 2019-04-19 19:26:48 +00:00
.pylintrc pylint: Fix migration E1120 no-value-for-parameter 2021-04-16 13:05:21 +02:00
.stestr.conf Add .stestr.conf configuration 2017-10-10 00:46:42 +00:00
.zuul.yaml Add Python3 yoga unit tests 2021-09-17 16:24:56 +00:00
CONTRIBUTING.rst Ussuri contrib docs community goal 2020-03-05 14:11:48 -05:00
HACKING.rst Update HACKING document to match current checks 2020-04-17 15:09:13 +00:00
LICENSE Initial fork out of Nova. 2012-05-03 10:48:26 -07:00
README.rst Merge "Refactor README links" 2020-01-22 11:44:36 +00:00
bindep.txt Add libcgroup related packages in bindep.txt 2021-06-15 00:54:55 +00:00
driver-requirements.txt [Pure Storage] Fix minimum SDK version required 2021-06-28 18:40:25 -04:00
mypy-files.txt mypy: continued manager, scheduler, rpcapi 2021-08-11 08:36:09 -04:00
reno.yaml Update release note info 2021-04-16 11:11:41 -04:00
requirements.txt Use os-brick 5.0.1 2021-10-01 04:43:27 -04:00
setup.cfg [Pure Storage] Fix minimum SDK version required 2021-06-28 18:40:25 -04:00
setup.py Cleanup py27 support 2020-04-17 14:47:10 +02:00
test-requirements.txt Update SQLAlchemy related requirements 2021-09-20 11:04:30 -04:00
tox.ini Add installation of mypy stubs packages 2021-07-15 10:33:36 -04:00

README.rst

OpenStack Cinder

image

OpenStack Cinder is a storage service for an open cloud computing service.

You can learn more about Cinder at:

Getting Started

If you'd like to run from the master branch, you can clone the git repo:

git clone https://opendev.org/openstack/cinder

If you'd like to contribute, please see the information in CONTRIBUTING.rst

You can raise bugs on Launchpad

Python client

Python Cinderclient