From bc79f6e66fc90773e86e6c3a78b7b4549d1d3466 Mon Sep 17 00:00:00 2001 From: Jason Tibbitts Date: Jul 13 2018 21:44:03 +0000 Subject: Make find_failures.py show all maintainer Previously the find_failures.py would use only the first result provided by pagure, which caused some package maintainers to fail to notice problems from the mass rebuild. In addition, the script would make one API call per failed package, which was quite slow. This patch converts the script to show list packages under each maintainer, and to use the data which is cached (and updated hourly) for just this use case. Instead of this, used the data which is cached for the express this, and list packages under each maintainer. For me, the runtime drops from 2 minutes 41 seconds to 18 seconds. The resulting list is of course a bit longer and many packages are listed under multiple usernames but the end result looks much the same. Signed-off-by: Jason Tibbitts --- diff --git a/scripts/find_failures.py b/scripts/find_failures.py index b90e1ce..1252ccc 100755 --- a/scripts/find_failures.py +++ b/scripts/find_failures.py @@ -29,6 +29,7 @@ desttag = 'f29' # Tag where fixed builds go epoch = '2018-07-12 17:00:00.000000' # Date to check for failures from failures = {} # dict of owners to lists of packages that failed. failed = [] # raw list of failed packages +ownerdataurl = 'https://src.fedoraproject.org/extras/pagure_owner_alias.json' def retry_session(): @@ -46,6 +47,11 @@ def retry_session(): return session +def get_owner_data(): + owners = requests.get(ownerdataurl).json() + return owners + + def get_failed_builds(kojisession, epoch, buildtag, desttag): """This function returns list of all failed builds since epoch within buildtag that were not rebuilt succesfully in desttag @@ -90,19 +96,8 @@ def get_failed_builds(kojisession, epoch, buildtag, desttag): taskinfos = kojisession.multiCall() for build, [taskinfo] in zip(failbuilds, taskinfos): build['taskinfo'] = taskinfo - # Get owners of the packages with failures - http = retry_session() - for build in failbuilds: - build['package_owner'] = get_package_owner(http, build['package_name']) return failbuilds -def get_package_owner(http, package): - url = 'https://src.fedoraproject.org/api/0/rpms/{0}'.format(package) - response = http.get(url, timeout=30) - if not bool(response): - return 'releng' - return response.json()['access_users']['owner'][0] - if __name__ == '__main__': # Create a koji session @@ -110,17 +105,18 @@ if __name__ == '__main__': failbuilds = get_failed_builds(kojisession, epoch, buildtag, desttag) + owners = get_owner_data() # Generate the dict with the failures and urls for build in failbuilds: if not build['taskinfo']['request'][1] == buildtag: continue taskurl = 'https://koji.fedoraproject.org/koji/taskinfo?taskID=%s' % build['task_id'] - owner = build['package_owner'] pkg = build['package_name'] - if not pkg in failed: + for owner in owners['rpms'][pkg]: + failures.setdefault(owner, {})[pkg] = taskurl + if pkg not in failed: failed.append(pkg) - failures.setdefault(owner, {})[pkg] = taskurl now = datetime.datetime.now() now_str = "%s UTC" % str(now.utcnow())