summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2019-02-28 16:56:00 +0000
committerGerrit Code Review <review@openstack.org>2019-02-28 16:56:00 +0000
commite70bd50a83c0699ed4545aa034da53a0fac4bc6f (patch)
tree267b07c52ac776090b35726396b27b4d8221bf2f
parentf4793a1df47507ec7c445f84952c0b87b1547298 (diff)
parent4fc2b345b434772b5897ba6549ac3b980de304a9 (diff)
Merge "Request dependent job nodes from paused parent provider"
-rw-r--r--tests/unit/test_v3.py2
-rw-r--r--zuul/model.py28
2 files changed, 24 insertions, 6 deletions
diff --git a/tests/unit/test_v3.py b/tests/unit/test_v3.py
index 955a344..9da04e4 100644
--- a/tests/unit/test_v3.py
+++ b/tests/unit/test_v3.py
@@ -5120,6 +5120,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
5120 reqs = self.fake_nodepool.getNodeRequests() 5120 reqs = self.fake_nodepool.getNodeRequests()
5121 self.assertEqual(len(reqs), 1) 5121 self.assertEqual(len(reqs), 1)
5122 self.assertEqual(reqs[0]['_oid'], '200-0000000000') 5122 self.assertEqual(reqs[0]['_oid'], '200-0000000000')
5123 self.assertEqual(reqs[0]['provider'], None)
5123 5124
5124 self.fake_nodepool.unpause() 5125 self.fake_nodepool.unpause()
5125 self.waitUntilSettled() 5126 self.waitUntilSettled()
@@ -5134,6 +5135,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
5134 5135
5135 self.assertEqual(len(reqs), 1) 5136 self.assertEqual(len(reqs), 1)
5136 self.assertEqual(reqs[0]['_oid'], '199-0000000001') 5137 self.assertEqual(reqs[0]['_oid'], '199-0000000001')
5138 self.assertEqual(reqs[0]['provider'], 'test-provider')
5137 5139
5138 self.fake_nodepool.unpause() 5140 self.fake_nodepool.unpause()
5139 self.waitUntilSettled() 5141 self.waitUntilSettled()
diff --git a/zuul/model.py b/zuul/model.py
index 7d84927..feefd68 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -714,6 +714,7 @@ class NodeRequest(object):
714 self.stat = None 714 self.stat = None
715 self.uid = uuid4().hex 715 self.uid = uuid4().hex
716 self.relative_priority = relative_priority 716 self.relative_priority = relative_priority
717 self.provider = self._getPausedParentProvider()
717 self.id = None 718 self.id = None
718 self._zk_data = {} # Data that we read back from ZK 719 self._zk_data = {} # Data that we read back from ZK
719 # Zuul internal flags (not stored in ZK so they are not 720 # Zuul internal flags (not stored in ZK so they are not
@@ -721,18 +722,32 @@ class NodeRequest(object):
721 self.failed = False 722 self.failed = False
722 self.canceled = False 723 self.canceled = False
723 724
724 @property 725 def _getPausedParent(self):
725 def priority(self):
726 precedence_adjustment = 0
727 if self.build_set: 726 if self.build_set:
728 precedence = self.build_set.item.pipeline.precedence
729 job_graph = self.build_set.item.job_graph 727 job_graph = self.build_set.item.job_graph
730 if job_graph: 728 if job_graph:
731 for parent in job_graph.getParentJobsRecursively( 729 for parent in job_graph.getParentJobsRecursively(
732 self.job.name): 730 self.job.name):
733 build = self.build_set.getBuild(parent.name) 731 build = self.build_set.getBuild(parent.name)
734 if build.paused: 732 if build.paused:
735 precedence_adjustment = -1 733 return build
734 return None
735
736 def _getPausedParentProvider(self):
737 build = self._getPausedParent()
738 if build:
739 nodeset = self.build_set.getJobNodeSet(build.job.name)
740 if nodeset and nodeset.nodes:
741 return list(nodeset.nodes.values())[0].provider
742 return None
743
744 @property
745 def priority(self):
746 precedence_adjustment = 0
747 if self.build_set:
748 precedence = self.build_set.item.pipeline.precedence
749 if self._getPausedParent():
750 precedence_adjustment = -1
736 else: 751 else:
737 precedence = PRECEDENCE_NORMAL 752 precedence = PRECEDENCE_NORMAL
738 initial_precedence = PRIORITY_MAP[precedence] 753 initial_precedence = PRIORITY_MAP[precedence]
@@ -764,6 +779,7 @@ class NodeRequest(object):
764 d.setdefault('node_types', nodes) 779 d.setdefault('node_types', nodes)
765 d.setdefault('requestor', self.requestor) 780 d.setdefault('requestor', self.requestor)
766 d.setdefault('created_time', self.created_time) 781 d.setdefault('created_time', self.created_time)
782 d.setdefault('provider', self.provider)
767 # We might change these 783 # We might change these
768 d['state'] = self.state 784 d['state'] = self.state
769 d['state_time'] = self.state_time 785 d['state_time'] = self.state_time