Don't store change_queue in QueueItem
This was causing a problem with window sizes on reconfiguration because
the ChangeQueue objects were persisting across the reload via the local
reference inside of QueueItem. Instead of adding more complexity to
reset those on reEnqueue, drop that and instead find the change queue
via the change's project when needed.
Also fix the fact that the QueueItem pipeline reference was not being
updated (it was set to None before a re-enqueue but then not set to
the new pipeline value).
Change-Id: I7f7050bfec985972ad7a1bc89da02d7b0753b798
diff --git a/zuul/model.py b/zuul/model.py
index 904e8f3..d6fc1f0 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -412,12 +412,13 @@
self._jobs |= set(self.pipeline.getJobTree(project).getJobs())
def enqueueChange(self, change):
- item = QueueItem(self, self.pipeline, change)
+ item = QueueItem(self.pipeline, change)
self.enqueueItem(item)
item.enqueue_time = time.time()
return item
def enqueueItem(self, item):
+ item.pipeline = self.pipeline
if self.dependent and self.queue:
item.item_ahead = self.queue[-1]
item.item_ahead.items_behind.append(item)
@@ -659,8 +660,7 @@
class QueueItem(object):
"""A changish inside of a Pipeline queue"""
- def __init__(self, change_queue, pipeline, change):
- self.change_queue = change_queue
+ def __init__(self, pipeline, change):
self.pipeline = pipeline
self.change = change # a changeish
self.build_sets = []
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index 7ca1e35..5a085e2 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -1255,19 +1255,18 @@
item.change.branch)
self.log.info("Reported change %s status: all-succeeded: %s, "
"merged: %s" % (item.change, succeeded, merged))
+ change_queue = self.pipeline.getQueue(item.change.project)
if not (succeeded and merged):
self.log.debug("Reported change %s failed tests or failed "
"to merge" % (item.change))
- item.change_queue.decreaseWindowSize()
+ change_queue.decreaseWindowSize()
self.log.debug("%s window size decreased to %s" %
- (item.change_queue,
- item.change_queue.window))
+ (change_queue, change_queue.window))
raise MergeFailure("Change %s failed to merge" % item.change)
else:
- item.change_queue.increaseWindowSize()
+ change_queue.increaseWindowSize()
self.log.debug("%s window size increased to %s" %
- (item.change_queue,
- item.change_queue.window))
+ (change_queue, change_queue.window))
def _reportItem(self, item):
if item.reported: