summaryrefslogtreecommitdiff
path: root/zuul/connection
diff options
context:
space:
mode:
authorFelix Edel <felix.edel@bmw.de>2021-11-05 09:48:52 +0100
committerSimon Westphahl <simon.westphahl@bmw.de>2021-11-09 09:17:43 +0100
commit2c900c2c4a3ab65c31c5cba3c379f6675c4169d9 (patch)
treee7d4c3d610e6da95447241472d60bbbe0d6692a6 /zuul/connection
parent783990597237a480b726635e051c625e810d732f (diff)
downloadzuul-2c900c2c4a3ab65c31c5cba3c379f6675c4169d9.tar.gz
Split up registerScheduler() and onLoad() methods
This is an early preparation step for removing the RPC calls between zuul-web and the scheduler. In order to do so we must initialize the ConfigLoader in zuul-web which requires all connections to be available. Therefore, this change ensures that we can load all connections in zuul-web without providing a scheduler instance. To avoid unnecessary traffic from a zuul-web instance the onLoad() method initializes the change cache only if a scheduler instance is available on the connection. Change-Id: I3c1d2995e81e17763ae3454076ab2f5ce87ab1fc
Diffstat (limited to 'zuul/connection')
-rw-r--r--zuul/connection/__init__.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/zuul/connection/__init__.py b/zuul/connection/__init__.py
index 5a69dbb55..03eaee300 100644
--- a/zuul/connection/__init__.py
+++ b/zuul/connection/__init__.py
@@ -68,7 +68,7 @@ class BaseConnection(object, metaclass=abc.ABCMeta):
except Exception:
self.log.exception("Exception reporting event stats")
- def onLoad(self):
+ def onLoad(self, zk_client):
pass
def onStop(self):
@@ -136,6 +136,7 @@ class ZKBranchCacheMixin:
# Expected to be defined by the connection and to be an instance
# of BranchCache
_branch_cache = None
+ read_only = False
@abc.abstractmethod
def isBranchProtected(self, project_name: str, branch_name: str,
@@ -243,6 +244,10 @@ class ZKBranchCacheMixin:
if branches is not None:
return sorted(branches)
+ if self.read_only:
+ raise RuntimeError(
+ "Won't fetch project branches as read-only is set.")
+
# We need to perform a query
branches = self._fetchProjectBranches(project, exclude_unprotected)
self.log.info("Got branches for %s" % project.name)