#981 Store the component's build ID and use that to identify the build when acting on a tag message
Merged 5 years ago by mprahl. Opened 5 years ago by mprahl.

file modified
+1
@@ -13,6 +13,7 @@ 

      createrepo_c \

      fedmsg \

      fedmsg-hub \

+     gcc \

      git \

      kobo \

      kobo-rpmlib \

@@ -610,6 +610,7 @@ 

          component_build.state = koji.BUILD_STATES['COMPLETE']

          component_build.nvr = build['nvr']

          component_build.task_id = build['task_id']

+         component_build.build_id = build['build_id']

          component_build.state_reason = 'Found existing build'

          nvr_dict = kobo.rpmlib.parse_nvr(component_build.nvr)

          # Trigger a completed build message
@@ -630,7 +631,8 @@ 

              log.info('The build being skipped isn\'t tagged in the "{0}" tag. Will send a '

                       'message to the tag handler'.format(tag))

              further_work.append(module_build_service.messaging.KojiTagChange(

-                 'recover_orphaned_artifact: fake message', tag, component_build.package))

+                 'recover_orphaned_artifact: fake message', tag, component_build.package,

+                 component_build.build_id))

          return further_work

  

      def build(self, artifact_name, source):

@@ -157,7 +157,8 @@ 

              elif category == 'buildsys' and event == 'tag':

                  tag = msg_inner_msg.get('tag')

                  artifact = msg_inner_msg.get('name')

-                 msg_obj = KojiTagChange(msg_id, tag, artifact)

+                 build_id = msg_inner_msg.get('build_id')

+                 msg_obj = KojiTagChange(msg_id, tag, artifact, build_id)

  

              elif category == 'mbs' and object == 'module' and \

                      subobject == 'state' and event == 'change':
@@ -209,10 +210,11 @@ 

      :param tag: the name of tag (e.g. module-123456789-build)

      :param artifact: the name of tagged artifact (e.g. module-build-macros)

      """

-     def __init__(self, msg_id, tag, artifact):

+     def __init__(self, msg_id, tag, artifact, build_id):

          super(KojiTagChange, self).__init__(msg_id)

          self.tag = tag

          self.artifact = artifact

+         self.build_id = build_id

  

  

  class KojiRepoChange(BaseMessage):

@@ -14,10 +14,12 @@ 

  

  

  def upgrade():

-     op.drop_column('module_builds', 'copr_project')

-     op.drop_column('module_builds', 'copr_owner')

+     with op.batch_alter_table('module_builds') as b:

+         b.drop_column('copr_project')

+         b.drop_column('copr_owner')

  

  

  def downgrade():

-     op.add_column('module_builds', sa.Column('copr_owner', sa.VARCHAR(), nullable=True))

-     op.add_column('module_builds', sa.Column('copr_project', sa.VARCHAR(), nullable=True))

+     with op.batch_alter_table('module_builds') as b:

+         b.add_column('copr_project', sa.VARCHAR(), nullable=True)

+         b.add_column('copr_owner', sa.VARCHAR(), nullable=True)

@@ -0,0 +1,24 @@ 

+ """Add the component build_id column

+ 

+ Revision ID: c702c2d26a8b

+ Revises: 9d5e6938588f

+ Create Date: 2018-08-03 15:28:38.493950

+ 

