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 <mkelly@alteeve.ca>
main
digimer 11 months ago
parent 282fdbe7e0
commit 827cf1f331
  1. 14
      Anvil/Tools/Network.pm
  2. 16
      Anvil/Tools/System.pm
  3. 1
      tools/anvil-daemon
  4. 4
      tools/scancore

@ -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" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Network->find_matches()", parameter => "first" }});
return(""); return("");
} }
elsif (ref($anvil->data->{network}{$first}) ne "HASH") if (ref($anvil->data->{network}{$first}) ne "HASH")
{ {
$anvil->Network->load_ips({ $anvil->Network->load_ips({
debug => $debug, debug => $debug,
@ -2096,12 +2096,13 @@ sub find_matches
return(""); return("");
} }
} }
if (not $second) 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" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Network->find_matches()", parameter => "second" }});
return(""); return("");
} }
elsif (ref($anvil->data->{network}{$second}) ne "HASH") if (ref($anvil->data->{network}{$second}) ne "HASH")
{ {
$anvil->Network->load_ips({ $anvil->Network->load_ips({
debug => $debug, debug => $debug,
@ -2145,13 +2146,14 @@ sub find_matches
foreach my $second_interface (sort {$b cmp $a} keys %{$anvil->data->{network}{$second}{interface}}) 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_ip = $anvil->data->{network}{$second}{interface}{$second_interface}{ip};
my $second_subnet_mask = $anvil->data->{network}{$second}{interface}{$second_interface}{subnet_mask}; my $second_subnet_mask = $anvil->data->{network}{$second}{interface}{$second_interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
second => $second, 's1:second' => $second,
second_interface => $second_interface, 's2:second_interface' => $second_interface,
second_ip => $second_ip, 's3:second_ip' => $second_ip,
second_subnet_mask => $second_subnet_mask, 's4:second_subnet_mask' => $second_subnet_mask,
}}); }});
if (($second_ip) && ($second_subnet_mask)) if (($second_ip) && ($second_subnet_mask))
{ {

@ -2836,6 +2836,7 @@ sub disable_daemon
return($return_code); return($return_code);
} }
=head2 generate_state_json =head2 generate_state_json
This method generates the C<< all_status.json >> file. 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 $mac_address = $anvil->data->{network}{$host}{interface}{$interface}{mac_address};
my $iface_hash = {}; my $iface_hash = {};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:interface" => $interface, "s1:host" => $host,
"s2:mac_address" => $mac_address, "s2:interface" => $interface,
"s3:type" => $type, "s3:mac_address" => $mac_address,
"s4:mtu" => $mtu, "s4:type" => $type,
"s5:configured" => $configured, "s5:mtu" => $mtu,
"s6:host_uuid" => $host_uuid, "s6:configured" => $configured,
"s7:host_key" => $host_key, "s7:host_uuid" => $host_uuid,
"s8:host_key" => $host_key,
}}); }});
$iface_hash->{name} = $interface; $iface_hash->{name} = $interface;
$iface_hash->{type} = $type; $iface_hash->{type} = $type;

@ -209,7 +209,6 @@ while(1)
# Mark that we don't want to check the database now. # Mark that we don't want to check the database now.
$check_if_database_is_configured = 0; $check_if_database_is_configured = 0;
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
{ {
# Run the normal tasks # Run the normal tasks

@ -91,8 +91,10 @@ $anvil->Storage->record_md5sums();
# Connect to DBs. # Connect to DBs.
wait_for_database($anvil); 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. # If we're not configured, sleep.
wait_until_configured($anvil); #wait_until_configured($anvil);
# Startup tasks. # Startup tasks.
startup_tasks($anvil); startup_tasks($anvil);

Loading…
Cancel
Save