Remove scheduler.getProject
Note that this removes the vestigal foreign project code. That
feature has not currently been reworked into v3 and may need to
be in the future. It the mean time, in order to better support
recording job provenance (ie, what repo a job was defined in)
we need to ensure that Projects are globally unique entities.
With this patch, Projects are only ever created by source objects.
Change-Id: I094cb6f82e06317ee08862757cf306e83576c47d
diff --git a/zuul/model.py b/zuul/model.py
index fc67e67..e3dea02 100644
--- a/zuul/model.py
+++ b/zuul/model.py
@@ -461,12 +461,18 @@
class Project(object):
+ # NOTE: Projects should only be instantiated via a Source object
+ # so that they are associated with and cached by their Connection.
+ # This makes a Project instance a unique identifier for a given
+ # project from a given source.
+
def __init__(self, name, foreign=False):
self.name = name
self.merge_mode = MERGER_MERGE_RESOLVE
# foreign projects are those referenced in dependencies
# of layout projects, this should matter
# when deciding whether to enqueue their changes
+ # TODOv3 (jeblair): re-add support for foreign projects if needed
self.foreign = foreign
self.unparsed_config = None
diff --git a/zuul/scheduler.py b/zuul/scheduler.py
index a34be22..eca7c54 100644
--- a/zuul/scheduler.py
+++ b/zuul/scheduler.py
@@ -28,7 +28,6 @@
from zuul import configloader
from zuul import model
-from zuul.model import Project
from zuul import exceptions
from zuul import version as zuul_version
@@ -285,20 +284,6 @@
def setNodepool(self, nodepool):
self.nodepool = nodepool
- def getProject(self, name, create_foreign=False):
- self.layout_lock.acquire()
- p = None
- try:
- p = self.layout.projects.get(name)
- if p is None and create_foreign:
- # TODOv3(jeblair): fix
- self.log.info("Registering foreign project: %s" % name)
- p = Project(name, foreign=True)
- self.layout.projects[name] = p
- finally:
- self.layout_lock.release()
- return p
-
def addEvent(self, event):
self.log.debug("Adding trigger event: %s" % event)
try: