* Updated Database->configure_pgsql() to use 'postgresql-setup --initdb --unit postgresql' instead of the deprecaded 'initdb' switch.

* Updated Database->insert_or_update_states() to switch to an active UUID if the passed in UUID is not an active handle.
* Updated Database->query() to swutch to 'sys::database::read_uuid' if the passed in 'uuid' is not an active handle.
* Updated Database->_test_access() to return immediately if the passed in uuid is not an active handle.
* Started working on a Storage->get_storage_group_from_path() bug where the storage group isn't being returned.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 5c1978d5a0
commit 257a998743
  1. 53
      Anvil/Tools/Database.pm
  2. 17
      Anvil/Tools/Storage.pm
  3. 4
      scancore-agents/scan-apc-ups/scan-apc-ups
  4. 1
      share/words.xml
  5. 8
      tools/anvil-manage-server
  6. 2
      tools/striker-get-peer-data

@ -806,7 +806,7 @@ sub configure_pgsql
if (not -e $anvil->data->{path}{configs}{'pg_hba.conf'})
{
# Initialize. Record that we did so, so that we know to start the daemon.
my ($output, $return_code) = $anvil->System->call({debug => 1, shell_call => $anvil->data->{path}{exe}{'postgresql-setup'}." initdb", source => $THIS_FILE, line => __LINE__});
my ($output, $return_code) = $anvil->System->call({debug => 1, shell_call => $anvil->data->{path}{exe}{'postgresql-setup'}." --initdb --unit postgresql", source => $THIS_FILE, line => __LINE__});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { output => $output, return_code => $return_code }});
# Did it succeed?
@ -12031,7 +12031,20 @@ sub insert_or_update_states
# If we were passed a database UUID, check for the open handle.
if ($uuid)
{
$anvil->data->{cache}{database_handle}{$uuid} = "" if not defined $anvil->data->{cache}{database_handle}{$uuid};
if ((not defined $anvil->data->{cache}{database_handle}{$uuid}) or (not $anvil->data->{cache}{database_handle}{$uuid}))
{
# Switch to another UUID
foreach my $this_uuid (keys %{$anvil->data->{cache}{database_handle}})
{
if ($anvil->data->{cache}{database_handle}{$this_uuid})
{
# Switch to this UUID
$uuid = $this_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { uuid => $uuid }});
}
}
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"cache::database_handle::${uuid}" => $anvil->data->{cache}{database_handle}{$uuid},
}});
@ -15300,9 +15313,26 @@ sub query
}
elsif (not defined $anvil->data->{cache}{database_handle}{$uuid})
{
# Database handle is gone.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0073", variables => { uuid => $uuid }});
return("!!error!!");
# Database handle is gone. Switch to the read_uuid
my $old_uuid = $uuid;
$uuid = $anvil->data->{sys}{database}{read_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
old_uuid => $old_uuid,
uuid => $uuid,
}});
if (not defined $anvil->data->{cache}{database_handle}{$uuid})
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0073", variables => { uuid => $uuid }});
return("!!error!!");
}
else
{
# Warn that we switched.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0073", variables => {
old_uuid => $old_uuid,
new_uuid => $uuid,
}});
}
}
if (not $query)
{
@ -17391,6 +17421,8 @@ This method takes a database UUID and tests the connection to it using the DBD '
This exists to handle the loss of a database mid-run where a normal query, which isn't wrapped in a query, could hang indefinately.
B<< Note >>: If there is no active handle, this returns 0 immediately.
=cut
sub _test_access
{
@ -17401,7 +17433,16 @@ sub _test_access
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Database->_test_access()" }});
my $uuid = $parameter->{uuid} ? $parameter->{uuid} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { uuid => $uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
uuid => $uuid,
"cache::database_handle::${uuid}" => $anvil->data->{cache}{database_handle}{$uuid},
}});
# If the handle is down, return 0.
if ((not exists $anvil->data->{cache}{database_handle}{$uuid}) or (not $anvil->data->{cache}{database_handle}{$uuid}))
{
return(0);
}
# Make logging code a little cleaner
my $database_name = defined $anvil->data->{database}{$uuid}{name} ? $anvil->data->{database}{$uuid}{name} : $anvil->data->{sys}{database}{name};

