* Fixed a bug in anvil-daemon where, when an anvil-manage-power reboot run had triggered a reboot, anvil-daemon didn't set the job_progress to '100', causing constant reboots. Also fixed a bug where the log level was hard-set to '1' instead of '2' needed during debugging.

* Updated Jobs->get_job_uuid() to accept the new 'incomplete' parameter that, when set, will look for jobs whose progress is > 1 and < 100.
* Updated ScanCore-agent_startup() to take the new 'no_db_ok' parameter which returns with '0' if no DB is available and that parameter is set to '1'.
* Fixed a logging bug in 'anvil-join-anvil'.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 04f7571097
commit 6777104398
  1. 11
      Anvil/Tools/Job.pm
  2. 66
      Anvil/Tools/Network.pm
  3. 13
      Anvil/Tools/ScanCore.pm
  4. 10
      tools/anvil-daemon
  5. 7
      tools/anvil-join-anvil
  6. 4
      tools/anvil-manage-power

@ -320,6 +320,10 @@ Parameters;
If set, this will search for the job on a specific host. If set, this will search for the job on a specific host.
=head3 incomplete (optional, default '0')
If set to C<< 1 >>, any job that is incomplete (C<< job_progress < 100 >>) is searched. If set to C<< 0 >>, only job that have not started (C<< job_progress = 0 >>) are searched.
=head3 program (required) =head3 program (required)
This is the program name to look for. Specifically, this string is used to search C<< job_command >> (anchored to the start of the column and a wild-card end, ie: C<< program => foo >> would find C<< foobar >> or C<< foo --bar >>). Be as specific as possible. If two or more results are found, no C<< job_uuid >> will be returned. There must be only one match for this method to work properly. This is the program name to look for. Specifically, this string is used to search C<< job_command >> (anchored to the start of the column and a wild-card end, ie: C<< program => foo >> would find C<< foobar >> or C<< foo --bar >>). Be as specific as possible. If two or more results are found, no C<< job_uuid >> will be returned. There must be only one match for this method to work properly.
@ -335,9 +339,11 @@ sub get_job_uuid
my $job_uuid = ""; my $job_uuid = "";
my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : $anvil->Get->host_uuid; my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : $anvil->Get->host_uuid;
my $incomplete = defined $parameter->{incomplete} ? $parameter->{incomplete} : 0;
my $program = defined $parameter->{program} ? $parameter->{program} : ""; my $program = defined $parameter->{program} ? $parameter->{program} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
host_uuid => $host_uuid, host_uuid => $host_uuid,
incomplete => $incomplete,
program => $program, program => $program,
}}); }});
@ -348,6 +354,9 @@ sub get_job_uuid
return(1); return(1);
} }
my $say_progress = $incomplete ? "< 100" : "= 0";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { say_progress => $say_progress }});
my $query = " my $query = "
SELECT SELECT
job_uuid job_uuid
@ -356,7 +365,7 @@ FROM
WHERE WHERE
job_command LIKE ".$anvil->Database->quote("%".$program."%")." job_command LIKE ".$anvil->Database->quote("%".$program."%")."
AND AND
job_progress = 0 job_progress ".$say_progress."
AND AND
job_host_uuid = ".$anvil->Database->quote($host_uuid)." job_host_uuid = ".$anvil->Database->quote($host_uuid)."
LIMIT 1 LIMIT 1

@ -2045,6 +2045,8 @@ sub get_ips
$anvil->data->{network}{$host}{interface}{$in_iface}{default_gateway} = 0 if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{default_gateway}; $anvil->data->{network}{$host}{interface}{$in_iface}{default_gateway} = 0 if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{default_gateway};
$anvil->data->{network}{$host}{interface}{$in_iface}{gateway} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{gateway}; $anvil->data->{network}{$host}{interface}{$in_iface}{gateway} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{gateway};
$anvil->data->{network}{$host}{interface}{$in_iface}{dns} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{dns}; $anvil->data->{network}{$host}{interface}{$in_iface}{dns} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{dns};
$anvil->data->{network}{$host}{interface}{$in_iface}{tx_bytes} = 0 if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{tx_bytes};
$anvil->data->{network}{$host}{interface}{$in_iface}{rx_bytes} = 0 if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{rx_bytes};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"network::${host}::interface::${in_iface}::ip" => $anvil->data->{network}{$host}{interface}{$in_iface}{ip}, "network::${host}::interface::${in_iface}::ip" => $anvil->data->{network}{$host}{interface}{$in_iface}{ip},
"network::${host}::interface::${in_iface}::subnet_mask" => $anvil->data->{network}{$host}{interface}{$in_iface}{subnet_mask}, "network::${host}::interface::${in_iface}::subnet_mask" => $anvil->data->{network}{$host}{interface}{$in_iface}{subnet_mask},
@ -2054,6 +2056,70 @@ sub get_ips
"network::${host}::interface::${in_iface}::gateway" => $anvil->data->{network}{$host}{interface}{$in_iface}{gateway}, "network::${host}::interface::${in_iface}::gateway" => $anvil->data->{network}{$host}{interface}{$in_iface}{gateway},
"network::${host}::interface::${in_iface}::dns" => $anvil->data->{network}{$host}{interface}{$in_iface}{dns}, "network::${host}::interface::${in_iface}::dns" => $anvil->data->{network}{$host}{interface}{$in_iface}{dns},
}}); }});
if ($in_iface ne "lo")
{
# Read the read and write bytes.
my $read_bytes = 0;
my $write_bytes = 0;
my $shell_call = "
if [ -e '/sys/class/net/".$in_iface."/statistics/rx_bytes' ];
then
echo -n 'rx:';
cat /sys/class/net/".$in_iface."/statistics/rx_bytes;
echo -n 'tx:';
cat /sys/class/net/".$in_iface."/statistics/tx_bytes;
else
echo 'rx:0';
echo 'tx:0';
fi";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my $transmit_sizes = "";
if ($is_local)
{
# Local call.
($transmit_sizes, my $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
's1:transmit_sizes' => $transmit_sizes,
's2:return_code' => $return_code,
}});
}
else
{
# Remote call
($transmit_sizes, my $error, my $return_code) = $anvil->Remote->call({
debug => $debug,
shell_call => $shell_call,
target => $target,
user => $remote_user,
password => $password,
remote_user => $remote_user,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
's1:transmit_sizes' => $transmit_sizes,
's2:error' => $error,
's3:return_code' => $return_code,
}});
}
foreach my $line (split/\n/, $transmit_sizes)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }});
if ($line =~ /rx:(\d+)/)
{
$anvil->data->{network}{$host}{interface}{$in_iface}{rx_bytes} = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"network::${host}::interface::${in_iface}::rx_bytes" => $anvil->data->{network}{$host}{interface}{$in_iface}{rx_bytes}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{network}{$host}{interface}{$in_iface}{rx_bytes}}).")",
}});
}
if ($line =~ /tx:(\d+)/)
{
$anvil->data->{network}{$host}{interface}{$in_iface}{tx_bytes} = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"network::${host}::interface::${in_iface}::tx_bytes" => $anvil->data->{network}{$host}{interface}{$in_iface}{tx_bytes}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{network}{$host}{interface}{$in_iface}{tx_bytes}}).")",
}});
}
}
}
} }
next if not $in_iface; next if not $in_iface;
if ($in_iface eq "lo") if ($in_iface eq "lo")

@ -100,6 +100,10 @@ Parameters;
This is the name of the scan agent. Usually this can be set as C<< $THIS_FILE >>. This is the name of the scan agent. Usually this can be set as C<< $THIS_FILE >>.
=head3 no_db_ok (optional, default 0)
If set to C<< 1 >>, if no database connections are available but otherwise the startup is OK, C<< 0 >> (no problem) is returned.
=head3 tables (required) =head3 tables (required)
This is an array reference of database tables to check when resync'ing. It is important that the tables are sorted in the order they need to be resync'ed in. (tables with primary keys before their foreign key tables). This is an array reference of database tables to check when resync'ing. It is important that the tables are sorted in the order they need to be resync'ed in. (tables with primary keys before their foreign key tables).
@ -114,9 +118,11 @@ sub agent_startup
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "ScanCore->agent_startup()" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "ScanCore->agent_startup()" }});
my $agent = defined $parameter->{agent} ? $parameter->{agent} : ""; my $agent = defined $parameter->{agent} ? $parameter->{agent} : "";
my $no_db_ok = defined $parameter->{no_db_ok} ? $parameter->{no_db_ok} : "";
my $tables = defined $parameter->{tables} ? $parameter->{tables} : ""; my $tables = defined $parameter->{tables} ? $parameter->{tables} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
agent => $agent, agent => $agent,
no_db_ok => $no_db_ok,
tables => $tables, tables => $tables,
}}); }});
@ -160,8 +166,15 @@ sub agent_startup
{ {
# No databases, exit. # No databases, exit.
$anvil->Log->entry({source => $agent, line => __LINE__, 'print' => 1, level => 0, secure => 0, key => "error_0003"}); $anvil->Log->entry({source => $agent, line => __LINE__, 'print' => 1, level => 0, secure => 0, key => "error_0003"});
if ($no_db_ok)
{
return(0);
}
else
{
return(1); return(1);
} }
}
my $table_count = @{$tables}; my $table_count = @{$tables};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { table_count => $table_count }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { table_count => $table_count }});

