mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 03:38:12 +08:00
Use the NVR instead of the component name when responding to a tag message
This addresses an issue when a module contains builds that have different names in their NVR than the component name in MBS. This happens with SCLs for instance. MBS wouldn't be able to find the component to mark as tagged in the database since it was searching by the wrong name, so the build would just stall. This uses the NVR now to find the correct build in the database.
This commit is contained in:
@@ -630,7 +630,8 @@ chmod 644 %buildroot/etc/rpm/macros.zz-modules
|
||||
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.nvr))
|
||||
return further_work
|
||||
|
||||
def build(self, artifact_name, source):
|
||||
|
||||
@@ -157,7 +157,8 @@ class FedmsgMessageParser(MessageParser):
|
||||
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)
|
||||
nvr = msg_inner_msg.get('nvr')
|
||||
msg_obj = KojiTagChange(msg_id, tag, artifact, nvr)
|
||||
|
||||
elif category == 'mbs' and object == 'module' and \
|
||||
subobject == 'state' and event == 'change':
|
||||
@@ -208,11 +209,13 @@ class KojiTagChange(BaseMessage):
|
||||
object for a buildsys.tag info (in fedmsg this replaces the msg dictionary)
|
||||
:param tag: the name of tag (e.g. module-123456789-build)
|
||||
:param artifact: the name of tagged artifact (e.g. module-build-macros)
|
||||
:param nvr: the nvr of the tagged artifact
|
||||
"""
|
||||
def __init__(self, msg_id, tag, artifact):
|
||||
def __init__(self, msg_id, tag, artifact, nvr):
|
||||
super(KojiTagChange, self).__init__(msg_id)
|
||||
self.tag = tag
|
||||
self.artifact = artifact
|
||||
self.nvr = nvr
|
||||
|
||||
|
||||
class KojiRepoChange(BaseMessage):
|
||||
|
||||
@@ -708,6 +708,10 @@ class ComponentBuild(MBSBase):
|
||||
return session.query(cls).filter_by(
|
||||
package=component_name, module_id=module_id).first()
|
||||
|
||||
@classmethod
|
||||
def from_component_nvr(cls, session, nvr, module_id):
|
||||
return session.query(cls).filter_by(nvr=nvr, 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()
|
||||
|
||||
@@ -44,8 +44,8 @@ def tagged(config, session, msg):
|
||||
return
|
||||
|
||||
# Find tagged component.
|
||||
component = models.ComponentBuild.from_component_name(
|
||||
session, msg.artifact, module_build.id)
|
||||
component = models.ComponentBuild.from_component_nvr(
|
||||
session, msg.nvr, module_build.id)
|
||||
if not component:
|
||||
log.error("No component %s in module %r", msg.artifact, module_build)
|
||||
return
|
||||
|
||||
@@ -163,7 +163,7 @@ class FakeModuleBuilder(GenericBuilder):
|
||||
package_name = nvr.split('.module')[0].rsplit('-', 2)[0]
|
||||
# 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(package_name, nvr, dest_tag=False)
|
||||
elif self.backend == 'testlocal':
|
||||
self._send_repo_done()
|
||||
|
||||
@@ -179,7 +179,7 @@ class FakeModuleBuilder(GenericBuilder):
|
||||
# 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)
|
||||
self._send_tag(artifact, nvr, dest_tag=dest_tag)
|
||||
|
||||
@property
|
||||
def koji_session(self):
|
||||
@@ -202,7 +202,7 @@ class FakeModuleBuilder(GenericBuilder):
|
||||
)
|
||||
module_build_service.scheduler.consumer.work_queue_put(msg)
|
||||
|
||||
def _send_tag(self, artifact, dest_tag=True):
|
||||
def _send_tag(self, artifact, nvr, dest_tag=True):
|
||||
if dest_tag:
|
||||
tag = self.tag_name
|
||||
else:
|
||||
@@ -210,7 +210,8 @@ class FakeModuleBuilder(GenericBuilder):
|
||||
msg = module_build_service.messaging.KojiTagChange(
|
||||
msg_id='a faked internal message',
|
||||
tag=tag,
|
||||
artifact=artifact
|
||||
artifact=artifact,
|
||||
nvr=nvr
|
||||
)
|
||||
module_build_service.scheduler.consumer.work_queue_put(msg)
|
||||
|
||||
@@ -274,7 +275,8 @@ class FakeModuleBuilder(GenericBuilder):
|
||||
# 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.nvr))
|
||||
return msgs
|
||||
|
||||
def finalize(self):
|
||||
|
||||
@@ -45,7 +45,8 @@ class TestTagTagged:
|
||||
"""
|
||||
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',
|
||||
'artifact-1.2-1')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -54,9 +55,8 @@ class TestTagTagged:
|
||||
that we do nothing gracefully.
|
||||
"""
|
||||
msg = module_build_service.messaging.KojiTagChange(
|
||||
'id',
|
||||
'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
"artifact")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'artifact', 'artifact-1.2-1')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -92,21 +92,23 @@ class TestTagTagged:
|
||||
|
||||
module_build.batch = 2
|
||||
for c in module_build.current_batch():
|
||||
if c.package == 'perl-Tangerine':
|
||||
c.nvr = 'perl-Tangerine-0.23-1.module+0+d027b723'
|
||||
elif c.package == 'perl-List-Compare':
|
||||
c.nvr = 'perl-List-Compare-0.53-5.module+0+d027b723'
|
||||
c.state = koji.BUILD_STATES["COMPLETE"]
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'perl-Tangerine', 'perl-Tangerine-0.23-1.module+0+d027b723')
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c',
|
||||
'perl-Tangerine', 'perl-Tangerine-0.23-1.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -116,9 +118,8 @@ class TestTagTagged:
|
||||
|
||||
# Tag the second component to the buildroot.
|
||||
msg = module_build_service.messaging.KojiTagChange(
|
||||
'id',
|
||||
'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
"perl-List-Compare")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'perl-List-Compare', 'perl-List-Compare-0.53-5.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -128,9 +129,8 @@ class TestTagTagged:
|
||||
|
||||
# Tag the first component to the final tag.
|
||||
msg = module_build_service.messaging.KojiTagChange(
|
||||
'id',
|
||||
'module-testmodule-master-20170219191323-c40c156c',
|
||||
"perl-List-Compare")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c',
|
||||
'perl-List-Compare', 'perl-List-Compare-0.53-5.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -172,20 +172,19 @@ class TestTagTagged:
|
||||
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.nvr = 'perl-Tangerine-0.23-1.module+0+d027b723'
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'perl-Tangerine', 'perl-Tangerine-0.23-1.module+0+d027b723')
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c',
|
||||
'perl-Tangerine', 'perl-Tangerine-0.23-1.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -227,23 +226,23 @@ class TestTagTagged:
|
||||
component = module_build_service.models.ComponentBuild.query\
|
||||
.filter_by(package='perl-Tangerine', module_id=module_build.id).one()
|
||||
component.state = koji.BUILD_STATES["FAILED"]
|
||||
component.nvr = 'perl-Tangerine-0.23-1.module+0+d027b723'
|
||||
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.nvr = 'perl-List-Compare-0.53-5.module+0+d027b723'
|
||||
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-List-Compare")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'perl-List-Compare', 'perl-List-Compare-0.53-5.module+0+d027b723')
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c',
|
||||
'perl-List-Compare', 'perl-List-Compare-0.53-5.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -291,21 +290,23 @@ class TestTagTagged:
|
||||
mbm.tagged = False
|
||||
db.session.add(mbm)
|
||||
for c in module_build.current_batch():
|
||||
if c.package == 'perl-Tangerine':
|
||||
c.nvr = 'perl-Tangerine-0.23-1.module+0+d027b723'
|
||||
elif c.package == 'perl-List-Compare':
|
||||
c.nvr = 'perl-List-Compare-0.53-5.module+0+d027b723'
|
||||
c.state = koji.BUILD_STATES["COMPLETE"]
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'perl-Tangerine', 'perl-Tangerine-0.23-1.module+0+d027b723')
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c',
|
||||
'perl-Tangerine', 'perl-Tangerine-0.23-1.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -315,16 +316,14 @@ class TestTagTagged:
|
||||
|
||||
# Tag the second component to the buildroot.
|
||||
msg = module_build_service.messaging.KojiTagChange(
|
||||
'id',
|
||||
'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
"perl-List-Compare")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'perl-List-Compare', 'perl-List-Compare-0.53-5.module+0+d027b723')
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c',
|
||||
'perl-List-Compare', 'perl-List-Compare-0.53-5.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -334,16 +333,14 @@ class TestTagTagged:
|
||||
|
||||
# Tag the component from first batch to final tag.
|
||||
msg = module_build_service.messaging.KojiTagChange(
|
||||
'id',
|
||||
'module-testmodule-master-20170219191323-c40c156c',
|
||||
"module-build-macros")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c',
|
||||
'module-build-macros', 'module-build-macros-0.1-1.module+0+b0a1d1f7')
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'module-build-macros', 'module-build-macros-0.1-1.module+0+b0a1d1f7')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
@@ -386,6 +383,8 @@ class TestTagTagged:
|
||||
# Set previous components as COMPLETE and tagged.
|
||||
module_build.batch = 1
|
||||
for c in module_build.up_to_current_batch():
|
||||
if c.package == 'module-build-macros':
|
||||
c.nvr = 'module-build-macros-0.1-1.module+0+b0a1d1f7'
|
||||
c.state = koji.BUILD_STATES["COMPLETE"]
|
||||
c.tagged = True
|
||||
c.tagged_in_final = True
|
||||
@@ -397,31 +396,30 @@ class TestTagTagged:
|
||||
component.build_time_only = True
|
||||
component.tagged = False
|
||||
component.tagged_in_final = False
|
||||
component.nvr = 'perl-Tangerine-0.23-1.module+0+d027b723'
|
||||
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.nvr = 'perl-List-Compare-0.53-5.module+0+d027b723'
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'perl-Tangerine', 'perl-Tangerine-0.23-1.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
assert not koji_session.newRepo.called
|
||||
# Tag the perl-List-Compare component to the buildroot.
|
||||
msg = module_build_service.messaging.KojiTagChange(
|
||||
'id',
|
||||
'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
"perl-List-Compare")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c-build',
|
||||
'perl-List-Compare', 'perl-List-Compare-0.53-5.module+0+d027b723')
|
||||
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")
|
||||
'id', 'module-testmodule-master-20170219191323-c40c156c',
|
||||
'perl-List-Compare', 'perl-List-Compare-0.53-5.module+0+d027b723')
|
||||
module_build_service.scheduler.handlers.tags.tagged(
|
||||
config=conf, session=db.session, msg=msg)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user