Support external cross-project dependencies in ui

When a cross project dependency includes a change from a project
that is not known to zuul, the zuul ui stops updating and the following
stack trace is seen in the zuul logs on every ui update.

2015-06-12 12:42:50,079 ERROR zuul.WebApp: Exception formatting status:
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/zuul/webapp.py", line 104, in app
    self.cache = self.scheduler.formatStatusJSON()
  File "/usr/local/lib/python2.7/dist-packages/zuul/scheduler.py", line 974, in formatStatusJSON
    pipelines.append(pipeline.formatStatusJSON())
  File "/usr/local/lib/python2.7/dist-packages/zuul/model.py", line 276, in formatStatusJSON
    j_changes.append(e.formatJSON())
  File "/usr/local/lib/python2.7/dist-packages/zuul/model.py", line 738, in formatJSON
    ret['project'] = changeish.project.name
AttributeError: 'NoneType' object has no attribute 'name'

Quick fix to stop the bleeding is to mark the project as "unknown".
An alternative is to simply leave it blank.
A more permanent fix is still needed (e.g. look up name of project).

Change-Id: I97299ed2089ad005afaf7494168f4ee74f799e82
This commit is contained in:
Ramy Asselin 2015-06-12 14:06:34 -07:00
parent 7fca9c1cc6
commit 07cc33c85c
1 changed files with 7 additions and 1 deletions

View File

@ -735,7 +735,13 @@ class QueueItem(object):
ret['items_behind'] = [i.change._id() for i in self.items_behind]
ret['failing_reasons'] = self.current_build_set.failing_reasons
ret['zuul_ref'] = self.current_build_set.ref
ret['project'] = changeish.project.name
if changeish.project:
ret['project'] = changeish.project.name
else:
# For cross-project dependencies with the depends-on
# project not known to zuul, the project is None
# Set it to a static value
ret['project'] = "Unknown Project"
ret['enqueue_time'] = int(self.enqueue_time * 1000)
ret['jobs'] = []
if hasattr(changeish, 'owner'):