Cache branches in connections/sources

The current attempt to caches branches is ineffective -- we
query the list of branches during every tenant reconfiguration.

The list of branches for a project is really global information;
we might cache it on the Abide, however, drivers may need to filter
that list based on tenant configuration (eg, github protected
branches).  To accomodate that, just allow/expect the drivers to
perform their own caching of branches, and to generally keep
the list up to date (or at least invalidate their caches) by
observing branch create/delete events.

A full reconfiguration instructs the connections to clear their
caches so that we perform a full query.  That way, an operator
can correct from a situation where the cache is invalid.

Change-Id: I3bd0cda5875dd21368e384e3704a61ebb5dcedfa
This commit is contained in:
James E. Blair
2018-08-08 10:26:27 -07:00
parent 6479892b9c
commit a48c9101c6
10 changed files with 188 additions and 27 deletions

View File

@@ -68,12 +68,25 @@ class BaseConnection(object, metaclass=abc.ABCMeta):
def registerScheduler(self, sched):
self.sched = sched
def clearBranchCache(self):
"""Clear the branch cache for this connection.
This is called immediately prior to performing a full
reconfiguration. The branch cache should be cleared so that a
full reconfiguration can be used to correct any errors in
cached data.
"""
pass
def maintainCache(self, relevant):
"""Make cache contain relevant changes.
This lets the user supply a list of change objects that are
still in use. Anything in our cache that isn't in the supplied
list should be safe to remove from the cache."""
pass
def getWebController(self, zuul_web):
"""Return a cherrypy web controller to register with zuul-web.