From 1d503937e841da27f5e3441775b2d208e44f5e75 Mon Sep 17 00:00:00 2001 From: Navneet Singh Date: Sun, 20 Oct 2013 06:25:55 +0530 Subject: [PATCH] NetApp fix ssc volume filtering inconsistency This fixes the situation when the actual netapp volume data structure becomes inconsistent because of operating on the actual object than the copy of it. It also introduces some checks before calculating volume stats. Change-Id: I626f9ca9aa8c7cc41ba4aa6058f14cc040f7301f Closes-Bug:#1243081 --- cinder/volume/drivers/netapp/iscsi.py | 14 +++++++++----- cinder/volume/drivers/netapp/nfs.py | 14 +++++++++----- cinder/volume/drivers/netapp/ssc_utils.py | 2 +- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cinder/volume/drivers/netapp/iscsi.py b/cinder/volume/drivers/netapp/iscsi.py index ccd318dcf..2ae70dbce 100644 --- a/cinder/volume/drivers/netapp/iscsi.py +++ b/cinder/volume/drivers/netapp/iscsi.py @@ -1077,11 +1077,15 @@ class NetAppDirectCmodeISCSIDriver(NetAppDirectISCSIDriver): data['netapp_thick_provisioned'] = 'true'\ if len(self.ssc_vols['all']) >\ len(self.ssc_vols['thin']) else 'false' - vol_max = max(self.ssc_vols['all']) - data['total_capacity_gb'] =\ - int(vol_max.space['size_total_bytes']) / units.GiB - data['free_capacity_gb'] =\ - int(vol_max.space['size_avl_bytes']) / units.GiB + if self.ssc_vols['all']: + vol_max = max(self.ssc_vols['all']) + data['total_capacity_gb'] =\ + int(vol_max.space['size_total_bytes']) / units.GiB + data['free_capacity_gb'] =\ + int(vol_max.space['size_avl_bytes']) / units.GiB + else: + data['total_capacity_gb'] = 0 + data['free_capacity_gb'] = 0 else: LOG.warn(_("Cluster ssc is not updated. No volume stats found.")) ssc_utils.refresh_cluster_ssc(self, self.client, self.vserver) diff --git a/cinder/volume/drivers/netapp/nfs.py b/cinder/volume/drivers/netapp/nfs.py index bde0f6c16..95d729d29 100644 --- a/cinder/volume/drivers/netapp/nfs.py +++ b/cinder/volume/drivers/netapp/nfs.py @@ -902,11 +902,15 @@ class NetAppDirectCmodeNfsDriver (NetAppDirectNfsDriver): data['netapp_thick_provisioned'] = 'true'\ if len(self.ssc_vols['all']) >\ len(self.ssc_vols['thin']) else 'false' - vol_max = max(self.ssc_vols['all']) - data['total_capacity_gb'] =\ - int(vol_max.space['size_total_bytes']) / units.GiB - data['free_capacity_gb'] =\ - int(vol_max.space['size_avl_bytes']) / units.GiB + if self.ssc_vols['all']: + vol_max = max(self.ssc_vols['all']) + data['total_capacity_gb'] =\ + int(vol_max.space['size_total_bytes']) / units.GiB + data['free_capacity_gb'] =\ + int(vol_max.space['size_avl_bytes']) / units.GiB + else: + data['total_capacity_gb'] = 0 + data['free_capacity_gb'] = 0 elif self.ssc_enabled: LOG.warn(_("No cluster ssc stats found." " Wait for next volume stats update.")) diff --git a/cinder/volume/drivers/netapp/ssc_utils.py b/cinder/volume/drivers/netapp/ssc_utils.py index 5e53221d9..77abb9ef7 100644 --- a/cinder/volume/drivers/netapp/ssc_utils.py +++ b/cinder/volume/drivers/netapp/ssc_utils.py @@ -472,7 +472,7 @@ def get_volumes_for_specs(ssc_vols, specs): """Shortlists volumes for extra specs provided.""" if specs is None or not isinstance(specs, dict): return ssc_vols['all'] - result = ssc_vols['all'] + result = copy.deepcopy(ssc_vols['all']) raid_type = specs.get('netapp:raid_type') disk_type = specs.get('netapp:disk_type') qos_policy_group = specs.get('netapp:qos_policy_group') -- 2.45.2