diff options
author | Zuul <zuul@review.opendev.org> | 2021-12-17 19:04:10 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-12-17 19:04:10 +0000 |
commit | c093edab2d11938ac88cbde3323b90d50e8120a6 (patch) | |
tree | ea7d7334228571b7cb0991f2853163ec7ab4a3af | |
parent | 0fb7229979858aa1a0d33dca141a110da6e6a21e (diff) | |
parent | 3a7b2e3064319ef3ee844cdebfa9bbcaa4d6b377 (diff) | |
download | cinder-c093edab2d11938ac88cbde3323b90d50e8120a6.tar.gz |
Merge "RBD: Open RBD images read-only where possible" into stable/train
-rw-r--r-- | cinder/volume/drivers/rbd.py | 15 | ||||
-rw-r--r-- | releasenotes/notes/bug-1947518-rbd-open-readonly-ba523c4b0ddbba76.yaml | 9 |
2 files changed, 19 insertions, 5 deletions
diff --git a/cinder/volume/drivers/rbd.py b/cinder/volume/drivers/rbd.py index 5973622fd..c7fe9daa9 100644 --- a/cinder/volume/drivers/rbd.py +++ b/cinder/volume/drivers/rbd.py @@ -277,7 +277,7 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, def _show_msg_check_clone_v2_api(self, volume_name): if not self._clone_v2_api_checked: self._clone_v2_api_checked = True - with RBDVolumeProxy(self, volume_name) as volume: + with RBDVolumeProxy(self, volume_name, read_only=True) as volume: try: if (volume.volume.op_features() & self.rbd.RBD_OPERATION_FEATURE_CLONE_PARENT): @@ -645,7 +645,9 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, def _get_clone_depth(self, client, volume_name, depth=0): """Returns the number of ancestral clones of the given volume.""" - parent_volume = self.rbd.Image(client.ioctx, volume_name) + parent_volume = self.rbd.Image(client.ioctx, + volume_name, + read_only=True) try: _pool, parent, _snap = self._get_clone_info(parent_volume, volume_name) @@ -992,7 +994,7 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, default_stripe_unit = \ self.configuration.rbd_store_chunk_size * units.Mi - image = self.rbd.Image(ioctx, volume_name) + image = self.rbd.Image(ioctx, volume_name, read_only=True) try: image_stripe_unit = image.stripe_unit() finally: @@ -1707,7 +1709,9 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, with RADOSClient(self) as client: # Raise an exception if we didn't find a suitable rbd image. try: - rbd_image = self.rbd.Image(client.ioctx, rbd_name) + rbd_image = self.rbd.Image(client.ioctx, + rbd_name, + read_only=True) except self.rbd.ImageNotFound: kwargs = {'existing_ref': rbd_name, 'reason': 'Specified rbd image does not exist.'} @@ -1934,7 +1938,8 @@ class RBDDriver(driver.CloneableImageVD, driver.MigrateVD, # Raise an exception if we didn't find a suitable rbd image. try: rbd_snapshot = self.rbd.Image(client.ioctx, volume_name, - snapshot=snapshot_name) + snapshot=snapshot_name, + read_only=True) except self.rbd.ImageNotFound: kwargs = {'existing_ref': snapshot_name, 'reason': 'Specified snapshot does not exist.'} diff --git a/releasenotes/notes/bug-1947518-rbd-open-readonly-ba523c4b0ddbba76.yaml b/releasenotes/notes/bug-1947518-rbd-open-readonly-ba523c4b0ddbba76.yaml new file mode 100644 index 000000000..69f063d12 --- /dev/null +++ b/releasenotes/notes/bug-1947518-rbd-open-readonly-ba523c4b0ddbba76.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + RBD driver `bug #1947518 + <https://bugs.launchpad.net/cinder/+bug/1947518>`_: + Corrected a regression caused by the fix for `Bug #1931004 + <https://bugs.launchpad.net/cinder/+bug/1931004>`_ that was attempting + to access the glance images RBD pool with write privileges when creating + a volume from an image. |