diff --git a/artbotlib/buildinfo.py b/artbotlib/buildinfo.py index 78f7919..8a3f59e 100644 --- a/artbotlib/buildinfo.py +++ b/artbotlib/buildinfo.py @@ -7,6 +7,9 @@ from enum import Enum import koji +from artcommonlib import redis +from pyartcd.constants import JENKINS_UI_URL +from pyartcd.locks import Lock, Keys from . import util, constants, exectools, variables from .rhcos import rhcos_build_urls @@ -249,3 +252,30 @@ def alert_on_build_complete(so, user_id, build_id): finally: variables.active_slack_objects.remove(so) + + +def mass_rebuild_status(so): + output = [] + + async def check_active(): + # Check for active mass rebuild + job_path = await redis.get_value(Lock.MASS_REBUILD.value) + if not job_path: + output.append('No mass rebuild currently running') + else: + output.append(f':construction: Mass rebuild actively running at {JENKINS_UI_URL}/{job_path}') + + async def check_enqueued(): + # Check for enqueued mass rebuilds + result = await redis.call('zrange', Keys.MASS_REBUILD_QUEUE.value, 0, -1, desc=True) + if not result: + output.append('No mass rebuild currently enqueued') + else: + output.append(f':hourglass: Mass rebuilds currently waiting in the queue: {", ".join(result)}') + + tasks = [check_active(), check_enqueued()] + loop = asyncio.new_event_loop() + asyncio.set_event_loop(loop) + loop.run_until_complete(asyncio.gather(*tasks)) + + so.say('\n'.join(output)) diff --git a/artbotlib/help.py b/artbotlib/help.py index 7635af0..3c8a084 100644 --- a/artbotlib/help.py +++ b/artbotlib/help.py @@ -36,6 +36,7 @@ def show_help(so): * pr info `GitHub PR URL` [component `name`] in `major.minor` [for `arch`] * (go|golang) version (for|of) `nvr' * timestamp (for|of) brew event `brew-event` +* mass rebuild status _*misc:*_ * How can I get ART to build a new image? diff --git a/artbotlib/regex_mapping.py b/artbotlib/regex_mapping.py index 9a58e02..a4251ab 100644 --- a/artbotlib/regex_mapping.py +++ b/artbotlib/regex_mapping.py @@ -2,7 +2,7 @@ import re from artbotlib import brew_list, elliott, brew -from artbotlib.buildinfo import buildinfo_for_release, alert_on_build_complete +from artbotlib.buildinfo import buildinfo_for_release, alert_on_build_complete, mass_rebuild_status from artbotlib.pr_status import pr_status from artbotlib.taskinfo import alert_on_task_complete from artbotlib.constants import PROW_BASE_URL @@ -231,6 +231,12 @@ def map_command_to_regex(so, plain_text, user_id): "function": brew.get_event_ts, "example": "timestamp for brew event 55331468" }, + { + "regex": "^mass rebuild status$", + "flag": re.I, + "function": mass_rebuild_status, + "example": "mass rebuild status" + }, # ART advisory info: { diff --git a/requirements.txt b/requirements.txt index 467de2e..135dfd2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,6 @@ PyYAML slack_bolt==1.15.1 pip_system_certs fuzzywuzzy -python-Levenshtein \ No newline at end of file +python-Levenshtein +artcommon @ git+https://github.com/openshift-eng/art-tools.git@main#subdirectory=artcommon +pyartcd @ git+https://github.com/openshift-eng/art-tools.git@main#subdirectory=pyartcd