* Updated Database->connect() to delete 'database::<uuid>' when a peer's database is not a matching version to avoid later use attempts.

* Fixed a bug in Database->resync_databases() where tables that pluralized with the suffix 'es' were not being singularized properly, so the '_uuid' column wasn't found and preventing resync of that table.
* Fixed a bug in System->maintenance_mode() and System->reboot_needed() where the variable read wasn't restricted to the local host UUID.
* Reordered the config and maintenance mode checks in striker so that configure is shown even if maintenance mode is somehow set without configuration being done.
* Updated the .spec for .16 RPM release.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent c6e781d80b
commit e483d6e9a1
  1. 28
      Anvil/Tools/Database.pm
  2. 15
      Anvil/Tools/System.pm
  3. 34
      cgi-bin/striker
  4. 5
      rpm/SPECS/anvil.spec

@ -830,6 +830,10 @@ sub connect
local_version => $anvil->_anvil_version,
target_version => $remote_version,
}});
# Delete the information about this database. We'll try again on nexy
# ->connect().
delete $anvil->data->{database}{$uuid};
next;
}
}
@ -4731,16 +4735,28 @@ sub resync_databases
}});
# If there is a column name that is '<table>_uuid', or the same with the table's name minus
# the last 's', this will be the UUID column to keep records linked in history. We'll need to
# know this off the bat. Tables where we don't find a UUID column won't be sync'ed.
# the last 's' or 'es', this will be the UUID column to keep records linked in history. We'll
# need to know this off the bat. Tables where we don't find a UUID column won't be sync'ed.
my $column1 = $table."_uuid";
my $column2 = "";
my $column3 = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { column1 => $column1 }});
if ($table =~ /^(.*)s$/)
{
$column2 = $1."_uuid";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { column2 => $column2 }});
}
if ($table =~ /^(.*)es$/)
{
$column3 = $1."_uuid";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { column3 => $column3 }});
}
my $query = "SELECT column_name FROM information_schema.columns WHERE table_catalog = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{sys}{database}{name})." AND table_schema = 'public' AND table_name = ".$anvil->data->{sys}{database}{use_handle}->quote($table)." AND data_type = 'uuid' AND is_nullable = 'NO' AND column_name = ".$anvil->data->{sys}{database}{use_handle}->quote($column1).";";
if ($column2)
if ($column3)
{
$query = "SELECT column_name FROM information_schema.columns WHERE table_catalog = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{sys}{database}{name})." AND table_schema = 'public' AND table_name = ".$anvil->data->{sys}{database}{use_handle}->quote($table)." AND data_type = 'uuid' AND is_nullable = 'NO' AND (column_name = ".$anvil->data->{sys}{database}{use_handle}->quote($column1)." OR column_name = ".$anvil->data->{sys}{database}{use_handle}->quote($column2)." OR column_name = ".$anvil->data->{sys}{database}{use_handle}->quote($column3).");";
}
elsif ($column2)
{
$query = "SELECT column_name FROM information_schema.columns WHERE table_catalog = ".$anvil->data->{sys}{database}{use_handle}->quote($anvil->data->{sys}{database}{name})." AND table_schema = 'public' AND table_name = ".$anvil->data->{sys}{database}{use_handle}->quote($table)." AND data_type = 'uuid' AND is_nullable = 'NO' AND (column_name = ".$anvil->data->{sys}{database}{use_handle}->quote($column1)." OR column_name = ".$anvil->data->{sys}{database}{use_handle}->quote($column2).");";
}
@ -5454,8 +5470,6 @@ sub _find_behind_databases
}
}
# Preset all tables to have an initial 'modified_date' of 0.
foreach my $table (sort {$a cmp $b} @{$anvil->data->{sys}{database}{check_tables}})
{
@ -5610,10 +5624,10 @@ sub _mark_database_as_behind
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { uuid => $uuid }});
$anvil->data->{sys}{database}{to_update}{$uuid}{behind} = 1;
$anvil->data->{sys}{database}{resync_needed} = 1;
$anvil->data->{sys}{database}{resync_needed} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::database::to_update::${uuid}::behind" => $anvil->data->{sys}{database}{to_update}{$uuid}{behind},
"sys::database::resync_needed" => $anvil->data->{sys}{database}{resync_needed},
"sys::database::resync_needed" => $anvil->data->{sys}{database}{resync_needed},
}});
# We can't trust this database for reads, so switch to another database for reads if

@ -1062,8 +1062,14 @@ sub maintenance_mode
}
}
my ($maintenance_mode, $variable_uuid, $modified_date) = $anvil->Database->read_variable({debug => $debug, variable_name => "maintenance_mode"});
my ($maintenance_mode, $variable_uuid, $modified_date) = $anvil->Database->read_variable({
debug => $debug,
variable_name => "maintenance_mode",
variable_source_table => "hosts",
variable_source_uuid => $anvil->Get->host_uuid,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
debug => $debug,
maintenance_mode => $maintenance_mode,
variable_uuid => $variable_uuid,
modified_date => $modified_date,
@ -1879,7 +1885,12 @@ sub reboot_needed
}
}
my ($reboot_needed, $variable_uuid, $modified_date) = $anvil->Database->read_variable({debug => $debug, variable_name => "reboot::needed"});
my ($reboot_needed, $variable_uuid, $modified_date) = $anvil->Database->read_variable({
debug => $debug,
variable_name => "reboot::needed",
variable_source_table => "hosts",
variable_source_uuid => $anvil->Get->host_uuid,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
reboot_needed => $reboot_needed,
variable_uuid => $variable_uuid,

@ -61,22 +61,21 @@ if (not $anvil->data->{sys}{database}{connections})
}
# If any jobs are pending/running, show the "unavailable" option.
my $available = check_availability($anvil);
my $configured = $available ? $anvil->System->check_if_configured : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
available => $available,
configured => $configured,
}});
if (not $available)
{
# Set the body to 'say::maintenance'.
$anvil->data->{form}{body} = $anvil->data->{say}{maintenance};
}
elsif (not $configured)
my $configured = $anvil->System->check_if_configured;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { configured => $configured }});
my $available = $configured ? check_availability($anvil) : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {available => $available }});
if (not $configured)
{
# If there is no user account yet, then the system is new and needs to be reconfigured.
configure_striker($anvil);
}
elsif (not $available)
{
# Set the body to 'say::maintenance'.
$anvil->data->{form}{body} = $anvil->data->{say}{maintenance};
}
else
{
# Normal operation
@ -170,7 +169,7 @@ sub process_task
my $logged_in = 0;
$anvil->data->{cgi}{login}{value} = "" if not defined $anvil->data->{cgi}{login}{value};
$anvil->data->{cgi}{logout}{value} = "" if not defined $anvil->data->{cgi}{logout}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"cgi::login::value" => $anvil->data->{cgi}{login}{value},
"cgi::logout::value" => $anvil->data->{cgi}{logout}{value},
}});
@ -190,6 +189,7 @@ sub process_task
elsif ($anvil->data->{cgi}{logout}{value})
{
# Bye now!
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cgi::logout::value" => $anvil->data->{cgi}{logout}{value} }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0215"});
$anvil->Account->logout();
}
@ -901,7 +901,7 @@ sub check_availability
my $jobs_list = "#!string!striker_0097!#";
my $return = $anvil->Database->get_jobs({ended_within => 300});
my $count = @{$return};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { count => $count }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { count => $count }});
if ($count)
{
$jobs_list = "";
@ -918,7 +918,7 @@ sub check_availability
my $job_title = $hash_ref->{job_title};
my $job_description = $hash_ref->{job_description};
my $job_status = $hash_ref->{job_status};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
job_uuid => $job_uuid,
job_command => $job_command,
job_data => $job_data,
@ -933,7 +933,7 @@ sub check_availability
# Skip jobs that finished more than five minutes ago.
my $job_finished = time - $job_updated;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
's1:time' => time,
's2:job_updated' => $job_updated,
's3:job_finished' => $job_finished,
@ -947,7 +947,7 @@ sub check_availability
# Convert the double-banged strings into a proper message.
my $say_title = $job_title ? $anvil->Words->parse_banged_string({key_string => $job_title}) : "";
my $say_description = $job_description ? $anvil->Words->parse_banged_string({key_string => $job_description}) : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
job_title => $job_title,
say_description => $say_description,
}});

@ -393,6 +393,11 @@ firewall-cmd --add-service=postgresql --permanent
%changelog
* Fri Sep 14 2018 Madison Kelly <mkelly@alteeve.ca> 3.0-16
- Added htop as a -core dependency.
- Now enables anvil-daemon.
- Disabled 'postun' for now.
* Thu Aug 30 2018 Madison Kelly <mkelly@alteeve.ca> 3.0-15
- Added perl-HTML-FromText and perl-HTML-Strip to anvil-core requires list.
- Added a check to see if /usr/share/anvil exists before trying to create it.

Loading…
Cancel
Save