diff --git a/glance_store/_drivers/cinder.py b/glance_store/_drivers/cinder.py index 9d3b9ad..de2c4b4 100644 --- a/glance_store/_drivers/cinder.py +++ b/glance_store/_drivers/cinder.py @@ -604,18 +604,22 @@ class Store(glance_store.driver.Store): loc = location.store_location + self._check_context(context) try: - self._check_context(context) volume = get_cinderclient(self.conf, context).volumes.get(loc.volume_id) - return int(volume.metadata.get('image_size', - volume.size * units.Gi)) except cinder_exception.NotFound: raise exceptions.NotFound(image=loc.volume_id) - except Exception: - LOG.exception(_LE("Failed to get image size due to " - "internal error.")) - return 0 + + if (is_user_overriden(self.conf) and + volume.metadata.get('image_owner') != context.tenant): + msg = _('Cannot get size of image volume %(id)s in another ' + 'tenant') % {'id': loc.volume_id} + LOG.error(msg) + raise exceptions.BackendException(msg) + + return int(volume.metadata.get('image_size', + volume.size * units.Gi)) @capabilities.check def add(self, image_id, image_file, image_size, context=None,