#1755 drop buildMap API call
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue1721  into  master

file modified
+15 -13
@@ -2635,19 +2635,21 @@ 

      data = session.untaggedBuilds(**opts)

      if options.show_references:

          print("(Showing build references)")

-         refs = {}

-         refs2 = {} #reverse map

-         for x in session.buildMap():

-             refs.setdefault(x['used'], {}).setdefault(x['built'], 1)

-             refs2.setdefault(x['built'], {}).setdefault(x['used'], 1)

-         #XXX - need to ignore refs to unreferenced builds

-         for x in data:

-             builds = refs.get(x['id'])

-             if builds:

-                 x['refs'] = "%s" % builds

-             else:

-                 x['refs'] = ''

-         #data = [x for x in data if x['id'] not in refs)]

+         references = {}

+         with session.multicall(strict=True, batch=10000) as m:

+             for build in data:

+                 references[build['id']] = m.buildReferences(build['id'])

+ 

+         for build in data:

+             refs = references[build['id']].result

+             r = []

+             if refs.get('rpms'):

+                 r.append("rpms: %s" % refs['rpms'])

+             if refs.get('component_of'):

+                 r.append("images/archives: %" % refs['component_of'])

+             if refs.get('archives'):

+                 r.append("archives buildroots: %s" % refs['archives'])

+             build['refs'] = ', '.join(r)

      if options.paths:

          for x in data:

              x['path'] = pathinfo.build(x)

file modified
-18
@@ -7543,23 +7543,6 @@ 

                             opts=queryOpts)

      return query.iterate()

  

- def build_map():

-     """Map which builds were used in the buildroots of other builds

- 

-     To be used for garbage collection

-     """

-     # find rpms whose buildroots we were in

-     st_complete = koji.BUILD_STATES['COMPLETE']

-     fields = ('used', 'built')

-     q = """SELECT DISTINCT used.id, built.id

-     FROM buildroot_listing

-         JOIN rpminfo AS r_used ON r_used.id = buildroot_listing.rpm_id

-         JOIN rpminfo AS r_built ON r_built.buildroot_id = buildroot_listing.buildroot_id

-         JOIN build AS used ON used.id = r_used.build_id

-         JOIN build AS built ON built.id = r_built.build_id

-     WHERE built.state = %(st_complete)i AND used.state =%(st_complete)i"""

-     return _multiRow(q, locals(), fields)

- 

  

  def build_references(build_id, limit=None, lazy=False):

      """Returns references to a build
@@ -9987,7 +9970,6 @@ 

      tagHistory = staticmethod(tag_history)

      queryHistory = staticmethod(query_history)

  

-     buildMap = staticmethod(build_map)

      deleteBuild = staticmethod(delete_build)

      def buildReferences(self, build, limit=None, lazy=False):

          return build_references(get_build(build, strict=True)['id'], limit, lazy)

It was originally designed for garbage-collector, but it is now using
buildReferences call which supersedes this one.

Fixes: https://pagure.io/koji/issue/1721

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

2 years ago

deleting code :tada: :

Wait, after these changes, list-untagged with --show-references is not working:

koji list-untagged --show-references
GenericError: Invalid method: buildMap\n(Showing build references)\n'

Ah, it is used in CLI - I'll check, if we can replace it with buildReferences. If not, I'll drop an issue as invalid.

rebased onto a35f864

2 years ago

I believe, nobody is using as it is (CLI) for real-world deployment, it would probably die on memory issues. So, I've replaced it with similar values from buildReferences.

Commit 46d7fa7 fixes this pull-request

Pull-Request has been merged by tkopecek

2 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

2 years ago