diff --git a/module_build_service/builder/KojiModuleBuilder.py b/module_build_service/builder/KojiModuleBuilder.py
index eede0ab..88760ad 100644
--- a/module_build_service/builder/KojiModuleBuilder.py
+++ b/module_build_service/builder/KojiModuleBuilder.py
@@ -67,6 +67,7 @@ class KojiModuleBuilder(GenericBuilder):
"""
self.owner = owner
self.module_str = module.name
+ self.mmd = module.mmd()
self.config = config
self.tag_name = tag_name
self.__prep = False
@@ -375,15 +376,15 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
return get_result()
- def _get_task_by_artifact(self, artifact_name):
+ def _get_build_by_artifact(self, artifact_name):
"""
:param artifact_name: e.g. bash
- Searches for a tagged package inside module tag.
+ Searches for a complete build of artifact belonging to this module.
+ The returned build can be even untagged.
- Returns task_id or None.
+ Returns koji_session.getBuild response or None.
- TODO: handle builds with skip_tag (not tagged at all)
"""
# yaml file can hold only one reference to a package name, so
# I expect that we can have only one build of package within single module
@@ -404,6 +405,20 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
assert len(tagged) == 1, "Expected exactly one item in list. Got %s" % tagged
return tagged[0]
+ # If the build cannot be found in tag, it may be untagged as a result
+ # of some earlier inconsistent situation. Let's find the task_info
+ # based on the list of untagged builds
+ release = module_build_service.utils.get_rpm_release_from_mmd(self.mmd)
+ opts = {'name': artifact_name}
+ untagged = self.koji_session.untaggedBuilds(**opts)
+ for build in untagged:
+ if build["release"].endswith(release):
+ build_info = self.koji_session.getBuild(build['id'])
+ if not build_info:
+ log.error("Cannot get build info of build %r", build['id'])
+ return None
+ return build_info
+
return None
def build(self, artifact_name, source):
diff --git a/module_build_service/scheduler/handlers/modules.py b/module_build_service/scheduler/handlers/modules.py
index 849bc07..7580d94 100644
--- a/module_build_service/scheduler/handlers/modules.py
+++ b/module_build_service/scheduler/handlers/modules.py
@@ -29,12 +29,12 @@ import module_build_service.pdc
import module_build_service.utils
import module_build_service.messaging
from module_build_service.utils import (
- start_next_batch_build, attempt_to_reuse_all_components)
+ start_next_batch_build, attempt_to_reuse_all_components,
+ get_rpm_release_from_mmd)
from requests.exceptions import ConnectionError
import koji
-import hashlib
import logging
import os
@@ -42,15 +42,6 @@ import os
logging.basicConfig(level=logging.DEBUG)
-def get_rpm_release_from_mmd(mmd):
- """
- Returns the dist tag based on the modulemd metadata and MBS configuration.
- """
-
- dist_str = '.'.join([mmd.name, mmd.stream, str(mmd.version)])
- dist_hash = hashlib.sha1(dist_str).hexdigest()[:8]
- return conf.default_dist_tag_prefix + dist_hash
-
def get_artifact_from_srpm(srpm_path):
return os.path.basename(srpm_path).replace(".src.rpm", "")
diff --git a/module_build_service/utils.py b/module_build_service/utils.py
index 99ca4cc..f3aecc5 100644
--- a/module_build_service/utils.py
+++ b/module_build_service/utils.py
@@ -33,6 +33,7 @@ import copy
import kobo.rpmlib
import inspect
from six import iteritems
+import hashlib
import modulemd
@@ -1131,3 +1132,12 @@ def validate_koji_tag(tag_arg_names, pre='', post='-', dict_key='name'):
return wrapper
return validation_decorator
+
+def get_rpm_release_from_mmd(mmd):
+ """
+ Returns the dist tag based on the modulemd metadata and MBS configuration.
+ """
+
+ dist_str = '.'.join([mmd.name, mmd.stream, str(mmd.version)])
+ dist_hash = hashlib.sha1(dist_str).hexdigest()[:8]
+ return conf.default_dist_tag_prefix + dist_hash