From bea4586635cbfa369c7552ac73d3e98aa4a61fb1 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Thu, 25 Feb 2021 17:40:32 +0100 Subject: [PATCH] Fix volume OVO create method When we create a volume in the DB using the OVO interface we were missing some fields in the volume present in memory after it has been created. This was caused by the create method not passing the expected attributes to the _from_db_object. Because of this missing information we have places in the code where we forcefully a reload of the whole Volume OVO when it shouldn't be necessary. This patch fixes the create method of the Volume OVO and removes an instance of the forceful reload of the volume, reducing our DB calls. Change-Id: Ia59cbc5a4eb279e56f07ff9f44aa40b582aea829 --- cinder/objects/volume.py | 3 ++- cinder/volume/api.py | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cinder/objects/volume.py b/cinder/objects/volume.py index 53db5debb4b..bef4f3fd5f8 100644 --- a/cinder/objects/volume.py +++ b/cinder/objects/volume.py @@ -351,7 +351,8 @@ class Volume(cleanable.CinderCleanableObject, base.CinderObject, volume_types.get_default_volume_type()['id']) db_volume = db.volume_create(self._context, updates) - self._from_db_object(self._context, self, db_volume) + expected_attrs = self._get_expected_attrs(self._context) + self._from_db_object(self._context, self, db_volume, expected_attrs) def save(self): updates = self.cinder_obj_get_changes() diff --git a/cinder/volume/api.py b/cinder/volume/api.py index d9e6c6a1214..215bfe88b1c 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -353,9 +353,6 @@ class API(base.Base): if flow_engine.storage.fetch('refresh_az'): self.list_availability_zones(enable_cache=True, refresh_cache=True) - # Refresh the object here, otherwise things ain't right - vref = objects.Volume.get_by_id( - context, vref['id']) LOG.info("Create volume request issued successfully.", resource=vref) return vref