Merge pull request #207 from ClusterLabs/anvil-tools-dev

* Fixed a bug where ethtool's Media type contained tab characters tha…
main
Digimer 3 years ago committed by GitHub
commit 3f848aa194
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      Anvil/Tools/Database.pm
  2. 69
      Anvil/Tools/Server.pm
  3. 7
      share/words.xml
  4. 2
      tools/anvil-daemon
  5. 15
      tools/anvil-update-states

@ -15680,6 +15680,15 @@ sub resync_databases
return(0); return(0);
} }
# If we're hosting servers, don't resync. Too high of a risk of oom-killer being triggered.
my $server_count = $anvil->Server->count_servers({debug => $debug});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { server_count => $server_count }});
if ($server_count)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0680", variables => { count => $server_count }});
return(0);
}
### NOTE: Don't sort this array, we need to resync in the order that the user passed the tables to us ### NOTE: Don't sort this array, we need to resync in the order that the user passed the tables to us
### to avoid trouble with primary/foreign keys. ### to avoid trouble with primary/foreign keys.
# We're going to use the array of tables assembles by _find_behind_databases() stored in # We're going to use the array of tables assembles by _find_behind_databases() stored in

@ -14,6 +14,7 @@ my $THIS_FILE = "Server.pm";
### Methods; ### Methods;
# active_migrations # active_migrations
# boot_virsh # boot_virsh
# count_servers
# find # find
# get_definition # get_definition
# get_runtime # get_runtime
@ -263,6 +264,74 @@ WHERE
return($success); return($success);
} }
=head2 count_servers
This method counts the number of hosted servers and returns that number. If C<< virsh >> is not available, C<< 0 >> is returned. Note that it's B< possible >>, though unlikely on an Anvil!, that a qemu server is running outside C<< libvirtd >>.
This method takes no parameters.
=cut
sub count_servers
{
my $self = shift;
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Server->count_servers()" }});
my $count = 0;
if (-e $anvil->data->{path}{exe}{virsh})
{
my $shell_call = $anvil->data->{path}{exe}{virsh}." list";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call, debug => $debug});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
output => $output,
return_code => $return_code,
}});
foreach my $line (split/\n/, $output)
{
$line = $anvil->Words->clean_spaces({string => $line});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }});
if ($line =~ /^\d+ (.*) (.*?)$/)
{
=cut
* Server states;
running - The domain is currently running on a CPU
idle - The domain is idle, and not running or runnable. This can be caused because the domain is waiting on IO (a traditional wait state) or has gone to sleep because there was nothing else for it to do.
paused - The domain has been paused, usually occurring through the administrator running virsh suspend. When in a paused state the domain will still consume allocated resources like memory, but will not be eligible for scheduling by the hypervisor.
in shutdown - The domain is in the process of shutting down, i.e. the guest operating system has been notified and should be in the process of stopping its operations gracefully.
shut off - The domain is not running. Usually this indicates the domain has been shut down completely, or has not been started.
crashed - The domain has crashed, which is always a violent ending. Usually this state can only occur if the domain has been configured not to restart on crash.
pmsuspended - The domain has been suspended by guest power management, e.g. entered into s3 state.
=cut
my $name = $1;
my $status = $2;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
status => $status,
name => $name,
}});
if ((lc($status) eq "running") or
(lc($status) eq "paused") or
(lc($status) eq "in shutdown") or
(lc($status) eq "pmsuspended"))
{
$count++;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { count => $count }});
}
}
}
}
return($count);
}
=head2 find =head2 find
This will look on the local or a remote machine for the list of servers that are running. This will look on the local or a remote machine for the list of servers that are running.