+ """

+ 

+ # revision identifiers, used by Alembic.

+ revision = 'c702c2d26a8b'

+ down_revision = '9d5e6938588f'

+ 

+ from alembic import op

+ import sqlalchemy as sa

+ 

+ 

+ def upgrade():

+     with op.batch_alter_table('component_builds') as b:

+         b.add_column(sa.Column('build_id', sa.Integer(), nullable=True))

+ 

+ 

+ def downgrade():

+     with op.batch_alter_table('component_builds') as b:

+         b.drop_column('build_id')

@@ -658,7 +658,8 @@ 

      scmurl = db.Column(db.String, nullable=False)

      # XXX: Consider making this a proper ENUM

      format = db.Column(db.String, nullable=False)

-     task_id = db.Column(db.Integer)  # This is the id of the build in koji

+     build_id = db.Column(db.Integer)  # This is the id of the build in Koji

+     task_id = db.Column(db.Integer)  # This is the id of the build task in Koji

      # This is the commit hash that component was built with

      ref = db.Column(db.String, nullable=True)

      # XXX: Consider making this a proper ENUM (or an int)
@@ -708,12 +709,18 @@ 

          return session.query(cls).filter_by(

              package=component_name, module_id=module_id).first()

  

+     @classmethod

+     def from_component_build_id(cls, session, build_id, module_id):

+         return session.query(cls).filter_by(

+             build_id=build_id, module_id=module_id).first()

+ 

      def state_trace(self, component_id):

          return ComponentBuildTrace.query.filter_by(

              component_id=component_id).order_by(ComponentBuildTrace.state_time).all()

  

      def json(self):

          retval = {

+             'build_id': self.build_id,

              'id': self.id,

              'package': self.package,

              'format': self.format,
@@ -758,8 +765,9 @@ 

          return json

  

      def __repr__(self):

-         return "<ComponentBuild %s, %r, state: %r, task_id: %r, batch: %r, state_reason: %s>" % (

-             self.package, self.module_id, self.state, self.task_id, self.batch, self.state_reason)

+         return ("<ComponentBuild %s, %r, state: %r, build_id: %r, task_id: %r, batch: %r, "

+                 "state_reason: %s>") % (self.package, self.module_id, self.state, self.build_id,

+                                         self.task_id, self.batch, self.state_reason)

  

  

  class ComponentBuildTrace(MBSBase):

@@ -62,6 +62,7 @@ 

      component_build.state = state

      component_build.nvr = nvr

      component_build.state_reason = state_reason

+     component_build.build_id = msg.build_id

      session.commit()

  

      parent = component_build.module_build

@@ -44,8 +44,8 @@ 

          return

  

      # Find tagged component.

-     component = models.ComponentBuild.from_component_name(

-         session, msg.artifact, module_build.id)

+     component = models.ComponentBuild.from_component_build_id(

+         session, msg.build_id, module_build.id)

      if not component:

          log.error("No component %s in module %r", msg.artifact, module_build)

          return

@@ -58,13 +58,14 @@ 

      component.state_reason = \

          'Reused component from previous module build'

      component.nvr = previous_component_build.nvr

+     component.build_id = previous_component_build.build_id

      nvr_dict = kobo.rpmlib.parse_nvr(component.nvr)

      # Add this message to further_work so that the reused

      # component will be tagged properly

      return [

          module_build_service.messaging.KojiBuildChange(

              msg_id='reuse_component: fake msg',

-             build_id=None,

+             build_id=component.build_id,

              task_id=component.task_id,

              build_new_state=previous_component_build.state,

              build_name=component.package,

file modified
+11
@@ -149,6 +149,7 @@ 

                  ('git://pkgs.domain.local/rpms/nginx?'

                   '#ga95886c8a443b36a9ce31abda1f9bed22f2f8c3')

              component_one_build_one.format = 'rpms'

+             component_one_build_one.build_id = 2345 + index

              component_one_build_one.task_id = 12312345 + index

              component_one_build_one.state = koji.BUILD_STATES['COMPLETE']

              component_one_build_one.nvr = 'nginx-1.10.1-2.{0}'.format(build_one_component_release)
@@ -163,6 +164,7 @@ 

                  ('/tmp/module_build_service-build-macrosWZUPeK/SRPMS/'

                   'module-build-macros-0.1-1.module_nginx_1_2.src.rpm')

              component_two_build_one.format = 'rpms'

+             component_two_build_one.build_id = 4356 + index

              component_two_build_one.task_id = 12312321 + index

              component_two_build_one.state = koji.BUILD_STATES['COMPLETE']

              component_two_build_one.nvr = \
@@ -200,6 +202,7 @@ 

              ('git://pkgs.domain.local/rpms/postgresql?'

               '#dc95586c4a443b26a9ce38abda1f9bed22f2f8c3')

          component_one_build_two.format = 'rpms'

+         component_one_build_two.build_id = 345345 + index

          component_one_build_two.task_id = 2433433 + index

          component_one_build_two.state = koji.BUILD_STATES['COMPLETE']

          component_one_build_two.nvr = 'postgresql-9.5.3-4.{0}'.format(build_two_component_release)
@@ -214,6 +217,7 @@ 

              ('/tmp/module_build_service-build-macrosWZUPeK/SRPMS/'

               'module-build-macros-0.1-1.module_postgresql_1_2.src.rpm')

          component_two_build_two.format = 'rpms'

+         component_two_build_two.build_id = 567567 + index

          component_two_build_two.task_id = 47383993 + index

          component_two_build_two.state = koji.BUILD_STATES['COMPLETE']

          component_two_build_two.nvr = \
@@ -250,6 +254,7 @@ 

              ('git://pkgs.domain.local/rpms/rubygem-rails?'

               '#dd55886c4a443b26a9ce38abda1f9bed22f2f8c3')

          component_one_build_three.format = 'rpms'

+         component_one_build_three.build_id = 345353 + index

          component_one_build_three.task_id = 2433433 + index

          component_one_build_three.state = koji.BUILD_STATES['FAILED']

          component_one_build_three.nvr = \
@@ -263,6 +268,7 @@ 

              ('/tmp/module_build_service-build-macrosWZUPeK/SRPMS/'

               'module-build-macros-0.1-1.module_testmodule_1_2.src.rpm')

          component_two_build_three.format = 'rpms'

+         component_two_build_three.build_id = 83732 + index

          component_two_build_three.task_id = 47383993 + index

          component_two_build_three.state = koji.BUILD_STATES['COMPLETE']

          component_two_build_three.nvr = \
@@ -431,6 +437,7 @@ 

          ('git://pkgs.fedoraproject.org/rpms/perl-Tangerine'

           '?#4ceea43add2366d8b8c5a622a2fb563b625b9abf')

      component_one_build_one.format = 'rpms'

+     component_one_build_one.build_id = 23456

      component_one_build_one.task_id = 90276227

      component_one_build_one.state = koji.BUILD_STATES['COMPLETE']

      component_one_build_one.nvr = \
@@ -446,6 +453,7 @@ 

          ('git://pkgs.fedoraproject.org/rpms/perl-List-Compare'

           '?#76f9d8c8e87eed0aab91034b01d3d5ff6bd5b4cb')

      component_two_build_one.format = 'rpms'

+     component_two_build_one.build_id = 23457

      component_two_build_one.task_id = 90276228

      component_two_build_one.state = koji.BUILD_STATES['COMPLETE']

      component_two_build_one.nvr = \
@@ -461,6 +469,7 @@ 

          ('git://pkgs.fedoraproject.org/rpms/tangerine'

           '?#fbed359411a1baa08d4a88e0d12d426fbf8f602c')

      component_three_build_one.format = 'rpms'

+     component_three_build_one.build_id = 23458

      component_three_build_one.task_id = 90276315

      component_three_build_one.state = koji.BUILD_STATES['COMPLETE']

      component_three_build_one.nvr = \
@@ -476,6 +485,7 @@ 

          ('/tmp/module_build_service-build-macrosqr4AWH/SRPMS/module-build-'

           'macros-0.1-1.module_testmodule_master_20170109091357.src.rpm')

      component_four_build_one.format = 'rpms'

+     component_four_build_one.build_id = 23459

      component_four_build_one.task_id = 90276181

      component_four_build_one.state = koji.BUILD_STATES['COMPLETE']

      component_four_build_one.nvr = \
@@ -542,6 +552,7 @@ 

          ('/tmp/module_build_service-build-macrosqr4AWH/SRPMS/module-build-'

           'macros-0.1-1.module_testmodule_master_20170219191323.src.rpm')

      component_four_build_two.format = 'rpms'

+     component_four_build_two.build_id = 456789

      component_four_build_two.task_id = 90276186

      component_four_build_two.state = koji.BUILD_STATES['COMPLETE']

      component_four_build_two.nvr = \

file modified
+23 -14
@@ -103,6 +103,7 @@ 

      on_cancel_cb = None

      on_buildroot_add_artifacts_cb = None

      on_tag_artifacts_cb = None

+     component_ids = {}

  

      @module_build_service.utils.validate_koji_tag('tag_name')

      def __init__(self, owner, module, config, tag_name, components):
@@ -120,6 +121,7 @@ 

          FakeModuleBuilder.on_tag_artifacts_cb = None

          FakeModuleBuilder.DEFAULT_GROUPS = None

          FakeModuleBuilder.backend = 'test'

+         FakeModuleBuilder.component_ids = {}

  

      def buildroot_connect(self, groups):

          default_groups = FakeModuleBuilder.DEFAULT_GROUPS or {
@@ -155,15 +157,10 @@ 

              FakeModuleBuilder.on_buildroot_add_artifacts_cb(self, artifacts, install)

          if self.backend == 'test':

              for nvr in artifacts:

-                 # buildroot_add_artifacts received a list of NVRs, but the tag message expects the

-                 # component name. At this point, the NVR may not be set if we are trying to reuse

-                 # all components, so we can't search the database. We must parse the package name

-                 # from the nvr and then tag it in the build tag. Kobo doesn't work when parsing

-                 # the NVR of a component with a module dist-tag, so we must manually do it.

-                 package_name = nvr.split('.module')[0].rsplit('-', 2)[0]

+                 component = models.ComponentBuild.query.filter_by(nvr=nvr).first()

                  # When INSTANT_COMPLETE is on, the components are already in the build tag

                  if self.INSTANT_COMPLETE is False:

-                     self._send_tag(package_name, dest_tag=False)

+                     self._send_tag(component, dest_tag=False)

          elif self.backend == 'testlocal':

              self._send_repo_done()

  
@@ -178,8 +175,8 @@ 

              for nvr in artifacts:

                  # tag_artifacts received a list of NVRs, but the tag message expects the

                  # component name

-                 artifact = models.ComponentBuild.query.filter_by(nvr=nvr).first().package

-                 self._send_tag(artifact, dest_tag=dest_tag)

+                 component = models.ComponentBuild.query.filter_by(nvr=nvr).first()

+                 self._send_tag(component, dest_tag=dest_tag)

  

      @property

      def koji_session(self):
@@ -202,15 +199,20 @@ 

          )

          module_build_service.scheduler.consumer.work_queue_put(msg)

  

-     def _send_tag(self, artifact, dest_tag=True):

+     def _send_tag(self, component, dest_tag=True):

          if dest_tag:

              tag = self.tag_name

          else:

              tag = self.tag_name + "-build"

+ 

+         if not FakeModuleBuilder.component_ids.get(component.package):

+             FakeModuleBuilder.component_ids[component.package] = component.build_id

+ 

          msg = module_build_service.messaging.KojiTagChange(

              msg_id='a faked internal message',

              tag=tag,

-             artifact=artifact

+             artifact=component.package,

+             build_id=FakeModuleBuilder.component_ids[component.package]

          )

          module_build_service.scheduler.consumer.work_queue_put(msg)

  
@@ -230,7 +232,10 @@ 

  

      def build(self, artifact_name, source):

          print("Starting building artifact %s: %s" % (artifact_name, source))

-         build_id = randint(1000, 9999999)

+         # Make sure we have consistent component IDs on every message

+         if artifact_name not in FakeModuleBuilder.component_ids:

+             FakeModuleBuilder.component_ids[artifact_name] = randint(1000, 9999999)

+         build_id = FakeModuleBuilder.component_ids[artifact_name]

  

          if FakeModuleBuilder.on_build_cb:

              FakeModuleBuilder.on_build_cb(self, artifact_name, source)
@@ -264,17 +269,21 @@ 

              component_build.state = koji.BUILD_STATES['COMPLETE']

              component_build.nvr = nvr

              component_build.task_id = component_build.id + 51234

+             if component_build.package not in FakeModuleBuilder.component_ids:

+                 FakeModuleBuilder.component_ids[component_build.package] = component_build.id + 123

+             component_build.build_id = FakeModuleBuilder.component_ids[component_build.package]

              component_build.state_reason = 'Found existing build'

              nvr_dict = kobo.rpmlib.parse_nvr(component_build.nvr)

              # Send a message stating the build is complete

              msgs.append(module_build_service.messaging.KojiBuildChange(

-                 'recover_orphaned_artifact: fake message', randint(1, 9999999),

+                 'recover_orphaned_artifact: fake message', component_build.build_id,

                  component_build.task_id, koji.BUILD_STATES['COMPLETE'], component_build.package,

                  nvr_dict['version'], nvr_dict['release'], component_build.module_build.id))

              # Send a message stating that the build was tagged in the build tag

              msgs.append(module_build_service.messaging.KojiTagChange(

                  'recover_orphaned_artifact: fake message',

-                 component_build.module_build.koji_tag + '-build', component_build.package))

+                 component_build.module_build.koji_tag + '-build', component_build.package,

+                 component_build.build_id))

          return msgs

  

      def finalize(self):

@@ -45,7 +45,7 @@ 

          """

          from_tag_change_event.return_value = None

          msg = module_build_service.messaging.KojiTagChange(

-             'no matches for this...', '2016-some-nonexistent-build', "artifact")

