From 24cfa3148494021a5ba119b0d985f5d59d51068e Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Dec 29 2016 18:37:49 +0000 Subject: Add IMPORTING state Signed-off-by: Patrick Uiterwijk --- diff --git a/builder/kojid b/builder/kojid index 446ab2e..4ceb324 100755 --- a/builder/kojid +++ b/builder/kojid @@ -864,7 +864,7 @@ class BuildTask(BaseTaskHandler): #scratch builds do not get imported self.session.host.moveBuildToScratch(self.id,srpm,rpms,logs=logs) else: - self.session.host.completeBuild(self.id,build_id,srpm,rpms,brmap,logs=logs) + res = self.session.host.completeBuild(self.id,build_id,srpm,rpms,brmap,logs=logs) except (SystemExit,ServerExit,KeyboardInterrupt): #we do not trap these raise @@ -874,7 +874,7 @@ class BuildTask(BaseTaskHandler): self.session.host.failBuild(self.id, build_id) # reraise the exception raise - if not self.opts.get('skip_tag') and not self.opts.get('scratch'): + if not self.opts.get('skip_tag') and not self.opts.get('scratch') and len(res) > 0: self.tagBuild(build_id,dest_tag) def getSRPM(self, src, build_tag, repo_id): diff --git a/hub/kojihub.py b/hub/kojihub.py index 51e41a2..3602a53 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -4825,19 +4825,23 @@ def import_build(srpm, rpms, brmap=None, task_id=None, build_id=None, logs=None) else: #build_id was passed in - sanity check binfo = get_build(build_id, strict=True) + st_importing = koji.BUILD_STATES['IMPORTING'] st_complete = koji.BUILD_STATES['COMPLETE'] - koji.plugin.run_callbacks('preBuildStateChange', attribute='state', old=binfo['state'], new=st_complete, info=binfo) + koji.plugin.run_callbacks('preBuildStateChange', attribute='state', old=binfo['state'], new=st_importing, info=binfo) for key in ('name', 'version', 'release', 'epoch', 'task_id'): if build[key] != binfo[key]: raise koji.GenericError, "Unable to complete build: %s mismatch (build: %s, rpm: %s)" % (key, binfo[key], build[key]) + if binfo['state'] == koji.BUILD_STATES['IMPORTING']: + return {} if binfo['state'] != koji.BUILD_STATES['BUILDING']: raise koji.GenericError, "Unable to complete build: state is %s" \ % koji.BUILD_STATES[binfo['state']] #update build state - update = """UPDATE build SET state=%(st_complete)i,completion_time=NOW() + update = """UPDATE build SET state=%(st_importing)i WHERE id=%(build_id)i""" _dml(update, locals()) koji.plugin.run_callbacks('postBuildStateChange', attribute='state', old=binfo['state'], new=st_complete, info=binfo) + binfo['state'] = st_importing # now to handle the individual rpms for relpath in [srpm] + rpms: fn = "%s/%s" % (uploadpath, relpath) @@ -4851,6 +4855,12 @@ def import_build(srpm, rpms, brmap=None, task_id=None, build_id=None, logs=None) for relpath in files: fn = "%s/%s" % (uploadpath, relpath) import_build_log(fn, binfo, subdir=key) + #update build state + koji.plugin.run_callbacks('preBuildStateChange', attribute='state', old=binfo['state'], new=st_complete, info=binfo) + update = """UPDATE build SET state=%(st_complete)i,completion_time=NOW() + WHERE id=%(build_id)i""" + _dml(update, locals()) + koji.plugin.run_callbacks('postBuildStateChange', attribute='state', old=binfo['state'], new=st_complete, info=binfo) koji.plugin.run_callbacks('postImport', type='build', srpm=srpm, rpms=rpms, brmap=brmap, task_id=task_id, build_id=build_id, build=binfo, logs=logs) return binfo @@ -7118,7 +7128,8 @@ def build_notification(task_id, build_id): if target: dest_tag = target['dest_tag'] - if build['state'] == koji.BUILD_STATES['BUILDING']: + if build['state'] in [koji.BUILD_STATES['BUILDING'] + koji.BUILD_STATES['IMPORTING']]: raise koji.GenericError, 'never send notifications for incomplete builds' web_url = context.opts.get('KojiWebURL', 'http://localhost/koji') @@ -11484,7 +11495,8 @@ class HostExports(object): task = Task(task_id) task.assertHost(host.id) result = import_build(srpm, rpms, brmap, task_id, build_id, logs=logs) - build_notification(task_id, build_id) + if len(result) != 0: + build_notification(task_id, build_id) return result def completeImageBuild(self, task_id, build_id, results): diff --git a/koji/__init__.py b/koji/__init__.py index 144c2c5..a035eda 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -174,6 +174,7 @@ TASK_STATES = Enum(( BUILD_STATES = Enum(( 'BUILDING', + 'IMPORTING', 'COMPLETE', 'DELETED', 'FAILED', diff --git a/util/koji-shadow b/util/koji-shadow index 48baaf9..fdd0bbb 100755 --- a/util/koji-shadow +++ b/util/koji-shadow @@ -406,7 +406,7 @@ class TrackedBuild(object): elif state in ('FAILED', 'CANCELED'): #treat these as having no build pass - elif state == 'BUILDING' and ours['task_id']: + elif state in ['BUILDING', 'IMPORTING'] and ours['task_id']: self.setState("pending") self.task_id = ours['task_id'] return diff --git a/www/kojiweb/builds.chtml b/www/kojiweb/builds.chtml index 843955d..00b72ac 100644 --- a/www/kojiweb/builds.chtml +++ b/www/kojiweb/builds.chtml @@ -24,7 +24,7 @@