Support spaces in Gearman functions names

Jenkins allow spaces in its job names, when splitting the Gearman status
flow, nodepool uses split() which includes both spaces and tabs. That
causes an exception:

  ...
  File "nodepool/nodepool.py", line 1565, in getNeededNodes
      label_demand = self.gearman_client.getNeededWorkers()
  File "nodepool/nodepool.py", line 255, in getNeededWorkers
      queued = int(parts[1]) - int(parts[2])
  ValueError: invalid literal for int() with base 10: 'Dashboard'

That is caused by a job named 'Global-Dev Dashboard Data' with the
status output being:

  build:Global-Dev Dashboard Data<TAB>0<TAB>0<TAB>23

Since Gearman uses tab separated fields, explicitly split on tabs.

Change-Id: I72c49409808251ce87a55f8b6f444b6f57120550
This commit is contained in:
Antoine Musso 2015-04-21 11:52:25 +02:00
parent 3550c7c08f
commit 80e393f46f

View File

@ -249,7 +249,7 @@ class GearmanClient(gear.Client):
self._lostConnection(connection)
continue
for line in req.response.split('\n'):
parts = [x.strip() for x in line.split()]
parts = [x.strip() for x in line.split('\t')]
if not parts or parts[0] == '.':
continue
if not parts[0].startswith('build:'):