From 827cf1f331f34b5fc44c92c675bf044018fd25ca Mon Sep 17 00:00:00 2001 From: digimer Date: Wed, 17 Jan 2024 23:17:59 -0500 Subject: [PATCH] Fixed a bug that was crashing anvil-daemon * Network->find_matches() was trying to compare two IPs when the second IP wasn't actually defined. * Disabled scancore's blocking of running before the host is configured. Signed-off-by: digimer --- Anvil/Tools/Network.pm | 14 ++++++++------ Anvil/Tools/System.pm | 16 +++++++++------- tools/anvil-daemon | 1 - tools/scancore | 4 +++- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Anvil/Tools/Network.pm b/Anvil/Tools/Network.pm index 41c61f3a..5b49a639 100644 --- a/Anvil/Tools/Network.pm +++ b/Anvil/Tools/Network.pm @@ -2079,7 +2079,7 @@ sub find_matches $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Network->find_matches()", parameter => "first" }}); return(""); } - elsif (ref($anvil->data->{network}{$first}) ne "HASH") + if (ref($anvil->data->{network}{$first}) ne "HASH") { $anvil->Network->load_ips({ debug => $debug, @@ -2096,12 +2096,13 @@ sub find_matches return(""); } } + if (not $second) { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Network->find_matches()", parameter => "second" }}); return(""); } - elsif (ref($anvil->data->{network}{$second}) ne "HASH") + if (ref($anvil->data->{network}{$second}) ne "HASH") { $anvil->Network->load_ips({ debug => $debug, @@ -2145,13 +2146,14 @@ sub find_matches foreach my $second_interface (sort {$b cmp $a} keys %{$anvil->data->{network}{$second}{interface}}) { + next if not exists $anvil->data->{network}{$second}{interface}{$second_interface}{ip}; my $second_ip = $anvil->data->{network}{$second}{interface}{$second_interface}{ip}; my $second_subnet_mask = $anvil->data->{network}{$second}{interface}{$second_interface}{subnet_mask}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - second => $second, - second_interface => $second_interface, - second_ip => $second_ip, - second_subnet_mask => $second_subnet_mask, + 's1:second' => $second, + 's2:second_interface' => $second_interface, + 's3:second_ip' => $second_ip, + 's4:second_subnet_mask' => $second_subnet_mask, }}); if (($second_ip) && ($second_subnet_mask)) { diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index e45ec6d4..08baf5ff 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -2836,6 +2836,7 @@ sub disable_daemon return($return_code); } + =head2 generate_state_json This method generates the C<< all_status.json >> file. @@ -2925,13 +2926,14 @@ sub generate_state_json my $mac_address = $anvil->data->{network}{$host}{interface}{$interface}{mac_address}; my $iface_hash = {}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "s1:interface" => $interface, - "s2:mac_address" => $mac_address, - "s3:type" => $type, - "s4:mtu" => $mtu, - "s5:configured" => $configured, - "s6:host_uuid" => $host_uuid, - "s7:host_key" => $host_key, + "s1:host" => $host, + "s2:interface" => $interface, + "s3:mac_address" => $mac_address, + "s4:type" => $type, + "s5:mtu" => $mtu, + "s6:configured" => $configured, + "s7:host_uuid" => $host_uuid, + "s8:host_key" => $host_key, }}); $iface_hash->{name} = $interface; $iface_hash->{type} = $type; diff --git a/tools/anvil-daemon b/tools/anvil-daemon index d0714920..c8d6796a 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -209,7 +209,6 @@ while(1) # Mark that we don't want to check the database now. $check_if_database_is_configured = 0; - if ($anvil->data->{sys}{database}{connections}) { # Run the normal tasks diff --git a/tools/scancore b/tools/scancore index 5c387936..e4e842d8 100755 --- a/tools/scancore +++ b/tools/scancore @@ -91,8 +91,10 @@ $anvil->Storage->record_md5sums(); # Connect to DBs. wait_for_database($anvil); +### NOTE: We need to collect data from the start. Once confirmed this isn't introducing old problems, remove +### this function # If we're not configured, sleep. -wait_until_configured($anvil); +#wait_until_configured($anvil); # Startup tasks. startup_tasks($anvil);