changeset 8822:116151b6bfb2

celery: drop tracking of task_id - we use ignore_result=True and will never get anything back There is thus no need for configuration of celery.result_backend . The alternative would be to fix it. That could give better error reporting from failing repo creations, but would require quite a bit of additional changes before it actually works reliably.
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 30 Dec 2020 00:14:57 +0100
parents a5c17c93d246
children e3d033042fca
files development.ini kallithea/controllers/admin/repos.py kallithea/controllers/api/api.py kallithea/controllers/forks.py kallithea/lib/celerylib/__init__.py kallithea/templates/admin/repos/repo_creating.html kallithea/templates/ini/template.ini.mako kallithea/tests/api/api_base.py
diffstat 8 files changed, 3 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/development.ini	Tue Dec 29 16:31:59 2020 +0100
+++ b/development.ini	Wed Dec 30 00:14:57 2020 +0100
@@ -259,10 +259,6 @@
 ## Example: use the message queue on the local virtual host 'kallitheavhost' as the RabbitMQ user 'kallithea':
 celery.broker_url = amqp://kallithea:thepassword@localhost:5672/kallitheavhost
 
-celery.result_backend = db+sqlite:///celery-results.db
-
-#celery.amqp.task.result.expires = 18000
-
 celery.worker_concurrency = 2
 celery.worker_max_tasks_per_child = 100
 
--- a/kallithea/controllers/admin/repos.py	Tue Dec 29 16:31:59 2020 +0100
+++ b/kallithea/controllers/admin/repos.py	Wed Dec 30 00:14:57 2020 +0100
@@ -117,7 +117,6 @@
             # create is done sometimes async on celery, db transaction
             # management is handled there.
             task = RepoModel().create(form_result, request.authuser.user_id)
-            task_id = task.task_id
         except Exception:
             log.error(traceback.format_exc())
             msg = (_('Error creating repository %s')
@@ -127,7 +126,7 @@
 
         raise HTTPFound(location=webutils.url('repo_creating_home',
                               repo_name=form_result['repo_name_full'],
-                              task_id=task_id))
+                              ))
 
     @NotAnonymous()
     def create_repository(self):
@@ -158,7 +157,6 @@
     @LoginRequired()
     def repo_creating(self, repo_name):
         c.repo = repo_name
-        c.task_id = request.GET.get('task_id')
         if not c.repo:
             raise HTTPNotFound()
         return base.render('admin/repos/repo_creating.html')
@@ -167,14 +165,6 @@
     @base.jsonify
     def repo_check(self, repo_name):
         c.repo = repo_name
-        task_id = request.GET.get('task_id')
-
-        if task_id and task_id not in ['None']:
-            if kallithea.CELERY_APP:
-                task_result = kallithea.CELERY_APP.AsyncResult(task_id)
-                if task_result.failed():
-                    raise HTTPInternalServerError(task_result.traceback)
-
         repo = db.Repository.get_by_repo_name(repo_name)
         if repo and repo.repo_state == db.Repository.STATE_CREATED:
             if repo.clone_uri:
--- a/kallithea/controllers/api/api.py	Tue Dec 29 16:31:59 2020 +0100
+++ b/kallithea/controllers/api/api.py	Wed Dec 30 00:14:57 2020 +0100
@@ -1266,13 +1266,11 @@
             )
 
             task = RepoModel().create(form_data=data, cur_user=owner.username)
-            task_id = task.task_id
             # no commit, it's done in RepoModel, or async via celery
             return dict(
                 msg="Created new repository `%s`" % (repo_name,),
                 success=True,  # cannot return the repo data here since fork
                                # can be done async
-                task=task_id
             )
         except Exception:
             log.error(traceback.format_exc())
@@ -1441,13 +1439,11 @@
             )
             task = RepoModel().create_fork(form_data, cur_user=owner.username)
             # no commit, it's done in RepoModel, or async via celery
-            task_id = task.task_id
             return dict(
                 msg='Created fork of `%s` as `%s`' % (repo.repo_name,
                                                       fork_name),
                 success=True,  # cannot return the repo data here since fork
                                # can be done async
-                task=task_id
             )
         except Exception:
             log.error(traceback.format_exc())
--- a/kallithea/controllers/forks.py	Tue Dec 29 16:31:59 2020 +0100
+++ b/kallithea/controllers/forks.py	Wed Dec 30 00:14:57 2020 +0100
@@ -143,7 +143,6 @@
                              repo_groups=c.repo_groups,
                              landing_revs=c.landing_revs_choices)()
         form_result = {}
