|
|
66d99fd |
From 0a8efdc2e54a1df534425bef6460de0eb5c4fb7f Mon Sep 17 00:00:00 2001
|
|
|
66d99fd |
From: Jan Kaluza <jkaluza@redhat.com>
|
|
|
66d99fd |
Date: Jun 05 2017 11:48:36 +0000
|
|
|
66d99fd |
Subject: Tag the component to final tag in case it is built, but not tagged.
|
|
|
66d99fd |
|
|
|
66d99fd |
|
|
|
66d99fd |
---
|
|
|
66d99fd |
|
|
|
b70930f |
diff --git a/module_build_service/builder/KojiModuleBuilder.py b/module_build_service/builder/KojiModuleBuilder.py
|
|
|
fe51ec6 |
index eede0ab..382d2ea 100644
|
|
|
b70930f |
--- a/module_build_service/builder/KojiModuleBuilder.py
|
|
|
b70930f |
+++ b/module_build_service/builder/KojiModuleBuilder.py
|
|
|
b70930f |
@@ -67,6 +67,7 @@ class KojiModuleBuilder(GenericBuilder):
|
|
|
b70930f |
"""
|
|
|
b70930f |
self.owner = owner
|
|
|
b70930f |
self.module_str = module.name
|
|
|
b70930f |
+ self.mmd = module.mmd()
|
|
|
b70930f |
self.config = config
|
|
|
b70930f |
self.tag_name = tag_name
|
|
|
b70930f |
self.__prep = False
|
|
|
b70930f |
@@ -375,15 +376,15 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
|
|
|
b70930f |
|
|
|
b70930f |
return get_result()
|
|
|
b70930f |
|
|
|
b70930f |
- def _get_task_by_artifact(self, artifact_name):
|
|
|
b70930f |
+ def _get_build_by_artifact(self, artifact_name):
|
|
|
b70930f |
"""
|
|
|
b70930f |
:param artifact_name: e.g. bash
|
|
|
b70930f |
|
|
|
b70930f |
- Searches for a tagged package inside module tag.
|
|
|
b70930f |
+ Searches for a complete build of artifact belonging to this module.
|
|
|
b70930f |
+ The returned build can be even untagged.
|
|
|
b70930f |
|
|
|
b70930f |
- Returns task_id or None.
|
|
|
b70930f |
+ Returns koji_session.getBuild response or None.
|
|
|
b70930f |
|
|
|
b70930f |
- TODO: handle builds with skip_tag (not tagged at all)
|
|
|
b70930f |
"""
|
|
|
b70930f |
# yaml file can hold only one reference to a package name, so
|
|
|
b70930f |
# I expect that we can have only one build of package within single module
|
|
|
fe51ec6 |
@@ -404,6 +405,21 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
|
|
|
b70930f |
assert len(tagged) == 1, "Expected exactly one item in list. Got %s" % tagged
|
|
|
b70930f |
return tagged[0]
|
|
|
b70930f |
|
|
|
b70930f |
+ # If the build cannot be found in tag, it may be untagged as a result
|
|
|
b70930f |
+ # of some earlier inconsistent situation. Let's find the task_info
|
|
|
b70930f |
+ # based on the list of untagged builds
|
|
|
b70930f |
+ release = module_build_service.utils.get_rpm_release_from_mmd(self.mmd)
|
|
|
b70930f |
+ opts = {'name': artifact_name}
|
|
|
b70930f |
+ untagged = self.koji_session.untaggedBuilds(**opts)
|
|
|
b70930f |
+ for build in untagged:
|
|
|
b70930f |
+ if build["release"].endswith(release):
|
|
|
b70930f |
+ build_info = self.koji_session.getBuild(build['id'])
|
|
|
b70930f |
+ if not build_info:
|
|
|
b70930f |
+ log.error("Cannot get build info of build %r", build['id'])
|
|
|
b70930f |
+ return None
|
|
|
fe51ec6 |
+ self.tag_artifacts([build_info["nvr"]])
|
|
|
b70930f |
+ return build_info
|
|
|
b70930f |
+
|
|
|
b70930f |
return None
|
|
|
b70930f |
|
|
|
b70930f |
def build(self, artifact_name, source):
|
|
|
fe51ec6 |
@@ -436,7 +452,7 @@ chmod 644 %buildroot/%_rpmconfigdir/macros.d/macros.modules
|
|
|
2354959 |
raise RuntimeError("Buildroot is not prep-ed")
|
|
|
2354959 |
|
|
|
2354959 |
# Skip existing builds
|
|
|
2354959 |
- task_info = self._get_task_by_artifact(artifact_name)
|
|
|
2354959 |
+ task_info = self._get_build_by_artifact(artifact_name)
|
|
|
2354959 |
if task_info:
|
|
|
2354959 |
log.info("skipping build of %s. Build already exists (task_id=%s), via %s" % (
|
|
|
2354959 |
source, task_info['task_id'], self))
|
|
|
b70930f |
diff --git a/module_build_service/scheduler/handlers/modules.py b/module_build_service/scheduler/handlers/modules.py
|
|
|
66d99fd |
index a48df6b..cc94b73 100644
|
|
|
b70930f |
--- a/module_build_service/scheduler/handlers/modules.py
|
|
|
b70930f |
+++ b/module_build_service/scheduler/handlers/modules.py
|
|
|
66d99fd |
@@ -29,13 +29,13 @@ import module_build_service.pdc
|
|
|
b70930f |
import module_build_service.utils
|
|
|
b70930f |
import module_build_service.messaging
|
|
|
b70930f |
from module_build_service.utils import (
|
|
|
b70930f |
- start_next_batch_build, attempt_to_reuse_all_components)
|
|
|
b70930f |
+ start_next_batch_build, attempt_to_reuse_all_components,
|
|
|
b70930f |
+ get_rpm_release_from_mmd)
|
|
|
66d99fd |
from module_build_service.builder.KojiContentGenerator import KojiContentGenerator
|
|
|
b70930f |
|
|
|
b70930f |
from requests.exceptions import ConnectionError
|
|
|
b70930f |
|
|
|
b70930f |
import koji
|
|
|
b70930f |
-import hashlib
|
|
|
b70930f |
|
|
|
b70930f |
import logging
|
|
|
b70930f |
import os
|
|
|
66d99fd |
@@ -43,15 +43,6 @@ import os
|
|
|
b70930f |
logging.basicConfig(level=logging.DEBUG)
|
|
|
b70930f |
|
|
|
b70930f |
|
|
|
b70930f |
-def get_rpm_release_from_mmd(mmd):
|
|
|
b70930f |
- """
|
|
|
b70930f |
- Returns the dist tag based on the modulemd metadata and MBS configuration.
|
|
|
b70930f |
- """
|
|
|
b70930f |
-
|
|
|
b70930f |
- dist_str = '.'.join([mmd.name, mmd.stream, str(mmd.version)])
|
|
|
b70930f |
- dist_hash = hashlib.sha1(dist_str).hexdigest()[:8]
|
|
|
b70930f |
- return conf.default_dist_tag_prefix + dist_hash
|
|
|
b70930f |
-
|
|
|
b70930f |
def get_artifact_from_srpm(srpm_path):
|
|
|
b70930f |
return os.path.basename(srpm_path).replace(".src.rpm", "")
|
|
|
b70930f |
|
|
|
b70930f |
diff --git a/module_build_service/utils.py b/module_build_service/utils.py
|
|
|
66d99fd |
index a47b080..dba95c5 100644
|
|
|
b70930f |
--- a/module_build_service/utils.py
|
|
|
b70930f |
+++ b/module_build_service/utils.py
|
|
|
b70930f |
@@ -33,6 +33,7 @@ import copy
|
|
|
b70930f |
import kobo.rpmlib
|
|
|
b70930f |
import inspect
|
|
|
b70930f |
from six import iteritems
|
|
|
b70930f |
+import hashlib
|
|
|
b70930f |
|
|
|
b70930f |
import modulemd
|
|
|
b70930f |
|
|
|
b70930f |
@@ -1131,3 +1132,12 @@ def validate_koji_tag(tag_arg_names, pre='', post='-', dict_key='name'):
|
|
|
b70930f |
return wrapper
|
|
|
b70930f |
|
|
|
b70930f |
return validation_decorator
|
|
|
b70930f |
+
|
|
|
b70930f |
+def get_rpm_release_from_mmd(mmd):
|
|
|
b70930f |
+ """
|
|
|
b70930f |
+ Returns the dist tag based on the modulemd metadata and MBS configuration.
|
|
|
b70930f |
+ """
|
|
|
b70930f |
+
|
|
|
b70930f |
+ dist_str = '.'.join([mmd.name, mmd.stream, str(mmd.version)])
|
|
|
b70930f |
+ dist_hash = hashlib.sha1(dist_str).hexdigest()[:8]
|
|
|
b70930f |
+ return conf.default_dist_tag_prefix + dist_hash
|
|
|
66d99fd |
|