* While working on the boot/shutdown server tools, ran into and fixed a bug where files uploaded before an Anvil! was added could not have those files sync'ed. This was fixed though the new Database->check_file_locations() method.
Signed-off-by: Digimer <digimer@alteeve.ca>
This commit is contained in:
parent
ff5cefd1c2
commit
798518ba5e
@ -17,6 +17,7 @@ my $THIS_FILE = "Database.pm";
|
||||
|
||||
### Methods;
|
||||
# archive_database
|
||||
# check_file_locations
|
||||
# check_lock_age
|
||||
# check_for_schema
|
||||
# configure_pgsql
|
||||
@ -311,6 +312,58 @@ sub archive_database
|
||||
}
|
||||
|
||||
|
||||
=head2 check_file_locations
|
||||
|
||||
This method checks to see that there is a corresponding entry in C<< file_locations >> for all Anvil! systems and files in the database. Any that are found to be missing will be set to C<< file_location_active >> -> c<< falsa >>.
|
||||
|
||||
This method takes no parameters.
|
||||
|
||||
=cut
|
||||
sub check_file_locations
|
||||
{
|
||||
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 => "Database->check_file_locations()" }});
|
||||
|
||||
# Get all the Anvil! systems we know of.
|
||||
$anvil->Database->get_anvils({debug => $debug});
|
||||
$anvil->Database->get_files({debug => $debug});
|
||||
$anvil->Database->get_file_locations({debug => $debug});
|
||||
|
||||
foreach my $anvil_name (sort {$a cmp $b} keys %{$anvil->data->{anvils}{anvil_name}})
|
||||
{
|
||||
my $anvil_uuid = $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_uuid};
|
||||
|
||||
foreach my $file_name (sort {$a cmp $b} keys %{$anvil->data->{files}{file_name}})
|
||||
{
|
||||
my $file_uuid = $anvil->data->{files}{file_name}{$file_name}{file_uuid};
|
||||
|
||||
# Does this file exist for this Anvil! system?
|
||||
if (not exists $anvil->data->{file_locations}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_location_uuid})
|
||||
{
|
||||
# Add this entry.
|
||||
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0613", variables => {
|
||||
anvil_name => $anvil_name,
|
||||
file_name => $file_name,
|
||||
}});
|
||||
|
||||
my $file_location_uuid = $anvil->Database->insert_or_update_file_locations({
|
||||
debug => $debug,
|
||||
file_location_file_uuid => $file_uuid,
|
||||
file_location_anvil_uuid => $anvil_uuid,
|
||||
file_location_active => 0,
|
||||
});
|
||||
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { file_location_uuid => $file_location_uuid }});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
=head2 check_lock_age
|
||||
|
||||
This checks to see if 'sys::database::local_lock_active' is set. If it is, its age is checked and if the age is >50% of sys::database::locking_reap_age, it will renew the lock.
|
||||
@ -2042,7 +2095,7 @@ WHERE
|
||||
$anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_node2_host_uuid} = $anvil_node2_host_uuid;
|
||||
$anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_dr1_host_uuid} = $anvil_dr1_host_uuid;
|
||||
$anvil->data->{anvils}{anvil_name}{$anvil_name}{modified_date} = $modified_date;
|
||||
$anvil->data->{anvils}{anvil_name}{$anvil_uuid}{query_time} = time;
|
||||
$anvil->data->{anvils}{anvil_name}{$anvil_name}{query_time} = time;
|
||||
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
|
||||
"anvils::anvil_name::${anvil_name}::anvil_uuid" => $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_uuid},
|
||||
"anvils::anvil_name::${anvil_name}::anvil_description" => $anvil->data->{anvils}{anvil_name}{$anvil_name}{anvil_description},
|
||||
|
@ -1593,7 +1593,7 @@ WHERE
|
||||
# value from the database is '1' or '0'. We'll convert the database version
|
||||
# for comparison versions.
|
||||
my $file_location_uuid = $anvil->data->{file_locations}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_location_uuid};
|
||||
my $old_file_location_active = $anvil->data->{file_locations}{file_location_uuid}{$file_location_uuid}{file_location_active} ? "true" : "falsa";
|
||||
my $old_file_location_active = $anvil->data->{file_locations}{file_location_uuid}{$file_location_uuid}{file_location_active} ? "true" : "false";
|
||||
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
|
||||
file_location_uuid => $file_location_uuid,
|
||||
old_file_location_active => $old_file_location_active,
|
||||
@ -1697,9 +1697,8 @@ sub process_file_menu
|
||||
process_file_change($anvil);
|
||||
}
|
||||
|
||||
# (Re)load the data.
|
||||
$anvil->Database->get_files();
|
||||
$anvil->Database->get_file_locations();
|
||||
# Make sure that all files are registered with all Anvil! systems, This also (re)loads the data.
|
||||
$anvil->Database->check_file_locations({debug => 2});
|
||||
|
||||
# Build the list of existing files.
|
||||
my $file_list = $anvil->Template->get({file => "files.html", name => "open-file-list"});
|
||||
@ -1753,8 +1752,8 @@ sub process_file_menu
|
||||
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { select_file_type => $select_file_type }});
|
||||
|
||||
# Build the anvil list
|
||||
$anvil->Database->get_anvils();
|
||||
$anvil->Database->get_file_locations();
|
||||
$anvil->Database->get_anvils({debug => 3});
|
||||
$anvil->Database->get_file_locations({debug => 3});
|
||||
|
||||
my $say_save_confirm = " ";
|
||||
my $say_purge_confirm = " ";
|
||||
|
@ -89,7 +89,7 @@ if ($anvil->data->{switches}{purge})
|
||||
if ($anvil->DRBD->gather_data())
|
||||
{
|
||||
# DRBD not found or configured.
|
||||
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, key => "scan_drbd_error_0001"});
|
||||
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "scan_drbd_error_0001"});
|
||||
$anvil->nice_exit({exit_code => 2});
|
||||
}
|
||||
|
||||
|
@ -1461,6 +1461,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
|
||||
<key name="log_0610">We're online as: [#!variable!node_name!#], but we're not quorate yet. Continuing to wait.</key>
|
||||
<key name="log_0611">We're online as: [#!variable!node_name!#] and quorate!</key>
|
||||
<key name="log_0612">We're not online yet. Waiting for 'in_ccm/crmd/join': [#!variable!in_ccm!#/#!variable!crmd!#/#!variable!join!#]. ('in_ccm' = consensus cluster member, communication layer. 'crmd' = cluster resource manager daemon is up, 'join' = allowed to host resources).</key>
|
||||
<key name="log_0613">The file: [#!variable!file_name!#] is not recorded for the Anvil! [#!variable!anvil_name!#] yet. Registering it now as not sync'ed to this Anvil! system.</key>
|
||||
|
||||
<!-- 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>
|
||||
|
@ -240,8 +240,9 @@ sub start_pacemaker
|
||||
# Keep waiting, or fence the peer?
|
||||
if (time > $wait_for_peer)
|
||||
{
|
||||
### TODO: See above, not implemented yet.
|
||||
# Time to fence.
|
||||
### TODO: See above, not implemented yet. Do we want to do this? If so:
|
||||
# Time to fence. Use 'pcs stonith fence <peer>', verify it succeeded,
|
||||
# then do 'pcs quorum unblock --force' to finish startup.
|
||||
}
|
||||
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, priority => "alert", key => "log_0610", variables => { node_name => $node_name }});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user