+             'no matches for this...', '2016-some-nonexistent-build', "artifact", 12345)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -56,7 +56,8 @@ 

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "artifact")

+             "artifact",

+             12345)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -85,28 +86,35 @@ 

  

          # Set previous components as COMPLETE and tagged.

          module_build.batch = 1

+         i = 0

          for c in module_build.up_to_current_batch():

              c.state = koji.BUILD_STATES["COMPLETE"]

              c.tagged = True

              c.tagged_in_final = True

+             c.build_id = 456790 + i

+             i += 1

  

          module_build.batch = 2

          for c in module_build.current_batch():

              c.state = koji.BUILD_STATES["COMPLETE"]

+             c.build_id = 456790 + i

+             i += 1

          db.session.commit()

  

          # Tag the first component to the buildroot.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "perl-Tangerine")

+             "perl-Tangerine",

+             456791)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

          # Tag the first component to the final tag.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c',

-             "perl-Tangerine")

+             "perl-Tangerine",

+             456791)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -118,7 +126,8 @@ 

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "perl-List-Compare")

+             "perl-List-Compare",

+             456792)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -130,7 +139,8 @@ 

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c',

-             "perl-List-Compare")

+             "perl-List-Compare",

+             456792)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -172,20 +182,23 @@ 

          component = module_build_service.models.ComponentBuild.query\

              .filter_by(package='perl-Tangerine', module_id=module_build.id).one()

          component.state = koji.BUILD_STATES["BUILDING"]

