Refactor logger setup in save_config.py for improved clarity and add warning for autoconf instance clearing

This commit is contained in:
Théophile Diot 2024-11-01 11:00:49 +01:00
parent c97332e864
commit 3117ab5a8b
No known key found for this signature in database
GPG key ID: FA995104A0BA376A

View file

@ -23,7 +23,7 @@ CUSTOM_CONF_RX = re_compile(
)
BUNKERWEB_STATIC_INSTANCES_RX = re_compile(r"(http://)?(?P<hostname>(?<![:])\b[^:\s]+\b)(:(?P<port>\d+))?")
LOGGER = setup_logger("Generator", getenv("CUSTOM_LOG_LEVEL", getenv("LOG_LEVEL", "INFO")))
LOGGER = setup_logger("Generator.save_config", getenv("CUSTOM_LOG_LEVEL", getenv("LOG_LEVEL", "INFO")))
if __name__ == "__main__":
@ -214,6 +214,11 @@ if __name__ == "__main__":
if err:
LOGGER.warning(f"Couldn't clear manual instances from database : {err}, instances may be incorrect")
if any(settings.get(setting, "no") == "yes" for setting in ("AUTOCONF_MODE", "SWARM_MODE", "KUBERNETES_MODE")):
err = db.update_instances([], method="autoconf", changed=False)
if err:
LOGGER.warning(f"Couldn't clear autoconf instances from database : {err}, instances may be incorrect")
changes.append("instances")
for api in apis: