Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 0 additions & 88 deletions auth/auth_server/migrate.py

This file was deleted.

1 change: 1 addition & 0 deletions auth/auth_server/models/db_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def should_retry(_exception):


class BaseDB(object):
uses_migrations = False

def __init__(self, config=None, _scopefunc=None):
self._engine = None
Expand Down
2 changes: 2 additions & 0 deletions auth/auth_server/models/db_mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@


class MySQLDB(BaseDB):
uses_migrations = True

def _get_engine(self):
user, password, host, db = self._config.auth_db_params()
return create_engine(
Expand Down
12 changes: 7 additions & 5 deletions auth/auth_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@
import logging
import os

import optscale_client.config_client.client
import tornado.ioloop
import tornado.web
from tornado.web import RedirectHandler

import auth.auth_server.handlers.v1 as h_v1
import auth.auth_server.handlers.v2 as h_v2
from auth.auth_server.constants import urls_v2

from auth.auth_server.handlers.v1.base import DefaultHandler
from auth.auth_server.handlers.v1.swagger import SwaggerStaticFileHandler
from auth.auth_server.models.db_factory import DBType, DBFactory

import optscale_client.config_client.client
from auth.auth_server.models.db_factory import DBFactory, DBType

DEFAULT_PORT = 8905
DEFAULT_ETCD_HOST = '127.0.0.1'
Expand Down Expand Up @@ -102,7 +100,11 @@ def make_app(db_type, etcd_host, etcd_port, wait=False):
if wait:
config_cl.wait_configured()
db = DBFactory(db_type, config_cl).db
db.create_schema()

# migrations are already applied by a Helm hook
if not db.uses_migrations:
db.create_schema()

handler_kwargs = {
"engine": db.engine,
"config": config_cl,
Expand Down
16 changes: 9 additions & 7 deletions auth/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ dependencies = [
"sqlalchemy==1.3.24",
"tornado==6.5",
"zcrmsdk==3.1.0",
"db",
]

[build-system]
Expand All @@ -32,13 +33,14 @@ module-root = ".."
module-name = "auth"

[tool.uv.sources]
optscale-exceptions = { path = "../tools/optscale_exceptions" }
optscale-time = { path = "../tools/optscale_time" }
optscale-password = { path = "../tools/optscale_password" }
config-client = { path = "../optscale_client/config_client" }
restapi-client = { path = "../optscale_client/rest_api_client" }
auth-client = { path = "../optscale_client/auth_client" }
check-alembic-down-revisions = { path = "../tools/check_alembic_down_revisions" }
optscale-exceptions = { path = "../tools/optscale_exceptions", editable = true }
optscale-time = { path = "../tools/optscale_time", editable = true }
optscale-password = { path = "../tools/optscale_password", editable = true }
config-client = { path = "../optscale_client/config_client", editable = true }
restapi-client = { path = "../optscale_client/rest_api_client", editable = true }
auth-client = { path = "../optscale_client/auth_client", editable = true }
check-alembic-down-revisions = { path = "../tools/check_alembic_down_revisions", editable = true }
db = { path = "../tools/db", editable = true }

[dependency-groups]
dev = [
Expand Down
Loading