From e63c68d505ee2eb88a0edef83c4a63a8d827f9f6 Mon Sep 17 00:00:00 2001 From: Alex Kavanagh Date: Fri, 7 May 2021 12:13:29 +0100 Subject: [PATCH] Fix bug where str is added to cached_hostset list The original code was appending a str to a list rather than either appending it or adding it as a list of one element. The code avoids append to avoid unintentional side-effects. Change-Id: I1466981f1d68f8dea3bbe32fdde6c4825056c0d0 Closes-Bug: #1927698 --- hooks/nova_cc_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hooks/nova_cc_utils.py b/hooks/nova_cc_utils.py index ff3628f7..a6d4cdb6 100644 --- a/hooks/nova_cc_utils.py +++ b/hooks/nova_cc_utils.py @@ -1367,7 +1367,10 @@ def resolve_hosts_for(private_address, hostname): if (not ch_ip.is_ipv6(private_address) and hostname and hostname not in cached_hostset): - return cached_hostset + hostname + hosts = cached_hostset + [hostname] + db.set(db_key, hosts) + db.flush() + return hosts return cached_hostset # Use a set to enforce uniqueness; order doesn't matter