]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NetApp fix ssc volume filtering inconsistency
authorNavneet Singh <singn@netapp.com>
Sun, 20 Oct 2013 00:55:55 +0000 (06:25 +0530)
committerNavneet Singh <singn@netapp.com>
Sun, 20 Oct 2013 00:55:55 +0000 (06:25 +0530)
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
cinder/volume/drivers/netapp/nfs.py
cinder/volume/drivers/netapp/ssc_utils.py

index ccd318dcfe1bd2b8110bdbdc2bca9623c26a72a7..2ae70dbce593acebf81e5119bba2a917e165bd9a 100644 (file)
@@ -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)
index bde0f6c1608fa3c431988213ca8bb32479fa3fa5..95d729d299239f0f1bb50ffd26c3ce0ae4347aa1 100644 (file)
@@ -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."))
index 5e53221d92d30b50b8fe2dc228eca81091b36847..77abb9ef7ffc03da88d6511241c4a9b8273892e1 100644 (file)
@@ -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')