diff --git a/builder/kojid b/builder/kojid index 3e6106af..1b192b51 100755 --- a/builder/kojid +++ b/builder/kojid @@ -79,7 +79,8 @@ from koji.tasks import ( BaseTaskHandler, MultiPlatformTask, ServerExit, - ServerRestart + ServerRestart, + RefuseTask, ) from koji.util import ( dslice, @@ -5731,7 +5732,7 @@ class NewRepoTask(BaseTaskHandler): if not os.path.isdir(top_repos_dir): # missing or incorrect mount? # refuse and let another host try - self.session.host.refuseTask(self.id, msg="No access to repos dir %s" % top_repos_dir) + raise RefuseTask("No access to repos dir %s" % top_repos_dir) # call repoInit kwargs = {} @@ -5841,7 +5842,7 @@ class CreaterepoTask(BaseTaskHandler): if not os.path.isdir(top_repos_dir): # missing or incorrect mount? # refuse and let another host try - self.session.host.refuseTask(self.id, msg="No access to repos dir %s" % top_repos_dir) + raise RefuseTask("No access to repos dir %s" % top_repos_dir) else: # we seem to have fs access, but dir is missing, perhaps a repo_init bug? raise koji.GenericError("Repo directory missing: %s" % self.repodir) diff --git a/koji/daemon.py b/koji/daemon.py index a7a9561f..2b8e7004 100644 --- a/koji/daemon.py +++ b/koji/daemon.py @@ -1504,6 +1504,9 @@ class TaskManager(object): except (SystemExit, koji.tasks.ServerExit, KeyboardInterrupt): # we do not trap these raise + except koji.tasks.RefuseTask as refuse: + self.session.host.refuseTask(handler.id, msg=str(refuse)) + return except koji.tasks.ServerRestart: # freeing this task will allow the pending restart to take effect self.session.host.freeTasks([handler.id]) diff --git a/koji/tasks.py b/koji/tasks.py index ea45a167..cbb279f5 100644 --- a/koji/tasks.py +++ b/koji/tasks.py @@ -110,6 +110,11 @@ class ServerRestart(Exception): pass +class RefuseTask(Exception): + """Raise to task handler to refuse a task""" + pass + + def parse_task_params(method, params): """Parse task params into a dictionary