From b4d1ad43255cb155e08f760094efafae6bc104d7 Mon Sep 17 00:00:00 2001 From: Justin Riley Date: Fri, 30 Jan 2015 10:42:50 -0500 Subject: [PATCH] Merge pull request #490 from datacratic/sge_get_loads_fix Squashed commit of the following: commit d022228f86e07cf0c32e1f3470fc19a444dd481b Author: Mich Date: Fri Jan 30 10:40:15 2015 -0500 Removed duplicate part commit f488c500ae8d4242aab9c931dd114011096f9940 Author: Mich Date: Fri Jan 30 10:34:42 2015 -0500 Converts no load to 0 on get_loads commit d69ccd0d90a16c46de6fd81b6f3b712394e30a9c Author: Mich Date: Fri Jan 30 10:23:52 2015 -0500 Added comment about the load_avg operation commit 81e544cc331ca9d7733fa1d0c911a0659e1b4f13 Author: Mich Date: Fri Jan 30 10:23:12 2015 -0500 try/except instead of isinstance for load avg check commit de3f313af502ba46c1165cc91d94f04d7e2161ce Author: Mich Date: Thu Jan 29 15:19:39 2015 -0500 Fix a crash that occurs when nodes load factor exceeds 999 closes #490 --- starcluster/balancers/sge/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/starcluster/balancers/sge/__init__.py b/starcluster/balancers/sge/__init__.py index 02693a8f7..ca6f31f17 100644 --- a/starcluster/balancers/sge/__init__.py +++ b/starcluster/balancers/sge/__init__.py @@ -311,9 +311,16 @@ def get_loads(self): """ loads = [] for h in self.hosts: - if h['load_avg'] == '-': - h['load_avg'] = 0 - loads.append(h['load_avg']) + load_avg = h['load_avg'] + try: + if load_avg == "-": + load_avg = 0 + elif load_avg[-1] == 'K': + load_avg = float(load_avg[:-1]) * 1000 + except TypeError: + # load_avg was already a number + pass + loads.append(load_avg) return loads def _add(self, x, y):