Fixed a bug where IPs were being marked repeatedly as DELETEd.

* Database->get_ip_addresses() was marking IPs that weren't on a network
  we managed, the IP would be marked as DELETEd, which caused problems
  with initializing targets, and it generated a lot of repeat alerts.
* Updated logging in Network.pm to help with debugging.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 11 months ago
parent 92ed77e05b
commit 282fdbe7e0
  1. 52
      Anvil/Tools/Database.pm
  2. 2
      Anvil/Tools/Network.pm
  3. 4
      tools/anvil-daemon
  4. 4
      tools/anvil-manage-dr
  5. 5
      tools/striker-initialize-host

@ -4579,51 +4579,37 @@ AND
$on_interface = $anvil->data->{hosts}{host_uuid}{$host_uuid}{network_interfaces}{network_interface_uuid}{$ip_address_on_uuid}{network_interface_name}; $on_interface = $anvil->data->{hosts}{host_uuid}{$host_uuid}{network_interfaces}{network_interface_uuid}{$ip_address_on_uuid}{network_interface_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { on_interface => $on_interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { on_interface => $on_interface }});
} }
my $on_network = ($on_interface =~ /^(.*?)_/)[0];
if (not defined $on_network)
{
# This isn't a network we should know about (ie: it might be a stray 'virbrX'
# birdge), delete this IP.
my $query = "
UPDATE
ip_addresses
SET
ip_address_note = 'DELETED',
modified_date = ".$anvil->Database->quote($anvil->Database->refresh_timestamp)."
WHERE
ip_address_uuid = ".$anvil->Database->quote($ip_address_uuid)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
next;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { on_network => $on_network }});
# Store it. # We want to be able to map IPs to hosts.
$anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{ip_address} = $ip_address_address; $anvil->data->{ip_addresses}{$ip_address_address}{host_uuid} = $ip_address_host_uuid;
$anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{subnet_mask} = $ip_address_subnet_mask; $anvil->data->{ip_addresses}{$ip_address_address}{ip_address_uuid} = $ip_address_uuid;
$anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{on_interface} = $on_interface;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"hosts::host_uuid::${host_uuid}::network::${on_network}::ip_address" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{ip_address}, "ip_addresses::${ip_address_address}::host_uuid" => $anvil->data->{ip_addresses}{$ip_address_address}{host_uuid},
"hosts::host_uuid::${host_uuid}::network::${on_network}::subnet_mask" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{subnet_mask}, "ip_addresses::${ip_address_address}::ip_address_uuid" => $anvil->data->{ip_addresses}{$ip_address_address}{ip_address_uuid},
"hosts::host_uuid::${host_uuid}::network::${on_network}::on_interface" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{on_interface},
}}); }});
$anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{subnet_mask} = $ip_address_subnet_mask; $anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{subnet_mask} = $ip_address_subnet_mask;
$anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{on_interface} = $on_interface; $anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{on_interface} = $on_interface;
$anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{on_network} = $on_network;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"hosts::host_uuid::${host_uuid}::ip_address::${ip_address_address}::subnet_mask" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{subnet_mask}, "hosts::host_uuid::${host_uuid}::ip_address::${ip_address_address}::subnet_mask" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{subnet_mask},
"hosts::host_uuid::${host_uuid}::ip_address::${ip_address_address}::on_interface" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{on_interface}, "hosts::host_uuid::${host_uuid}::ip_address::${ip_address_address}::on_interface" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{on_interface},
"hosts::host_uuid::${host_uuid}::ip_address::${ip_address_address}::on_network" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{on_network},
}}); }});
# We also want to be able to map IPs to hosts. # If this is an interface that doesn't belong to us, we're done.
$anvil->data->{ip_addresses}{$ip_address_address}{host_uuid} = $ip_address_host_uuid; my $on_network = ($on_interface =~ /^(.*?)_/)[0];
$anvil->data->{ip_addresses}{$ip_address_address}{ip_address_uuid} = $ip_address_uuid; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { on_network => $on_network }});
next if not $on_network;
# Store it by network.
$anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{ip_address} = $ip_address_address;
$anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{subnet_mask} = $ip_address_subnet_mask;
$anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{on_interface} = $on_interface;
$anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{on_network} = $on_network;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"ip_addresses::${ip_address_address}::host_uuid" => $anvil->data->{ip_addresses}{$ip_address_address}{host_uuid}, "hosts::host_uuid::${host_uuid}::network::${on_network}::ip_address" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{ip_address},
"ip_addresses::${ip_address_address}::ip_address_uuid" => $anvil->data->{ip_addresses}{$ip_address_address}{ip_address_uuid}, "hosts::host_uuid::${host_uuid}::network::${on_network}::subnet_mask" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{subnet_mask},
"hosts::host_uuid::${host_uuid}::network::${on_network}::on_interface" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{network}{$on_network}{on_interface},
"hosts::host_uuid::${host_uuid}::ip_address::${ip_address_address}::on_network" => $anvil->data->{hosts}{host_uuid}{$host_uuid}{ip_address}{$ip_address_address}{on_network},
}}); }});
} }

