Commit aea340bf authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed issue with missing admin password when started with no repo db.

parent bc365373
Pipeline #41243 passed with stages
in 15 minutes and 27 seconds
...@@ -110,7 +110,7 @@ services = NomadServicesConfig( ...@@ -110,7 +110,7 @@ services = NomadServicesConfig(
api_base_path=os.environ.get('NOMAD_API_BASE_PATH', '/nomad/api'), api_base_path=os.environ.get('NOMAD_API_BASE_PATH', '/nomad/api'),
api_secret=os.environ.get('NOMAD_API_SECRET', 'defaultApiSecret'), api_secret=os.environ.get('NOMAD_API_SECRET', 'defaultApiSecret'),
admin_password=os.environ.get('NOMAD_API_ADMIN_PASSWORD', 'password'), admin_password=os.environ.get('NOMAD_API_ADMIN_PASSWORD', 'password'),
disable_reset=os.environ.get('NOMAD_API_DISABLE_RESET', 'true') == 'false' disable_reset=os.environ.get('NOMAD_API_DISABLE_RESET', 'false') == 'true'
) )
console_log_level = get_loglevel_from_env('NOMAD_CONSOLE_LOGLEVEL', default_level=logging.INFO) console_log_level = get_loglevel_from_env('NOMAD_CONSOLE_LOGLEVEL', default_level=logging.INFO)
......
...@@ -128,6 +128,11 @@ def setup_repository_db(): ...@@ -128,6 +128,11 @@ def setup_repository_db():
"select exists(select * from information_schema.tables " "select exists(select * from information_schema.tables "
"where table_name='users')") "where table_name='users')")
exists = cur.fetchone()[0] exists = cur.fetchone()[0]
if not exists:
logger.info('repository db postgres schema does not exists')
reset_repository_db()
else:
logger.info('repository db postgres schema already exists')
# set the admin user password # set the admin user password
with repository_db_connection() as conn: with repository_db_connection() as conn:
...@@ -136,12 +141,6 @@ def setup_repository_db(): ...@@ -136,12 +141,6 @@ def setup_repository_db():
"UPDATE public.users SET password='%s' WHERE user_id=1;" % "UPDATE public.users SET password='%s' WHERE user_id=1;" %
bcrypt.encrypt(config.services.admin_password, ident='2y')) bcrypt.encrypt(config.services.admin_password, ident='2y'))
if not exists:
logger.info('repository db postgres schema does not exists')
reset_repository_db()
else:
logger.info('repository db postgres schema already exists')
global repository_db global repository_db
global repository_db_conn global repository_db_conn
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment