Browse Source

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
tags/3.7.0
Simon Westphahl 2 months ago
parent
commit
e0321f0daa

+ 1
- 0
tests/fixtures/config/job-pause-priority/git/common-config/zuul.yaml View File

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

+ 2
- 2
tests/unit/test_v3.py View File

@@ -5265,7 +5265,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
5265 5265
 
5266 5266
         reqs = self.fake_nodepool.getNodeRequests()
5267 5267
         self.assertEqual(len(reqs), 1)
5268
-        self.assertEqual(reqs[0]['_oid'], '200-0000000000')
5268
+        self.assertEqual(reqs[0]['_oid'], '100-0000000000')
5269 5269
         self.assertEqual(reqs[0]['provider'], None)
5270 5270
 
5271 5271
         self.fake_nodepool.unpause()
@@ -5280,7 +5280,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
5280 5280
                 break
5281 5281
 
5282 5282
         self.assertEqual(len(reqs), 1)
5283
-        self.assertEqual(reqs[0]['_oid'], '199-0000000001')
5283
+        self.assertEqual(reqs[0]['_oid'], '099-0000000001')
5284 5284
         self.assertEqual(reqs[0]['provider'], 'test-provider')
5285 5285
 
5286 5286
         self.fake_nodepool.unpause()

+ 1
- 1
zuul/zk.py View File

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

Loading…
Cancel
Save