@ -144,7 +144,7 @@ $anvil->data->{switches}{'no-start'} = 0;
$anvil->data->{switches}{'startup-only'} = 0; $anvil->data->{switches}{'startup-only'} = 0;
$anvil->Get->switches; $anvil->Get->switches;
$anvil->Log->level({set => 1}); $anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1}); $anvil->Log->secure({set => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0115", variables => { program => $THIS_FILE }});
@ -866,7 +866,7 @@ sub boot_time_tasks
# If the uptime is less than ten minutes, clear the reboot flag. # If the uptime is less than ten minutes, clear the reboot flag.
my $uptime = $anvil->Get->uptime; my $uptime = $anvil->Get->uptime;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { uptime => $uptime }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { uptime => $uptime }});
# Now find out if a reboot is listed as needed and when it was last changed. # Now find out if a reboot is listed as needed and when it was last changed.
my $reboot_needed = 0; my $reboot_needed = 0;
@ -921,7 +921,11 @@ AND
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { reboot_needed => $reboot_needed }});
# Check to see if there was a reboot job in progress. If so, finish it off. # Check to see if there was a reboot job in progress. If so, finish it off.
my $job_uuid = $anvil->Job->get_job_uuid({debug => 2, program => "anvil-manage-power"}); my $job_uuid = $anvil->Job->get_job_uuid({
debug => 2,
program => "anvil-manage-power",
incomplete => 1,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { job_uuid => $job_uuid }});
if ($job_uuid) if ($job_uuid)

@ -216,11 +216,14 @@ sub configure_pacemaker
($return_code) = $anvil->System->disable_daemon({daemon => "ksm.service"}); ($return_code) = $anvil->System->disable_daemon({daemon => "ksm.service"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { return_code => $return_code }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { return_code => $return_code }});
$return_code = undef; $return_code = undef;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0095", variables => { daemon => "ksm.service" }});
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0095,!!daemon!ksm.service!!");
($return_code) = $anvil->System->stop_daemon({daemon => "ksmtuned.service"}); ($return_code) = $anvil->System->stop_daemon({daemon => "ksmtuned.service"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { return_code => $return_code }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { return_code => $return_code }});
$return_code = undef; $return_code = undef;
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0095,!!daemon!ksm.service!!"); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0095", variables => { daemon => "ksmtuned.service" }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0095", variables => { daemon => "drbd.service" }}); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0095,!!daemon!ksmtuned.service!!");
# If there is no corosync.conf, see if the peer has it. If so, copy it. If not, we'll initialize the # If there is no corosync.conf, see if the peer has it. If so, copy it. If not, we'll initialize the
# cluster shortly. # cluster shortly.

@ -215,7 +215,9 @@ sub do_poweroff
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => $say_task}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => $say_task});
sleep $difference; sleep $difference;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0227", variables => { task => $task eq "poweroff" ? "#!string!log_0225!#" : "#!string!log_0226!#" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, secure => 0, key => "log_0227", variables => {
task => $task eq "poweroff" ? "#!string!log_0225!#" : "#!string!log_0226!#",
}});
} }
# If I don't have a job_uuid, try to find one. # If I don't have a job_uuid, try to find one.

Loading…
Cancel
Save