ceph-iscsi-cli icon indicating copy to clipboard operation
ceph-iscsi-cli copied to clipboard

gwcli error - ZeroDivisionError: float division by zero

Open leodavidsec opened this issue 8 years ago • 7 comments

Hi, I am scratching my head to figure out what could be the issue:

[root@iscsi-gw-test1 RPMS]# gwcli -d Adding ceph cluster 'ceph' to the UI Refreshing disk information from the config object Refreshing gateway & client information Gathering pool stats for 'ceph' Traceback (most recent call last): File "/usr/bin/gwcli", line 185, in main() File "/usr/bin/gwcli", line 99, in main root_node.refresh() File "/usr/lib/python2.7/site-packages/gwcli/gateway.py", line 88, in refresh self.ceph.refresh() File "/usr/lib/python2.7/site-packages/gwcli/ceph.py", line 125, in refresh cluster.pools.refresh() File "/usr/lib/python2.7/site-packages/gwcli/ceph.py", line 277, in refresh self.pool_lookup[pool_name].update(pool_data) File "/usr/lib/python2.7/site-packages/gwcli/ceph.py", line 306, in update self._calc_overcommit() File "/usr/lib/python2.7/site-packages/gwcli/ceph.py", line 299, in _calc_overcommit (potential_demand / float(self.max_bytes)) * 100) ZeroDivisionError: float division by zero

This is a new iscsi-gw fresh install, "rbd" pool was cleaned up of all objects before. The object gateway.conf is created in poll "rbd" but i just can't get gwcli working...

leodavidsec avatar Jan 14 '18 12:01 leodavidsec

Hi. Issue has been sorted out, it was a ceph pool with a crush rule assigned that did not have any osds in its root crush tree at the moment. This determined a value of max_bytes 0.

leodavidsec avatar Jan 15 '18 17:01 leodavidsec

Makes sense - we should catch the error though and not barf! I'll raise a PR to fix

pcuzner avatar Jan 15 '18 21:01 pcuzner

This is a possible patch:

diff -ruN ceph_iscsi-3.2-py3.7.egg.orig/gwcli/ceph.py ceph_iscsi-3.2-py3.7.egg/gwcli/ceph.py
--- ceph_iscsi-3.2-py3.7.egg.orig/gwcli/ceph.py	2019-09-08 09:47:40.000000000 +0200
+++ ceph_iscsi-3.2-py3.7.egg/gwcli/ceph.py	2020-03-05 17:33:59.351690142 +0100
@@ -306,6 +306,11 @@
         self.max_bytes = pool_metadata['stats']['max_avail']
         self.used_bytes = pool_metadata['stats']['bytes_used']
 
+        if self.max_bytes == 0:
+            if pool_metadata['stats']['percent_used'] != 0:
+                size_mb = self.used_bytes / pool_metadata['stats']['percent_used']
+                self.max_bytes = size_mb - self.used_bytes
+
         self._calc_overcommit()
 
     def summary(self):

gurubert avatar Mar 05 '20 16:03 gurubert

@gurubert

Are you still hitting this bug? It should be fixed. We have a check for max_bytes=0 in calc_overcommit().

mikechristie avatar Mar 05 '20 17:03 mikechristie

@gurubert

Are you still hitting this bug? It should be fixed. We have a check for max_bytes=0 in calc_overcommit().

Yes, I updated my Fedora 30 boxes and got gwcli 2.7

gurubert avatar Mar 05 '20 18:03 gurubert

Are you using gwcli from ceph-iscsi-cli or ceph-iscsi?

Where are you getting the rpm from? From the distro repo or download.ceph.com or somewhere else?

ceph-iscsi-cli is no longer being developed. We have done some releases for critical bug fixes only. It was merged with ceph-iscsi-config in the ceph-iscsi repo, and the package is named ceph-iscsi.

If you are using ceph-iscsi-cli is it because you are using ceph-ansible still?

mikechristie avatar Mar 05 '20 21:03 mikechristie

OK, please ignore that. I just found out that ceph-iscsi was installed from an older git checkout.

gurubert avatar Mar 07 '20 15:03 gurubert