| From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| From: Tristan Cacqueray <tdecacqu@redhat.com> |
| Date: Mon, 14 May 2018 07:31:50 +0000 |
| Subject: [PATCH] gerrit: add support for report only connection |
| |
| A Zuul scheduler used by multiple third party CIs for a single gerrit may |
| share a single events stream and uses report only connections per account. |
| This change adds a report_only gerrit connection option to disable the |
| GerritWatcher thread. |
| |
| A third party CI reporting using 2 gerrit accounts may reduce the merger |
| load by 2 when using this option. |
| |
| Change-Id: I7d9d532f1200c29b30e2f75b4add760dd6d7e8d4 |
| --- |
| doc/source/admin/drivers/gerrit.rst | 6 ++++++ |
| zuul/driver/gerrit/gerritconnection.py | 10 +++++++--- |
| zuul/driver/gerrit/gerrittrigger.py | 7 +++++++ |
| 3 files changed, 20 insertions(+), 3 deletions(-) |
| |
| diff --git a/doc/source/admin/drivers/gerrit.rst b/doc/source/admin/drivers/gerrit.rst |
| index 5433df3..30571af 100644 |
| --- a/doc/source/admin/drivers/gerrit.rst |
| +++ b/doc/source/admin/drivers/gerrit.rst |
| @@ -123,6 +123,12 @@ The supported options in ``zuul.conf`` connections are: |
| When using a self-signed certificate, this may be set to |
| ``false`` to disable SSL certificate verification. |
| |
| + .. attr:: report_only |
| + :default: False |
| + |
| + Disable the gerrit events stream watcher. |
| + |
| + |
| Trigger Configuration |
| --------------------- |
| |
| diff --git a/zuul/driver/gerrit/gerritconnection.py b/zuul/driver/gerrit/gerritconnection.py |
| index 1c41730..835844e 100644 |
| --- a/zuul/driver/gerrit/gerritconnection.py |
| +++ b/zuul/driver/gerrit/gerritconnection.py |
| @@ -324,6 +324,9 @@ class GerritConnection(BaseConnection): |
| self.port = int(self.connection_config.get('port', 29418)) |
| self.keyfile = self.connection_config.get('sshkey', None) |
| self.keepalive = int(self.connection_config.get('keepalive', 60)) |
| + self.report_only = self.connection_config.get('report_only', False) |
| + if self.report_only not in ("True", "true"): |
| + self.report_only = False |
| self.watcher_thread = None |
| self.event_queue = queue.Queue() |
| self.client = None |
| @@ -1076,9 +1079,10 @@ class GerritConnection(BaseConnection): |
| sha=sha) |
| |
| def onLoad(self): |
| - self.log.debug("Starting Gerrit Connection/Watchers") |
| - self._start_watcher_thread() |
| - self._start_event_connector() |
| + if not self.report_only: |
| + self.log.debug("Starting Gerrit Connection/Watchers") |
| + self._start_watcher_thread() |
| + self._start_event_connector() |
| |
| def onStop(self): |
| self.log.debug("Stopping Gerrit Connection/Watchers") |
| diff --git a/zuul/driver/gerrit/gerrittrigger.py b/zuul/driver/gerrit/gerrittrigger.py |
| index 67608ad..83a2ee8 100644 |
| --- a/zuul/driver/gerrit/gerrittrigger.py |
| +++ b/zuul/driver/gerrit/gerrittrigger.py |
| @@ -17,12 +17,19 @@ import voluptuous as v |
| from zuul.trigger import BaseTrigger |
| from zuul.driver.gerrit.gerritmodel import GerritEventFilter |
| from zuul.driver.util import scalar_or_list, to_list |
| +from zuul.configloader import ConfigurationSyntaxError |
| |
| |
| class GerritTrigger(BaseTrigger): |
| name = 'gerrit' |
| log = logging.getLogger("zuul.GerritTrigger") |
| |
| + def __init__(self, driver, connection, config): |
| + if connection.report_only: |
| + raise ConfigurationSyntaxError( |
| + "Connection doesn't support trigger") |
| + super().__init__(driver, connection, config) |
| + |
| def getEventFilters(self, trigger_conf): |
| efilters = [] |
| for trigger in to_list(trigger_conf): |
| -- |
| 1.8.3.1 |
| |