From fd5d603d86028669b5d1f249fd3b84092c911421 Mon Sep 17 00:00:00 2001 From: Heitor Matsui Date: Wed, 20 Mar 2024 18:33:26 -0300 Subject: [PATCH] Fix runtime_config_get method to avoid type error An issue was found when config_applied for a host assumed the default value, which is the string "install" (refer to [1]), returning a type error in runtime_config_get trying to compare string "install" with a column "id" with type int. This commit fixes runtime_config_get method by inverting the logic: if the id passed is an int then compare with id, if it is not then assume it is a string and compare with config_uuid column. [1] https://opendev.org/starlingx/config/src/commit/15aefdc46840b1cf9059ce0de21f67c24d4d0852/sysinv/sysinv/sysinv/sysinv/agent/manager.py#L116 Test Plan PASS: set config_applied="install" for a host, force inventory report and observe no more database errors on sysinv.log PASS: install/bootstrap/unlock AIO-DX Story: 2010676 Task: 49745 Signed-off-by: Heitor Matsui Change-Id: I9c687a1eb67c62291f1d2aa9cef1d6fbe993d0fa --- sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py b/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py index 834566e58a..401cdbd4aa 100644 --- a/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py +++ b/sysinv/sysinv/sysinv/sysinv/db/sqlalchemy/api.py @@ -9509,12 +9509,12 @@ class Connection(api.Connection): def runtime_config_get(self, id, host_id=None): query = model_query(models.RuntimeConfig) - if utils.is_uuid_like(id): + if isinstance(id, int): + query = query.filter_by(id=id) + else: query = query.filter_by(config_uuid=id) if host_id: query = query.filter_by(forihostid=host_id) - else: - query = query.filter_by(id=id) try: result = query.one()