#6974 find_failures.py - get owner from dist-git, instead of koji.
Merged 6 years ago by ausil. Opened 6 years ago by ralph.

file modified
+30 -11
@@ -9,12 +9,18 @@ 

  #

  # Authors:

  #     Jesse Keating <jkeating@redhat.com>

+ #     Ralph Bean <rbean@redhat.com>

  #

  

  import koji

  import operator

  import datetime

  

+ import requests

+ from requests.adapters import HTTPAdapter

+ from requests.packages.urllib3.util.retry import Retry

+ 

+ 

  # Set some variables

  # Some of these could arguably be passed in as args.

  buildtag = 'f27-rebuild' # tag to check
@@ -24,6 +30,21 @@ 

  failed = [] # raw list of failed packages

  

  

+ def retry_session():

+     session = requests.Session()

+     retry = Retry(

+         total=5,

+         read=5,

+         connect=5,

+         backoff_factor=0.3,

+         status_forcelist=(500, 502, 504),

+     )

+     adapter = HTTPAdapter(max_retries=retry)

+     session.mount('http://', adapter)

+     session.mount('https://', adapter)

+     return session

+ 

+ 

  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
@@ -69,20 +90,18 @@ 

      for build, [taskinfo] in zip(failbuilds, taskinfos):

          build['taskinfo'] = taskinfo

      # Get owners of the packages with failures

-     kojisession.multicall = True

+     http = retry_session()

      for build in failbuilds:

-         kojisession.listPackages(tagID=buildtag,

-                                  pkgID=build['package_id'],

-                                  inherited=True)

-     pkginfo = kojisession.multiCall()

- 

-     for build, [pkg] in zip(failbuilds, pkginfo):

-         if len(pkg) > 0:

-             build['package_owner'] = pkg[0]['owner_name']

-         else:

-             continue

+         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

I thought the plan was to fix koji owner sync instead of changing every script that uses koji?

I thought the plan was to fix koji owner sync instead of changing every script that uses koji?

I can't promise that anytime soon. Do we have a rough list of scripts that use koji ownership so we can evaluate which route would be more practical to take? The discussion from irc earlier in the week arrived at quick consensus that almost nothing uses koji ownership data.

Commit 4c0707b fixes this pull-request

Pull-Request has been merged by dennis@ausil.us

6 years ago

Pull-Request has been merged by ausil

6 years ago
Metadata