]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Report zero capacity if GPFS is unmounted
authorzhaoqin <chaochin@gmail.com>
Fri, 8 Nov 2013 17:45:02 +0000 (01:45 +0800)
committerzhaoqin <chaochin@gmail.com>
Fri, 8 Nov 2013 17:49:53 +0000 (01:49 +0800)
_get_available_capacity() calls df command to gather the capacity of GPFS
filesystem. If GPFS is unmounted, df command will return the capacity of
root file system. This change will let get_volume_stats() to report zero
capacity, so that Cinder can schedule the volume request to another volume
service After GPFS is mounted again, the correct capacity will be reported.

Change-Id: I4c229d78e7d659604a23a50e6ab46060642b4088
Closes-Bug: #1246779

cinder/volume/drivers/gpfs.py

index 2e5b8119cbbcf531437a2f4802c3be00cc6500d4..409a8c82cbf35834f26ede7a81dfaa553a7159d9 100644 (file)
@@ -589,6 +589,18 @@ class GPFSDriver(driver.VolumeDriver):
 
     def _get_available_capacity(self, path):
         """Calculate available space on path."""
+        # Check if GPFS is mounted
+        try:
+            self._verify_gpfs_path_state(path)
+            mounted = True
+        except exception.VolumeBackendAPIException:
+            mounted = False
+
+        # If GPFS is not mounted, return zero capacity. So that the volume
+        # request can be scheduled to another volume service.
+        if not mounted:
+            return 0, 0
+
         out, _ = self._execute('df', '-P', '-B', '1', path,
                                run_as_root=True)
         out = out.splitlines()[1]