summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwhoami-rajat <rajatdhasmana@gmail.com>2021-11-26 04:35:00 -0500
committerRajat Dhasmana <rajatdhasmana@gmail.com>2022-01-03 02:38:14 -0500
commite1ced9ea312d386416c486176fd5feed102702c3 (patch)
tree0a65b13891a27fe614357675b9d12f07ceed2b3d
parent395f792358d18b858b9c280e0896fb4d4bc3a38f (diff)
downloadglance_store-e1ced9ea312d386416c486176fd5feed102702c3.tar.gz
Correct attachment_complete call
Cinder's attachment_complete API is called to mark the volume from "attaching" state to "in-use" state stating that the volume is ready to use. In the current code, attachment_complete is called before the brick connection is complete. This should be done after the connection to brick is successful and we have a volume path to write the image into. This patch corrects the behavior. The wrong sequence of execution won't have any issues functionally since we open the volume after all steps are completed but flow wise it is incorrect. This change won't have any end user impact. Change-Id: Ia9652a4ff6d7efbabb58511f0ce93a87b3a4dfa8
-rw-r--r--glance_store/_drivers/cinder.py5
-rw-r--r--glance_store/tests/unit/test_cinder_store.py2
-rw-r--r--glance_store/tests/unit/test_multistore_cinder.py2
3 files changed, 4 insertions, 5 deletions
diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py
index 3ccfe29..6ac8209 100644
--- a/glance_store/_drivers/cinder.py
+++ b/glance_store/_drivers/cinder.py
@@ -710,7 +710,6 @@ class Store(glance_store.driver.Store):
attachment = self.volume_api.attachment_update(
client, attachment['id'], connector_prop,
mountpoint='glance_store')
- self.volume_api.attachment_complete(client, attachment.id)
volume = volume.manager.get(volume_id)
connection_info = attachment.connection_info
@@ -751,6 +750,10 @@ class Store(glance_store.driver.Store):
device = connect_volume_nfs()
else:
device = conn.connect_volume(connection_info)
+
+ # Complete the attachment (marking the volume "in-use") after
+ # the connection with os-brick is complete
+ self.volume_api.attachment_complete(client, attachment.id)
if (connection_info['driver_volume_type'] == 'rbd' and
not conn.do_local_attach):
yield device['path']
diff --git a/glance_store/tests/unit/test_cinder_store.py b/glance_store/tests/unit/test_cinder_store.py
index 437cfa0..9283312 100644
--- a/glance_store/tests/unit/test_cinder_store.py
+++ b/glance_store/tests/unit/test_cinder_store.py
@@ -279,8 +279,6 @@ class TestCinderStore(base.StoreBaseTest,
attach_update.assert_called_once_with(
fake_client, fake_attachment_id,
fake_conn_info, mountpoint='glance_store')
- attach_complete.assert_called_once_with(
- fake_client, fake_attachment_id)
attach_delete.assert_called_once_with(
fake_client, fake_attachment_id)
diff --git a/glance_store/tests/unit/test_multistore_cinder.py b/glance_store/tests/unit/test_multistore_cinder.py
index 167b379..a57e198 100644
--- a/glance_store/tests/unit/test_multistore_cinder.py
+++ b/glance_store/tests/unit/test_multistore_cinder.py
@@ -312,8 +312,6 @@ class TestMultiCinderStore(base.MultiStoreBaseTest,
attach_update.assert_called_once_with(
fake_client, fake_attachment_id,
fake_conn_info, mountpoint='glance_store')
- attach_complete.assert_called_once_with(
- fake_client, fake_attachment_id)
attach_delete.assert_called_once_with(
fake_client, fake_attachment_id)