+         component.build_id = 123456

          db.session.commit()

  

          # Tag the perl-List-Compare component to the buildroot.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "perl-Tangerine")

+             "perl-Tangerine",

+             123456)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

          # Tag the perl-List-Compare component to final tag.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c',

-             "perl-Tangerine")

+             "perl-Tangerine",

+             123456)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -226,9 +239,11 @@ 

          module_build.batch = 2

          component = module_build_service.models.ComponentBuild.query\

              .filter_by(package='perl-Tangerine', module_id=module_build.id).one()

+         component.build_id = 456791

          component.state = koji.BUILD_STATES["FAILED"]

          component = module_build_service.models.ComponentBuild.query\

              .filter_by(package='perl-List-Compare', module_id=module_build.id).one()

+         component.build_id = 456792

          component.state = koji.BUILD_STATES["COMPLETE"]

          db.session.commit()

  
@@ -236,14 +251,16 @@ 

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "perl-List-Compare")

+             "perl-List-Compare",

+             456792)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

          # Tag the perl-List-Compare component to final tag.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c',

-             "perl-List-Compare")

+             "perl-List-Compare",

+             456792)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -290,6 +307,14 @@ 

              module_id=3, package='module-build-macros').one()

          mbm.tagged = False

          db.session.add(mbm)

