Ensure correct lexical sorting of node requests

The recently introduced change to request child nodes of paused jobs
with a higher priority causes the priority to be actually lower in
case the pipeline precedence is set to 'high'.

Due to the lexical sorting of node requests in Nodepool, 99 will be
treated as the lowest prio in this case.

This is especially apparent when Nodepool is up against quota.

Change-Id: I094dee4f357c9974b6d9e95fcd70b02115d9de93
This commit is contained in:
Simon Westphahl 2019-03-14 15:27:28 +01:00
parent 2edb841866
commit e0321f0daa
3 changed files with 4 additions and 3 deletions

View File

@ -2,6 +2,7 @@
name: check
manager: independent
post-review: true
precedence: high
trigger:
gerrit:
- event: patchset-created

View File

@ -5265,7 +5265,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
reqs = self.fake_nodepool.getNodeRequests()
self.assertEqual(len(reqs), 1)
self.assertEqual(reqs[0]['_oid'], '200-0000000000')
self.assertEqual(reqs[0]['_oid'], '100-0000000000')
self.assertEqual(reqs[0]['provider'], None)
self.fake_nodepool.unpause()
@ -5280,7 +5280,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
break
self.assertEqual(len(reqs), 1)
self.assertEqual(reqs[0]['_oid'], '199-0000000001')
self.assertEqual(reqs[0]['_oid'], '099-0000000001')
self.assertEqual(reqs[0]['provider'], 'test-provider')
self.fake_nodepool.unpause()

View File

@ -166,7 +166,7 @@ class ZooKeeper(object):
node_request.created_time = time.time()
data = node_request.toDict()
path = '%s/%s-' % (self.REQUEST_ROOT, node_request.priority)
path = '{}/{:0>3}-'.format(self.REQUEST_ROOT, node_request.priority)
path = self.client.create(path, self._dictToStr(data),
makepath=True,
sequence=True, ephemeral=True)