Skip to content

Commit

Permalink
Merge pull request #171 from locriandev/mass-rebuild-status
Browse files Browse the repository at this point in the history
Add mass rebuild status functionality
  • Loading branch information
locriandev authored Mar 13, 2024
2 parents 4410d00 + a7fae06 commit b0e8aa0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
30 changes: 30 additions & 0 deletions artbotlib/buildinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
1 change: 1 addition & 0 deletions artbotlib/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
8 changes: 7 additions & 1 deletion artbotlib/regex_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
{
Expand Down
4 changes: 3 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ PyYAML
slack_bolt==1.15.1
pip_system_certs
fuzzywuzzy
python-Levenshtein
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

0 comments on commit b0e8aa0

Please sign in to comment.