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)