-        task_id = None
         try:
             form_result = _form.to_python(dict(request.POST))
 
@@ -154,7 +153,6 @@
             # create fork is done sometimes async on celery, db transaction
             # management is handled there.
             task = RepoModel().create_fork(form_result, request.authuser.user_id)
-            task_id = task.task_id
         except formencode.Invalid as errors:
             return htmlfill.render(
                 base.render('forks/fork.html'),
@@ -170,4 +168,4 @@
 
         raise HTTPFound(location=webutils.url('repo_creating_home',
                               repo_name=form_result['repo_name_full'],
-                              task_id=task_id))
+                              ))
--- a/kallithea/lib/celerylib/__init__.py	Tue Dec 29 16:31:59 2020 +0100
+++ b/kallithea/lib/celerylib/__init__.py	Wed Dec 30 00:14:57 2020 +0100
@@ -53,8 +53,6 @@
 
     traceback = None # if failed
 
-    task_id = None
-
 
 def task(f_org):
     """Wrapper of celery.task.task, running async if CELERY_APP
--- a/kallithea/templates/admin/repos/repo_creating.html	Tue Dec 29 16:31:59 2020 +0100
+++ b/kallithea/templates/admin/repos/repo_creating.html	Wed Dec 30 00:14:57 2020 +0100
@@ -46,7 +46,7 @@
 'use strict';
 (function worker() {
   $.ajax({
-    url: ${h.js(h.url('repo_check_home', repo_name=c.repo_name, repo=c.repo, task_id=c.task_id))},
+    url: ${h.js(h.url('repo_check_home', repo_name=c.repo_name, repo=c.repo))},
     success: function(data) {
       if(data.result === true){
           //redirect to created fork if our ajax loop tells us to do so.
--- a/kallithea/templates/ini/template.ini.mako	Tue Dec 29 16:31:59 2020 +0100
+++ b/kallithea/templates/ini/template.ini.mako	Wed Dec 30 00:14:57 2020 +0100
@@ -334,10 +334,6 @@
 <%text>##</%text> Example: use the message queue on the local virtual host 'kallitheavhost' as the RabbitMQ user 'kallithea':
 celery.broker_url = amqp://kallithea:thepassword@localhost:5672/kallitheavhost
 
-celery.result_backend = db+sqlite:///celery-results.db
-
-#celery.amqp.task.result.expires = 18000
-
 celery.worker_concurrency = 2
 celery.worker_max_tasks_per_child = 100
 
--- a/kallithea/tests/api/api_base.py	Tue Dec 29 16:31:59 2020 +0100
+++ b/kallithea/tests/api/api_base.py	Wed Dec 30 00:14:57 2020 +0100
@@ -789,7 +789,6 @@
         ret = {
             'msg': 'Created new repository `%s`' % repo_name,
             'success': True,
-            'task': None,
         }
         expected = ret
         self._compare_ok(id_, expected, given=response.body)
@@ -860,7 +859,6 @@
         expected = {
             'msg': 'Created new repository `%s`' % repo_name,
             'success': True,
-            'task': None,
         }
         self._compare_ok(id_, expected, given=response.body)
         repo = RepoModel().get_by_repo_name(repo_name)
@@ -893,7 +891,6 @@
         ret = {
             'msg': 'Created new repository `%s`' % repo_name,
             'success': True,
-            'task': None,
         }
         expected = ret
         self._compare_ok(id_, expected, given=response.body)
@@ -931,7 +928,6 @@
         ret = {
             'msg': 'Created new repository `%s`' % repo_name,
             'success': True,
-            'task': None,
         }
         expected = ret
         self._compare_ok(id_, expected, given=response.body)
@@ -951,7 +947,6 @@
         ret = {
             'msg': 'Created new repository `%s`' % repo_name,
             'success': True,
-            'task': None,
         }
         expected = ret
         self._compare_ok(id_, expected, given=response.body)
@@ -1260,7 +1255,6 @@
             'msg': 'Created fork of `%s` as `%s`' % (self.REPO,
                                                      fork_name),
             'success': True,
-            'task': None,
         }
         expected = ret
         self._compare_ok(id_, expected, given=response.body)
@@ -1281,7 +1275,6 @@
             'msg': 'Created fork of `%s` as `%s`' % (self.REPO,
                                                      fork_name),
             'success': True,
-            'task': None,
         }
         expected = ret
         self._compare_ok(id_, expected, given=response.body)