mirror of
https://src.fedoraproject.org/rpms/module-build-service.git
synced 2026-11-03 06:33:45 +08:00
fix bug when untagged builds couldn't be find in Koji
This commit is contained in:
113
mbs-koji-find-untagged.patch
Normal file
113
mbs-koji-find-untagged.patch
Normal file
@@ -0,0 +1,113 @@
|
||||
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
|
||||
@@ -1,6 +1,6 @@
|
||||
Name: module-build-service
|
||||
Version: 1.3.23
|
||||
Release: 1%{?dist}
|
||||
Release: 2%{?dist}
|
||||
Summary: The Module Build Service for Modularity
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ Source0: https://files.pythonhosted.org/packages/source/m/%{name}/%{name}-%{vers
|
||||
%if 0%{?rhel} && 0%{?rhel} <= 7
|
||||
Patch0: mbs-no-mbsbuild.patch
|
||||
%endif
|
||||
Patch1: mbs-koji-find-untagged.patch
|
||||
|
||||
%if 0%{?rhel} && 0%{?rhel} <= 7
|
||||
# In EL7 we need flask which needs python-itsdangerous which comes from
|
||||
@@ -128,6 +129,8 @@ for a number of tasks:
|
||||
%patch0 -p1
|
||||
%endif
|
||||
|
||||
%patch1 -p1
|
||||
|
||||
# Simply remove an old .pyc file that was included in one release.
|
||||
rm -f module_build_service/scheduler/consumer.pyc
|
||||
# And this weird sqlite file that made it in...
|
||||
@@ -176,6 +179,9 @@ done
|
||||
|
||||
|
||||
%changelog
|
||||
* Mon Jun 05 2017 Jan Kaluza <jkaluza@redhat.com> - 1.3.23-2
|
||||
- fix bug when untagged builds couldn't be find in Koji
|
||||
|
||||
* Wed May 31 2017 Jan Kaluza <jkaluza@redhat.com> - 1.3.23-1
|
||||
- new version
|
||||
|
||||
|
||||
Reference in New Issue
Block a user