Added a periodic check to ensure all users can ping. This fixes a bug where a local striker dashboard whose DB was stopped wouldn't work.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 65e02d01ea
commit a633ab7f63
  1. 1
      Anvil/Tools.pm
  2. 18
      Anvil/Tools/Network.pm
  3. 2
      cgi-bin/striker
  4. 1
      share/words.xml
  5. 33
      tools/anvil-daemon

@ -1246,6 +1246,7 @@ sub _set_paths
su => "/usr/bin/su", su => "/usr/bin/su",
'subscription-manager' => "/usr/sbin/subscription-manager", 'subscription-manager' => "/usr/sbin/subscription-manager",
swapon => "/usr/sbin/swapon", swapon => "/usr/sbin/swapon",
sysctl => "/usr/sbin/sysctl",
systemctl => "/usr/bin/systemctl", systemctl => "/usr/bin/systemctl",
timeout => "/usr/bin/timeout", timeout => "/usr/bin/timeout",
touch => "/usr/bin/touch", touch => "/usr/bin/touch",

@ -2876,22 +2876,34 @@ sub ping
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
} }
$shell_call .= " || ".$anvil->data->{path}{exe}{echo}." timeout"; $shell_call .= " || ".$anvil->data->{path}{exe}{echo}." timeout";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my $pinged = 0; my $pinged = 0;
my $average_ping_time = 0; my $average_ping_time = 0;
foreach my $try (1..$count) foreach my $try (1..$count)
{ {
last if $pinged; last if $pinged;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { count => $count, try => $try }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
count => $count,
try => $try,
}});
my $output = ""; my $output = "";
my $error = ""; my $error = "";
# If the 'target' is set, we'll call over SSH unless 'target' is our host name. # If the 'target' is set, we'll call over SSH unless 'target' is our host name.
if ($anvil->Network->is_local({host => $target})) my $is_local = $anvil->Network->is_local({host => $target});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
target => $target,
is_local => $is_local,
}});
if ($is_local)
{ {
### Local calls ### Local calls
($output, my $return_code) = $anvil->System->call({shell_call => $shell_call}); ($output, my $return_code) = $anvil->System->call({
debug => $debug,
shell_call => $shell_call,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output, return_code => $return_code }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output, return_code => $return_code }});
} }
else else

@ -65,7 +65,7 @@ if (not -e $anvil->data->{path}{data}{host_uuid})
print_and_exit($anvil); print_and_exit($anvil);
} }
$anvil->Database->connect({debug => 3}); $anvil->Database->connect({debug => 2});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections}) if (not $anvil->data->{sys}{database}{connections})
{ {

@ -2074,6 +2074,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<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> <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>
<key name="log_0681">Testing that our short host name resolves to one of our IP prior to starting the cluster.</key> <key name="log_0681">Testing that our short host name resolves to one of our IP prior to starting the cluster.</key>
<key name="log_0682">Changing the ownership of: [#!variable!file!#] to be owned by: [#!variable!user!#:#!variable!user!#].</key> <key name="log_0682">Changing the ownership of: [#!variable!file!#] to be owned by: [#!variable!user!#:#!variable!user!#].</key>
<key name="log_0683">Enabling 'ping' for all users.</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>

@ -413,6 +413,39 @@ sub check_network
check_firewall($anvil); check_firewall($anvil);
} }
# Check that all users can ping.
if (1)
{
my $shell_call = $anvil->data->{path}{exe}{sysctl}." net.ipv4.ping_group_range";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call, source => $THIS_FILE, line => __LINE__});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output }});
if ($output =~ /net.ipv4.ping_group_range = (\d+)\t(\d+)$/)
{
my $lowest_uid = $1;
my $highest_uid = $2;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
lowest_uid => $lowest_uid,
highest_uid => $highest_uid,
}});
if ($highest_uid < 2000)
{
# Tell the user we're enabling ping for all users.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0683"});
my $shell_call = $anvil->data->{path}{exe}{sysctl}." -w net.ipv4.ping_group_range=\"0 2147483647\"";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call, source => $THIS_FILE, line => __LINE__});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { output => $output }});
}
}
}
return(0); return(0);
} }

Loading…
Cancel
Save