sunlightlabs / django-locksmith

django utilities for shared api authentication & log aggregation
BSD 3-Clause "New" or "Revised" License
27 stars 5 forks source link

reset_keys view can timeout. #12

Open dvogel opened 10 years ago

dvogel commented 10 years ago

The reset_keys method queues thousands of jobs. It should queue a single job that then queues the thousands of jobs.

https://github.com/sunlightlabs/django-locksmith/blob/master/locksmith/hub/views.py#L57-L78

dcloud commented 10 years ago

:facepunch:

timball commented 10 years ago

drew claims that this is al good, tn but trying to reset the capwords keys again and i keep getting this AND the one dude's key isn't getting synced so badness/magic/sadness ? don't care ate korean last night...

--timball

(capwords)capwords@southwest:~/src/Capitol-Words/cwod_site$ python ./manage.py resetkeys
resetting all keys for capitolwords
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/projects/capwords/lib/python2.6/site-packages/locksmith/auth/management/commands/resetkeys.py", line 16, in handle_noargs
    api=settings.LOCKSMITH_API_NAME)
  File "/projects/capwords/lib/python2.6/site-packages/locksmith/common.py", line 53, in apicall
    urllib2.urlopen(url, body)
  File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.6/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 502: Bad Gateway
timball commented 10 years ago

this demonstrates a nearly exactly 30s timeout .

--timball

(capwords)capwords@southwest:~/src/Capitol-Words/cwod_site$ time python ./manage.py resetkeys
resetting all keys for capitolwords
Traceback (most recent call last):
  File "./manage.py", line 11, in <module>
    execute_manager(settings)
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
    utility.execute()
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/base.py", line 220, in execute
    output = self.handle(*args, **options)
  File "/projects/capwords/lib/python2.6/site-packages/django/core/management/base.py", line 351, in handle
    return self.handle_noargs(**options)
  File "/projects/capwords/lib/python2.6/site-packages/locksmith/auth/management/commands/resetkeys.py", line 16, in handle_noargs
    api=settings.LOCKSMITH_API_NAME)
  File "/projects/capwords/lib/python2.6/site-packages/locksmith/common.py", line 53, in apicall
    urllib2.urlopen(url, body)
  File "/usr/lib/python2.6/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)
  File "/usr/lib/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)
  File "/usr/lib/python2.6/urllib2.py", line 435, in error
    return self._call_chain(*args)
  File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.6/urllib2.py", line 518, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 502: Bad Gateway

real    0m31.152s
user    0m0.280s
sys 0m0.170s
timball commented 10 years ago

mayhaps related to this > https://app.getsentry.com/sunlightlabs/sunlightfoundationcom/group/26744887/#exception

Can't retry locksmith.hub.tasks.replicate_key[36a01bef-49e7-41b8-9b3a-cc74a0781901] args:(<Key: API_KEY user@example.com [A]>, <Api: capitolwords>) kwargs:{}

locksmith/hub/tasks.py ? in replicate_key (application)

             'k': str(key.key),
            'e': str(e.read()) if isinstance(e, urllib2.HTTPError) else str(e)
        }
        print 'Caught exception while pushing key {k} to {a}: {e}'.format(**ctx)
        print 'Will retry'
        replicate_key.retry()
boblannon commented 9 years ago

having this issue on IE right now. did we ever come up with a solution? paging @timball

timball commented 9 years ago

uh don't thinks so . I'm not really near the network ... uh hrm .

--timball

please pardom the two thumbed typist On Oct 3, 2014 6:12 PM, "Bob Lannon" notifications@github.com wrote:

having this issue on IE right now. did we ever come up with a solution? paging @timball https://github.com/timball

— Reply to this email directly or view it on GitHub https://github.com/sunlightlabs/django-locksmith/issues/12#issuecomment-57870225 .