@ -16,7 +16,7 @@ Author: Madison Kelly <mkelly@alteeve.ca>
<key name="brand_0002">Anvil!</key> <key name="brand_0002">Anvil!</key>
<key name="brand_0003">Striker</key> <key name="brand_0003">Striker</key>
<key name="brand_0004">ScanCore</key> <key name="brand_0004">ScanCore</key>
<key name="brand_0005"><![CDATA[&copy; 1997 - 2021 <a href="https://alteeve.com/" target="_new">Alteeve's Niche! Inc.</a>, Toronto, Ontario, Canada]]></key> <key name="brand_0005"><![CDATA[&copy; 1997 - 2022 <a href="https://alteeve.com/" target="_new">Alteeve's Niche! Inc.</a>, Toronto, Ontario, Canada]]></key>
<key name="brand_0006"><![CDATA[<i>Anvil!</i>]]></key> <key name="brand_0006"><![CDATA[<i>Anvil!</i>]]></key>
<key name="brand_0007">Node</key> <key name="brand_0007">Node</key>
<key name="brand_0008">DR Host</key> <key name="brand_0008">DR Host</key>
@ -2071,6 +2071,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0677">Found an installable DRBD kernel module RPM that matches the current kernel. Installing it now.</key> <key name="log_0677">Found an installable DRBD kernel module RPM that matches the current kernel. Installing it now.</key>
<key name="log_0678">[ Note ] - We need to build the DRBD kernel module. This can take a few minutes, please be patient! Use 'journalctl -f' to monitor the build process.</key> <key name="log_0678">[ Note ] - We need to build the DRBD kernel module. This can take a few minutes, please be patient! Use 'journalctl -f' to monitor the build process.</key>
<key name="log_0679">Successfully built and installed the new DRBD kernel module!</key> <key name="log_0679">Successfully built and installed the new DRBD kernel module!</key>
<key name="log_0680">We were asked to resync the database, but this host is hosting: [#!variable!count!#] server(s). Resync is not allowed when servers are running to reduce the risk the kernel's out of memory handler shooting a VM if the resync consumes too much RAM. You can see which servers are running with 'virsh list' and look for servers whose states are "running", "paused", "in shutdown" or "pmsuspended".</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. --> <!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key> <key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>
@ -3096,7 +3097,7 @@ We will sleep a bit and try again.
</key> </key>
<key name="warning_0130">[ Warning ] - The storage group: [#!variable!storage_group_name!#] had the host: [#!variable!host_name!#] as a member. This host is not a member (anymore?) of the Anvil!: [#!variable!anvil_name!#]. Removing it from the storage group now.</key> <key name="warning_0130">[ Warning ] - The storage group: [#!variable!storage_group_name!#] had the host: [#!variable!host_name!#] as a member. This host is not a member (anymore?) of the Anvil!: [#!variable!anvil_name!#]. Removing it from the storage group now.</key>
<key name="warning_0131">[ Warning ] - The postgresql server is not installed yet. Sleeping for a bit, then will check again.</key> <key name="warning_0131">[ Warning ] - The postgresql server is not installed yet. Sleeping for a bit, then will check again.</key>
<key name="warning_0132">[ Warning ] - Failed to build or install the DRBD kernel module! It is very likely that this machine will be able to run any servers until this is fixed.</key> <key name="warning_0132">[ Warning ] - Failed to build or install the DRBD kernel module! It is very unlikely that this machine will be able to run any servers until this is fixed.</key>
<!-- The entries below here are not sequential, but use a key to find the entry. --> <!-- The entries below here are not sequential, but use a key to find the entry. -->
<!-- Run 'striker-parse-os-list to find new entries. --> <!-- Run 'striker-parse-os-list to find new entries. -->
@ -3826,7 +3827,7 @@ We will sleep a bit and try again.
<key name="brand_0002">Anvil!</key> <key name="brand_0002">Anvil!</key>
<key name="brand_0003">ストライカ</key> <key name="brand_0003">ストライカ</key>
<key name="brand_0004">スカンコア</key> <key name="brand_0004">スカンコア</key>
<key name="brand_0005"><![CDATA[&copy; 1997 - 2018 <a href="https://alteeve.com/" target="_new">Alteeve's Niche! Inc.</a>, トロント、オンタリオ、カナダ]]></key> <key name="brand_0005"><![CDATA[&copy; 1997 - 2022 <a href="https://alteeve.com/" target="_new">Alteeve's Niche! Inc.</a>, トロント、オンタリオ、カナダ]]></key>
</language> </language>
</words> </words>

@ -276,7 +276,7 @@ sub check_if_mapping
# shouldn't fire in practice). # shouldn't fire in practice).
my $expire_age = 86400; my $expire_age = 86400;
my $map_network_age = 0; my $map_network_age = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:map_network_value' => $map_network_value, 's1:map_network_value' => $map_network_value,
's2:map_network_mtime' => $map_network_mtime, 's2:map_network_mtime' => $map_network_mtime,
's3:map_network_modified_date' => $map_network_modified_date, 's3:map_network_modified_date' => $map_network_modified_date,

@ -42,6 +42,10 @@ process_interface_cache($anvil);
update_network($anvil); update_network($anvil);
# Write out the interface cache # Write out the interface cache
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"cache::new_file" => $anvil->data->{cache}{new_file},
"path::data::network_cache" => $anvil->data->{path}{data}{network_cache},
}});
$anvil->Storage->write_file({ $anvil->Storage->write_file({
debug => 3, debug => 3,
body => $anvil->data->{cache}{new_file}, body => $anvil->data->{cache}{new_file},
@ -446,7 +450,14 @@ sub update_network
if ($line =~ /Supported ports: \[ (.*?) \]/i) if ($line =~ /Supported ports: \[ (.*?) \]/i)
{ {
$media = lc($1); $media = lc($1);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { media => $media }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { media => $media }});
# This can be 'tp mii', which breaks json.
if ($media =~ /\t/)
{
$media =~ s/\t/,/g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { media => $media }});
}
last; last;
} }
} }
@ -948,7 +959,7 @@ ORDER BY
network_interface_bond_uuid => defined $row->[9] ? $row->[9] : 'NULL', network_interface_bond_uuid => defined $row->[9] ? $row->[9] : 'NULL',
network_interface_bridge_uuid => defined $row->[10] ? $row->[10] : 'NULL', network_interface_bridge_uuid => defined $row->[10] ? $row->[10] : 'NULL',
}; };
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"network_interfaces::${network_interface_uuid}::network_interface_mac_address" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_mac_address}, "network_interfaces::${network_interface_uuid}::network_interface_mac_address" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_mac_address},
"network_interfaces::${network_interface_uuid}::network_interface_name" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_name}, "network_interfaces::${network_interface_uuid}::network_interface_name" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_name},
"network_interfaces::${network_interface_uuid}::network_interface_speed" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_speed}, "network_interfaces::${network_interface_uuid}::network_interface_speed" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_speed},

Loading…
Cancel
Save