From 5c3d1860c8f145a65f5d5811ee744bc28e623d48 Mon Sep 17 00:00:00 2001 From: digimer Date: Fri, 19 Apr 2024 01:44:42 -0400 Subject: [PATCH] Made the host_key check conditional on an available DB Signed-off-by: digimer --- Anvil/Tools/Database.pm | 2 +- Anvil/Tools/Remote.pm | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 0c206ec1..baa4f9b9 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -3687,7 +3687,7 @@ WHERE ;"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__}); - my $count = @{$results}; + my $count = ref($results) eq "ARRAY" ? @{$results} : 0; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { results => $results, count => $count, diff --git a/Anvil/Tools/Remote.pm b/Anvil/Tools/Remote.pm index 9862b5bf..d550fdcd 100644 --- a/Anvil/Tools/Remote.pm +++ b/Anvil/Tools/Remote.pm @@ -1218,8 +1218,9 @@ sub _check_known_hosts_for_target return($known_machine) } + ### NOTE: This is called by ocf:alteeve:server, so there might not be a database available. # Make sure we've loaded hosts. - if (not exists $anvil->data->{hosts}{host_uuid}) + if (($anvil->data->{sys}{database}{read_uuid}) && (not exists $anvil->data->{hosts}{host_uuid})) { $anvil->Database->get_hosts({debug => $debug}); } @@ -1250,6 +1251,12 @@ sub _check_known_hosts_for_target # If we're already planning to delete next if $delete_if_found; + # If we don't have any DBs to read from, we're also done. + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, secure => 0, list => { + 'sys::database::read_uuid' => $anvil->data->{sys}{database}{read_uuid}, + }}); + next if not $anvil->data->{sys}{database}{read_uuid}; + my $target_host_uuid = ""; my $target_host_name = ""; if ($is_ip)