fix and test TOTAL_USERS count

Don't assume UserDict contains all users

which assumption led to double-counting when a user in the db was loaded into the dict cache
This commit is contained in:
Min RK
2020-11-30 13:27:52 +01:00
parent 18393ec6b4
commit 7e469f911d
5 changed files with 40 additions and 1 deletions

View File

@@ -40,6 +40,7 @@ from ..metrics import SERVER_STOP_DURATION_SECONDS
from ..metrics import ServerPollStatus
from ..metrics import ServerSpawnStatus
from ..metrics import ServerStopStatus
from ..metrics import TOTAL_USERS
from ..objects import Server
from ..spawner import LocalProcessSpawner
from ..user import User
@@ -453,6 +454,7 @@ class BaseHandler(RequestHandler):
# not found, create and register user
u = orm.User(name=username)
self.db.add(u)
TOTAL_USERS.inc()
self.db.commit()
user = self._user_from_orm(u)
return user