summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Westphahl <simon.westphahl@bmw.de>2019-03-14 15:27:28 +0100
committerSimon Westphahl <simon.westphahl@bmw.de>2019-03-14 15:39:23 +0100
commite0321f0daa395508b00ede277ad0cae938e009dc (patch)
tree5676fc1ccc49486772265ac6cf7e2df59fa77fed
parent2edb8418660fb5625721b3e64db54534897227aa (diff)
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
Notes
Notes (review): Code-Review+2: Tobias Henkel <tobias.henkel@bmw.de> Code-Review+2: Monty Taylor <mordred@inaugust.com> Workflow+1: Monty Taylor <mordred@inaugust.com> Code-Review+1: Andriy Shevchenko <huang.zhiping@99cloud.net> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 15 Mar 2019 05:47:33 +0000 Reviewed-on: https://review.openstack.org/643352 Project: openstack-infra/zuul Branch: refs/heads/master
-rw-r--r--tests/fixtures/config/job-pause-priority/git/common-config/zuul.yaml1
-rw-r--r--tests/unit/test_v3.py4
-rw-r--r--zuul/zk.py2
3 files changed, 4 insertions, 3 deletions
diff --git a/tests/fixtures/config/job-pause-priority/git/common-config/zuul.yaml b/tests/fixtures/config/job-pause-priority/git/common-config/zuul.yaml
index a07342e..1480b90 100644
--- a/tests/fixtures/config/job-pause-priority/git/common-config/zuul.yaml
+++ b/tests/fixtures/config/job-pause-priority/git/common-config/zuul.yaml
@@ -2,6 +2,7 @@
2 name: check 2 name: check
3 manager: independent 3 manager: independent
4 post-review: true 4 post-review: true
5 precedence: high
5 trigger: 6 trigger:
6 gerrit: 7 gerrit:
7 - event: patchset-created 8 - event: patchset-created
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index c0c5d6c..075f776 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -5265,7 +5265,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
5265 5265
5266 reqs = self.fake_nodepool.getNodeRequests() 5266 reqs = self.fake_nodepool.getNodeRequests()
5267 self.assertEqual(len(reqs), 1) 5267 self.assertEqual(len(reqs), 1)
5268 self.assertEqual(reqs[0]['_oid'], '200-0000000000') 5268 self.assertEqual(reqs[0]['_oid'], '100-0000000000')
5269 self.assertEqual(reqs[0]['provider'], None) 5269 self.assertEqual(reqs[0]['provider'], None)
5270 5270
5271 self.fake_nodepool.unpause() 5271 self.fake_nodepool.unpause()
@@ -5280,7 +5280,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
5280 break 5280 break
5281 5281
5282 self.assertEqual(len(reqs), 1) 5282 self.assertEqual(len(reqs), 1)
5283 self.assertEqual(reqs[0]['_oid'], '199-0000000001') 5283 self.assertEqual(reqs[0]['_oid'], '099-0000000001')
5284 self.assertEqual(reqs[0]['provider'], 'test-provider') 5284 self.assertEqual(reqs[0]['provider'], 'test-provider')
5285 5285
5286 self.fake_nodepool.unpause() 5286 self.fake_nodepool.unpause()
diff --git a/zuul/zk.py b/zuul/zk.py
index d35a5df..433fc98 100644
--- a/zuul/zk.py
+++ b/zuul/zk.py
@@ -166,7 +166,7 @@ class ZooKeeper(object):
166 node_request.created_time = time.time() 166 node_request.created_time = time.time()
167 data = node_request.toDict() 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 path = self.client.create(path, self._dictToStr(data), 170 path = self.client.create(path, self._dictToStr(data),
171 makepath=True, 171 makepath=True,
172 sequence=True, ephemeral=True) 172 sequence=True, ephemeral=True)