Browse Source

Request dependent job nodes from paused parent provider

When requesting nodes for a dependent job whose parent is paused,
request nodes from the same provider as the paused parent.

Change-Id: Iaa1ec5f3254ac26e6133a98dbda460a09e95d986
Depends-On: https://review.openstack.org/639418
tags/3.6.0
James E. Blair 2 months ago
parent
commit
4fc2b345b4
2 changed files with 24 additions and 6 deletions
  1. 2
    0
      tests/unit/test_v3.py
  2. 22
    6
      zuul/model.py

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

@@ -5120,6 +5120,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
5120 5120
         reqs = self.fake_nodepool.getNodeRequests()
5121 5121
         self.assertEqual(len(reqs), 1)
5122 5122
         self.assertEqual(reqs[0]['_oid'], '200-0000000000')
5123
+        self.assertEqual(reqs[0]['provider'], None)
5123 5124
 
5124 5125
         self.fake_nodepool.unpause()
5125 5126
         self.waitUntilSettled()
@@ -5134,6 +5135,7 @@ class TestJobPausePriority(AnsibleZuulTestCase):
5134 5135
 
5135 5136
         self.assertEqual(len(reqs), 1)
5136 5137
         self.assertEqual(reqs[0]['_oid'], '199-0000000001')
5138
+        self.assertEqual(reqs[0]['provider'], 'test-provider')
5137 5139
 
5138 5140
         self.fake_nodepool.unpause()
5139 5141
         self.waitUntilSettled()

+ 22
- 6
zuul/model.py View File

@@ -714,6 +714,7 @@ class NodeRequest(object):
714 714
         self.stat = None
715 715
         self.uid = uuid4().hex
716 716
         self.relative_priority = relative_priority
717
+        self.provider = self._getPausedParentProvider()
717 718
         self.id = None
718 719
         self._zk_data = {}  # Data that we read back from ZK
719 720
         # Zuul internal flags (not stored in ZK so they are not
@@ -721,18 +722,32 @@ class NodeRequest(object):
721 722
         self.failed = False
722 723
         self.canceled = False
723 724
 
724
-    @property
725
-    def priority(self):
726
-        precedence_adjustment = 0
725
+    def _getPausedParent(self):
727 726
         if self.build_set:
728
-            precedence = self.build_set.item.pipeline.precedence
729 727
             job_graph = self.build_set.item.job_graph
730 728
             if job_graph:
731 729
                 for parent in job_graph.getParentJobsRecursively(
732
-                    self.job.name):
730
+                        self.job.name):
733 731
                     build = self.build_set.getBuild(parent.name)
734 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 751
         else:
737 752
             precedence = PRECEDENCE_NORMAL
738 753
         initial_precedence = PRIORITY_MAP[precedence]
@@ -764,6 +779,7 @@ class NodeRequest(object):
764 779
         d.setdefault('node_types', nodes)
765 780
         d.setdefault('requestor', self.requestor)
766 781
         d.setdefault('created_time', self.created_time)
782
+        d.setdefault('provider', self.provider)
767 783
         # We might change these
768 784
         d['state'] = self.state
769 785
         d['state_time'] = self.state_time

Loading…
Cancel
Save