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:
mprahl
2018-08-07 11:45:50 -04:00
parent 411e459008
commit f08135352a
6 changed files with 73 additions and 65 deletions

View File

@@ -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):

View File

@@ -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):

View File

@@ -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()

View File

@@ -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