@ -2435,7 +2435,7 @@ sub get_ip_from_mac
=head2 get_ips =head2 get_ips
This method checks the local system for interfaces and stores them in: This method checks the target system for interfaces and stores them in:
* C<< network::<target>::interface::<iface_name>::ip >> - If an IP address is set * C<< network::<target>::interface::<iface_name>::ip >> - If an IP address is set
* C<< network::<target>::interface::<iface_name>::subnet_mask >> - If an IP is set * C<< network::<target>::interface::<iface_name>::subnet_mask >> - If an IP is set

@ -456,7 +456,7 @@ sub handle_periodic_tasks
# Check that the users we care about have ssh public keys and they're recorded in ssh_keys. # Check that the users we care about have ssh public keys and they're recorded in ssh_keys.
$anvil->System->check_ssh_keys({debug => 2}); $anvil->System->check_ssh_keys({debug => 2});
$anvil->System->update_hosts({debug => 3}); $anvil->System->update_hosts({debug => 2});
# Check if the files on disk have changed. Even if it is time to check, don't if a job is # Check if the files on disk have changed. Even if it is time to check, don't if a job is
# running. # running.
@ -1355,7 +1355,7 @@ AND
} }
# Make sure /etc/hosts is updated. # Make sure /etc/hosts is updated.
$anvil->System->update_hosts(); $anvil->System->update_hosts({debug => 2});
# This handles weird bits for things like bug work-arounds. # This handles weird bits for things like bug work-arounds.
handle_special_cases($anvil); handle_special_cases($anvil);

@ -1945,7 +1945,7 @@ sub process_remove
### If we're here, we can now update the resource config file to remove the DR host. ### If we're here, we can now update the resource config file to remove the DR host.
# Refresh the IP info (usually scrubbed by this point) # Refresh the IP info (usually scrubbed by this point)
$anvil->Database->get_ip_addresses(); $anvil->Database->get_ip_addresses({debug => 2});
# First loop to build the node sections, then we'll loop to build the connections # First loop to build the node sections, then we'll loop to build the connections
my $node1_volumes = ""; my $node1_volumes = "";
@ -2901,7 +2901,7 @@ sub process_protect
} }
# Refresh the IP info (usually scrubbed by this point) # Refresh the IP info (usually scrubbed by this point)
$anvil->Database->get_ip_addresses(); $anvil->Database->get_ip_addresses({debug => 2});
# The connections. Node 1 to 2 always uses the BCN, Either node to DR needs # The connections. Node 1 to 2 always uses the BCN, Either node to DR needs
my $storage_network = "sn1"; my $storage_network = "sn1";

@ -163,7 +163,7 @@ sub add_databases
$anvil->Network->get_ips({debug => 3}); $anvil->Network->get_ips({debug => 3});
$anvil->Network->get_ips({ $anvil->Network->get_ips({
debug => 3, debug => 2,
target => $target, target => $target,
remote_user => "root", remote_user => "root",
password => $anvil->data->{data}{password}, password => $anvil->data->{data}{password},
@ -171,7 +171,7 @@ sub add_databases
}); });
my $local_host = $anvil->Get->short_host_name(); my $local_host = $anvil->Get->short_host_name();
my ($match) = $anvil->Network->find_matches({ my ($match) = $anvil->Network->find_matches({
debug => 3, debug => 2,
first => $local_host, first => $local_host,
second => $target, second => $target,
source => $THIS_FILE, source => $THIS_FILE,
@ -283,6 +283,7 @@ sub add_databases
# Find a match between the target and the peer. # Find a match between the target and the peer.
my ($match) = $anvil->Network->find_matches({ my ($match) = $anvil->Network->find_matches({
debug => 2,
first => $target, first => $target,
second => $uuid, second => $uuid,
source => $THIS_FILE, source => $THIS_FILE,

Loading…
Cancel
Save