Fix potential infinite loop when waiting for a configuration from the autoconf

This commit is contained in:
Théophile Diot 2023-08-25 10:03:03 +02:00
parent 95c796c1ee
commit f7d9af9d69
No known key found for this signature in database
GPG key ID: 248FEA4BAE400D06
2 changed files with 21 additions and 22 deletions

View file

@ -262,17 +262,26 @@ if __name__ == "__main__":
"DATABASE_URI", getenv("DATABASE_URI", None)
),
)
env = {}
if INTEGRATION in (
"Swarm",
"Kubernetes",
"Autoconf",
):
while not db.is_initialized():
logger.warning(
"Database is not initialized, retrying in 5s ...",
)
sleep(5)
while not db.is_autoconf_loaded():
logger.warning(
"Autoconf is not loaded yet in the database, retrying in 5s ...",
)
sleep(5)
env = db.get_config()
elif (
not tmp_variables_path.exists()
or not nginx_variables_path.exists()
@ -301,21 +310,21 @@ if __name__ == "__main__":
"Config saver failed, configuration will not work as expected...",
)
while not db.is_initialized():
logger.warning(
"Database is not initialized, retrying in 5s ...",
)
sleep(5)
while not db.is_initialized():
logger.warning(
"Database is not initialized, retrying in 5s ...",
)
sleep(5)
env = db.get_config()
while not db.is_first_config_saved() or not env:
logger.warning(
"Database doesn't have any config saved yet, retrying in 5s ...",
)
sleep(5)
env = db.get_config()
while not db.is_first_config_saved() or not env:
logger.warning(
"Database doesn't have any config saved yet, retrying in 5s ...",
)
sleep(5)
env = db.get_config()
env["DATABASE_URI"] = db.database_uri
env["DATABASE_URI"] = db.database_uri
# Instantiate scheduler
SCHEDULER = JobScheduler(env.copy() | environ.copy(), logger, INTEGRATION)

View file

@ -205,16 +205,6 @@ while not db.is_initialized():
)
sleep(5)
env = db.get_config()
while not db.is_first_config_saved() or not env:
app.logger.warning(
"Database doesn't have any config saved yet, retrying in 5s ...",
)
sleep(5)
env = db.get_config()
del env
app.logger.info("Database is ready")
Path(sep, "var", "tmp", "bunkerweb", "ui.healthy").write_text("ok", encoding="utf-8")
bw_version = (