+         pt = module_build_service.models.ComponentBuild.query.filter_by(

+             module_id=3, package='perl-Tangerine').one()

+         pt.build_id = 456791

+         db.session.add(pt)

+         plc = module_build_service.models.ComponentBuild.query.filter_by(

+             module_id=3, package='perl-List-Compare').one()

+         plc.build_id = 456792

+         db.session.add(plc)

          for c in module_build.current_batch():

              c.state = koji.BUILD_STATES["COMPLETE"]

          db.session.commit()
@@ -298,14 +323,16 @@ 

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "perl-Tangerine")

+             "perl-Tangerine",

+             456791)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

          # Tag the first component to the final tag.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c',

-             "perl-Tangerine")

+             "perl-Tangerine",

+             456791)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -317,14 +344,16 @@ 

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "perl-List-Compare")

+             "perl-List-Compare",

+             456792)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

          # Tag the second component to final tag.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c',

-             "perl-List-Compare")

+             "perl-List-Compare",

+             456792)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -336,14 +365,16 @@ 

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c',

-             "module-build-macros")

+             "module-build-macros",

+             456789)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

          # Tag the component from first batch to the buildroot.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "module-build-macros")

+             "module-build-macros",

+             456789)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  
@@ -397,16 +428,19 @@ 

          component.build_time_only = True

          component.tagged = False

          component.tagged_in_final = False