@ -2177,6 +2177,7 @@ sub get_storage_group_from_path
}
# Is this a DRBD path?
my $gathered_data = 0;
my $logical_volume = "";
if ($path !~ /drbd/)
{
@ -2188,8 +2189,9 @@ sub get_storage_group_from_path
# Looks like it. If the device path is '/dev/drbd/by-res/...' we'll need to pull out the
# resource name (server name) and volume number as the path only actually exists when DRBD is
# up and isn't referenced in the config file.
my $resource = "";
my $volume = "";
my $resource = "";
my $volume = "";
$gathered_data = 1;
$anvil->DRBD->gather_data({debug => $debug});
if ($path =~ /\/dev\/drbd\/by-res\/(.*)\/(\d+)$/)
{
@ -2342,10 +2344,13 @@ LIMIT 1
scan_drbd_resource_xml => $scan_drbd_resource_xml,
}});
$anvil->DRBD->gather_data({
debug => 3,
xml => $scan_drbd_resource_xml,
});
if (not $gathered_data)
{
$anvil->DRBD->gather_data({
debug => 3,
xml => $scan_drbd_resource_xml,
});
}
# Dig out the LV behind the volume.
foreach my $this_host_name (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{host}})

@ -1480,8 +1480,8 @@ WHERE
my $alert_sent = 0;
my $variables = {
ups_name => $scan_apc_ups_name,
new_value => $scan_apc_ups_battery_model,
old_value => $old_scan_apc_ups_battery_model,
new_value => $scan_apc_ups_battery_percentage_charge,
old_value => $old_scan_apc_ups_battery_percentage_charge,
battery_number => $battery_number,
low_charge_clear => $anvil->data->{'scan-apc-ups'}{low_charge_percentage_ok},
low_charge_alert => $anvil->data->{'scan-apc-ups'}{low_charge_percentage_warning},

@ -2056,6 +2056,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0663">The target can be reached on the dedicated migration network: [#!variable!target!#] via the IP address: [#!variable!ip!#], switching to use that for the RAM copy.</key>
<key name="log_0664">[ Note ] - The IP address: [#!variable!ip!#] with 'ip_address_uuid': [#!variable!uuid!#] is a duplicate, removing it from the database(s).</key>
<key name="log_0665">The database dump file: [#!variable!file!#] exists, skipping database setup.</key>
<key name="log_0666"><![CDATA[[ Error ] - The method Database->query() was asked to query the database with UUID: [#!variable!old_uuid!#] but there is no file handle open to the database. Switched the read to: [#!variable!new_uuid!#].]]></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>

@ -661,6 +661,7 @@ sub interactive_configure_main
print "[ 3 ] - Storage\n";
print "[ 4 ] - Network\n";
print "[ 5 ] - Boot Order\n";
print "[ 6 ] - Cluster Management\n";
print "\n";
print "[ B ] - Back\n";
print "[ Q ] - Quit\n";
@ -696,6 +697,11 @@ sub interactive_configure_main
print "Going to Boot order menu\n";
sleep 1;
}
elsif ($answer eq "6")
{
print "Going to cluster manager menu\n";
sleep 1;
}
elsif (lc($answer) eq "b")
{
$anvil->data->{target_server}{server_name} = "";
@ -815,7 +821,7 @@ sub interactive_configure_storage
}});
my $this_storage_group_uuid = $anvil->Storage->get_storage_group_from_path({
debug => 3,
debug => 2,
anvil_uuid => $anvil_uuid,
path => $this_path,
});

@ -340,7 +340,7 @@ sub get_password
}
my $query = "SELECT state_note FROM states WHERE state_uuid = ".$anvil->Database->quote($anvil->data->{switches}{'state-uuid'}).";";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { query => $query }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
my $password = $anvil->Database->query({uuid => $anvil->data->{sys}{host_uuid}, debug => 3, query => $query, source => $THIS_FILE, line => __LINE__})->[0]->[0];
$password = "" if not defined $password;

Loading…
Cancel
Save