From 4139c901d82bba068f42d5862f4d5b397faaf221 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Wed, 2 Nov 2016 20:21:47 +0100 Subject: [PATCH] Check number of meetbot channels Check that we do not have more than 120 channels setup for meetbot. Change-Id: Ib5b948c68691ec959d4826a2cdf28f3e50631e60 --- hiera/common.yaml | 2 ++ test-requirements.txt | 1 + tools/irc_checks.py | 51 +++++++++++++++++++++++++++++++++++++++++++ tox.ini | 1 + 4 files changed, 55 insertions(+) create mode 100644 tools/irc_checks.py diff --git a/hiera/common.yaml b/hiera/common.yaml index a2f001cc85..b3f24b6dac 100644 --- a/hiera/common.yaml +++ b/hiera/common.yaml @@ -122,6 +122,8 @@ statusbot_channels: - syscompass - tacker - tripleo +# Note that freenode only allows a single account to connect to 120 +# channel. meetbot_channels: - '#ara' - '#cloudkitty' diff --git a/test-requirements.txt b/test-requirements.txt index 4d785cf785..cbe1615b7b 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,3 +2,4 @@ hacking>=0.5.6,<0.8 Sphinx>=1.1.2,<1.2 oslosphinx bashate>=0.2 +PyYAML diff --git a/tools/irc_checks.py b/tools/irc_checks.py new file mode 100644 index 0000000000..21686a86fe --- /dev/null +++ b/tools/irc_checks.py @@ -0,0 +1,51 @@ +#! /usr/bin/env python + +# Copyright 2016 SUSE Linux GmbH +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +import yaml + + +def check_meetbot(): + + errors = False + + config = yaml.load(open('hiera/common.yaml', 'r')) + meetbot_channels = config['meetbot_channels'] + # IRC has a limit of 120 channels that we unfortunately hit with + # gerritbot. If we try connect to more, it will not connect to + # all. Avoid this situation. + if len(meetbot_channels) > 120: + print("ERROR: bots can only handle 120 channels but found %s." + % len(meetbot_channels)) + print("Sorry, we're at our limit and cannot add more for now.") + print("If you want to help set up another instance contact the " + "infra team in #openstack-infra.\n") + errors = True + + return errors + + +def main(): + errors = check_meetbot() + + if errors: + print("Found errors in channel configuration!") + else: + print("No errors found in channel configuration!") + return errors + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tox.ini b/tox.ini index 3af4ec5ddd..5c5e284c5e 100644 --- a/tox.ini +++ b/tox.ini @@ -13,6 +13,7 @@ commands = flake8 {toxinidir}/tools/run-bashate.sh python {toxinidir}/tools/sorted_modules_env.py {toxinidir}/modules.env + python {toxinidir}/tools/irc_checks.py [testenv:venv] commands = {posargs}