+         component.build_id = 456791

          component = module_build_service.models.ComponentBuild.query\

              .filter_by(package='perl-List-Compare', module_id=module_build.id).one()

          component.state = koji.BUILD_STATES["COMPLETE"]

+         component.build_id = 456792

          db.session.commit()

  

          # Tag the perl-Tangerine component to the buildroot.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "perl-Tangerine")

+             "perl-Tangerine",

+             456791)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

          assert not koji_session.newRepo.called
@@ -414,14 +448,16 @@ 

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c-build',

-             "perl-List-Compare")

+             "perl-List-Compare",

+             456792)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

          # Tag the perl-List-Compare component to final tag.

          msg = module_build_service.messaging.KojiTagChange(

              'id',

              'module-testmodule-master-20170219191323-c40c156c',

-             "perl-List-Compare")

+             "perl-List-Compare",

+             456792)

          module_build_service.scheduler.handlers.tags.tagged(

              config=conf, session=db.session, msg=msg)

  

@@ -441,6 +441,7 @@ 

      def test_query_component_build(self):

          rv = self.client.get('/module-build-service/1/component-builds/1')

          data = json.loads(rv.data)

+         assert data['build_id'] == 2345

          assert data['id'] == 1

          assert data['format'] == 'rpms'

          assert data['module_build'] == 2
@@ -453,6 +454,7 @@ 

      def test_query_component_build_short(self):

          rv = self.client.get('/module-build-service/1/component-builds/1?short=True')

          data = json.loads(rv.data)

+         assert data['build_id'] == 2345

          assert data['id'] == 1

          assert data['format'] == 'rpms'

          assert data['module_build'] == 2
@@ -465,6 +467,7 @@ 

      def test_query_component_build_verbose(self):

          rv = self.client.get('/module-build-service/1/component-builds/3?verbose=true')

          data = json.loads(rv.data)

+         assert data['build_id'] == 345345

          assert data['id'] == 3

          assert data['format'] == 'rpms'

          assert data['module_build'] == 3

This should resolve an issue where the component name is different than the package being tagged due to a macro such as those used for SCLs. MBS used the package names to find a component in the database when responding to a tag message, but if the name is different than what is recorded in MBS, this fails. This approach uses the component's ID in Koji.

2 new commits added

  • Store the component's build ID and use that to identify the build when acting on a tag message
  • Fix the COPR cleanup database migration for SQLite
5 years ago

1 new commit added

  • Fix the Docker image for running unit tests
5 years ago

Pull-Request has been merged by mprahl

5 years ago

@jkaluza I ended up reverting the last commit since I think it would have broken local builds. I'll resort to using the NVR instead from tag messages.