Ensure correct re-enqueue on changing gate queue

When the queue for a project is changed during reconfiguration the
dependent pipeline manager was using the queue of the item
ahead in the old queue.

This lead to items ending up in the wrong queues and caused the
following exception in the run handler:

2019-11-28 13:33:47,313 zuul.Scheduler  ERROR  Exception in run handler:
Traceback (most recent call last):
  File "/tmp/zuul/zuul/scheduler.py", line 1145, in run
    while (pipeline.manager.processQueue() and
  File "/tmp/zuul/zuul/manager/__init__.py", line 914, in processQueue
    item, nnfi)
  File "/tmp/zuul/zuul/manager/__init__.py", line 898, in _processOneItem
    priority = item.getNodePriority()
  File "/tmp/zuul/zuul/model.py", line 2684, in getNodePriority
    return self.pipeline.manager.getNodePriority(self)
  File "/tmp/zuul/zuul/manager/dependent.py", line 101, in getNodePriority
    return items.index(item)
ValueError: <QueueItem 0x7f02583af4e0 for <Change 0x7f02583a9cf8 org/project2 2,1> in gate> is not in list

The issue is fixed, by ignoring the given existing queue in the
dependent pipeline manager, since it's always possible to get the
correct queue from the pipeline itself.

Change-Id: Ia5b1b58377e4420b9ab1440c0b9f67cb15967263
This commit is contained in:
Simon Westphahl
2019-11-28 14:45:32 +01:00
parent 25ac3feb28
commit 8eec9e3bcb
3 changed files with 125 additions and 2 deletions

View File

@@ -78,8 +78,9 @@ class DependentPipelineManager(PipelineManager):
def getChangeQueue(self, change, event, existing=None):
log = get_annotated_logger(self.log, event)
if existing:
return StaticChangeQueueContextManager(existing)
# Ignore the existing queue, since we can always get the correct queue
# from the pipeline. This avoids enqueuing changes in a wrong queue
# e.g. during re-configuration.
queue = self.pipeline.getQueue(change.project)
if queue:
return StaticChangeQueueContextManager(queue)