mirror of
https://github.com/jupyterhub/jupyterhub.git
synced 2025-10-17 15:03:02 +00:00
add Proxy.check_routes
checks to ensure proxy table and user db are in sync called on each last-activity check with the proxy (5 minutes)
This commit is contained in:
@@ -869,6 +869,7 @@ class JupyterHub(Application):
|
|||||||
user.last_activity = max(user.last_activity, dt)
|
user.last_activity = max(user.last_activity, dt)
|
||||||
|
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
|
yield self.proxy.check_routes(routes)
|
||||||
|
|
||||||
@gen.coroutine
|
@gen.coroutine
|
||||||
def start(self):
|
def start(self):
|
||||||
|
@@ -193,6 +193,23 @@ class Proxy(Base):
|
|||||||
resp = yield self.api_request('', client=client)
|
resp = yield self.api_request('', client=client)
|
||||||
return json.loads(resp.body.decode('utf8', 'replace'))
|
return json.loads(resp.body.decode('utf8', 'replace'))
|
||||||
|
|
||||||
|
@gen.coroutine
|
||||||
|
def check_routes(self, routes=None):
|
||||||
|
"""Check that all users are properly"""
|
||||||
|
if not routes:
|
||||||
|
routes = yield self.get_routes()
|
||||||
|
|
||||||
|
have_routes = { r['user'] for r in routes if 'user' in r }
|
||||||
|
futures = []
|
||||||
|
db = inspect(self).session
|
||||||
|
for user in db.query(User).filter(User.server != None):
|
||||||
|
if user.name not in have_routes:
|
||||||
|
self.log.warn("Adding missing route for %s", user.name)
|
||||||
|
futures.append(self.add_user(user))
|
||||||
|
for f in futures:
|
||||||
|
yield f
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Hub(Base):
|
class Hub(Base):
|
||||||
"""Bring it all together at the hub.
|
"""Bring it all together at the hub.
|
||||||
|
Reference in New Issue
Block a user