From 478f6b531b7d0e8bfcde471cc664dcb54a407ba2 Mon Sep 17 00:00:00 2001 From: clearml <> Date: Tue, 31 Dec 2024 22:04:10 +0200 Subject: [PATCH] Fix crash when mongodb host is overridden with cluster settings --- apiserver/database/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apiserver/database/__init__.py b/apiserver/database/__init__.py index 57dc526..abf9e16 100644 --- a/apiserver/database/__init__.py +++ b/apiserver/database/__init__.py @@ -37,6 +37,8 @@ OVERRIDE_QUERY_ENV_KEY = "CLEARML_MONGODB_SERVICE_QUERY" class DatabaseEntry(models.Base): host = StringField(required=True) alias = StringField() + name = StringField() + db = StringField() class DatabaseFactory: @@ -78,10 +80,13 @@ class DatabaseFactory: missing.append(key) continue - entry = cls._create_db_entry(alias=alias, settings=db_entries.get(key)) + settings = {**db_entries.get(key)} + if not any(field in settings for field in ("name", "db")): + settings["name"] = key + entry = cls._create_db_entry(alias=alias, settings=settings) if override_connection_string: - con_str = furl(override_connection_string).add(path=key).url + con_str = override_connection_string log.info(f"Using override mongodb connection string for {alias}: {con_str}") entry.host = con_str else: