* Updated Tools->catch_sig() to use return code 0 instead of 255 so that systemd doesn't think our daemons failed on stop.

* Updated Cluster->parse_cib() to not require a database connection (part of the work to make ocf:alteeve:server run without a DB)
* WIP: Continuing work on the ocf:alteeve:server RA to run without database connections.
* Updated the scancore daemon to explcitely check that all scan agent schemas are loaded in all databases on startup. This is to resolve resync issues on rebuilt strikers that may not yet have some schemas loaded when a DB resync runs.

Signed-off-by: Digimer <digimer@alteeve.ca>
This commit is contained in:
Digimer 2021-06-05 14:32:26 -04:00
parent 6710653ac9
commit 16c20ae69c
5 changed files with 125 additions and 178 deletions

View File

@ -1355,7 +1355,9 @@ sub catch_sig
$anvil->System->call({shell_call => $anvil->data->{path}{exe}{stty}." ".$anvil->data->{sys}{terminal}{stty}}); $anvil->System->call({shell_call => $anvil->data->{path}{exe}{stty}." ".$anvil->data->{sys}{terminal}{stty}});
} }
} }
$anvil->nice_exit({exit_code => 255});
# Exit with '0' so shutdowns from systemd doesn't think we failed.
$anvil->nice_exit({exit_code => 0});
} }

View File

@ -3001,10 +3001,11 @@ sub parse_cib
} }
else else
{ {
# It's our peer. # It's our peer. Note that we only get the peer's host UUID if we have a DB
# connection. This method is called by ocf:alteeve:anvil which skips the DB.
$anvil->data->{cib}{parsed}{peer}{ready} = $ready; $anvil->data->{cib}{parsed}{peer}{ready} = $ready;
$anvil->data->{cib}{parsed}{peer}{name} = $node_name; $anvil->data->{cib}{parsed}{peer}{name} = $node_name;
$anvil->data->{cib}{parsed}{peer}{host_uuid} = $anvil->Get->host_uuid_from_name({debug => $debug, host_name => $node_name}); $anvil->data->{cib}{parsed}{peer}{host_uuid} = $anvil->data->{sys}{database}{connections} ? $anvil->Get->host_uuid_from_name({debug => $debug, host_name => $node_name}) : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"cib::parsed::peer::ready" => $anvil->data->{cib}{parsed}{peer}{ready}, "cib::parsed::peer::ready" => $anvil->data->{cib}{parsed}{peer}{ready},
"cib::parsed::peer::name" => $anvil->data->{cib}{parsed}{peer}{name}, "cib::parsed::peer::name" => $anvil->data->{cib}{parsed}{peer}{name},
@ -3183,8 +3184,9 @@ sub parse_cib
# Stopping # Stopping
$status = $active ? "running" : "off"; $status = $active ? "running" : "off";
# If the role is NOT 'migating', check to see if it's marked as such in the database. # If the role is NOT 'migrating', and we have a database connection, check to see if
if ($role ne "migrating") # it's marked as such in the database.
if (($role ne "migrating") && ($anvil->data->{sys}{database}{connections}))
{ {
$anvil->Database->get_servers({debug => $debug}); $anvil->Database->get_servers({debug => $debug});
my $anvil_uuid = $anvil->Cluster->get_anvil_uuid({debug => $debug}); my $anvil_uuid = $anvil->Cluster->get_anvil_uuid({debug => $debug});

View File

@ -1732,15 +1732,6 @@ sub connect
# } # }
} }
if ($sensitive)
{
# Return here.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"sys::database::connections" => $anvil->data->{sys}{database}{connections},
}});
return($anvil->data->{sys}{database}{connections});
}
# Make sure my host UUID is valod # Make sure my host UUID is valod
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "sys::host_uuid" => $anvil->data->{sys}{host_uuid} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "sys::host_uuid" => $anvil->data->{sys}{host_uuid} }});
if ($anvil->data->{sys}{host_uuid} !~ /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/) if ($anvil->data->{sys}{host_uuid} !~ /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/)
@ -1752,23 +1743,33 @@ sub connect
$anvil->Database->disconnect({debug => $debug}); $anvil->Database->disconnect({debug => $debug});
} }
# If this is a time sensitive call, end here.
if ($sensitive)
{
# Return here.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::database::connections" => $anvil->data->{sys}{database}{connections},
}});
return($anvil->data->{sys}{database}{connections});
}
# If we have a previous count and the new count is higher, resync. # If we have a previous count and the new count is higher, resync.
if (exists $anvil->data->{sys}{database}{last_db_count}) if (exists $anvil->data->{sys}{database}{last_db_count})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::database::last_db_count" => $anvil->data->{sys}{database}{last_db_count}, "sys::database::last_db_count" => $anvil->data->{sys}{database}{last_db_count},
"sys::database::connections" => $anvil->data->{sys}{database}{connections}, "sys::database::connections" => $anvil->data->{sys}{database}{connections},
}}); }});
if ($anvil->data->{sys}{database}{connections} > $anvil->data->{sys}{database}{last_db_count}) if ($anvil->data->{sys}{database}{connections} > $anvil->data->{sys}{database}{last_db_count})
{ {
$check_for_resync = 1; $check_for_resync = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { check_for_resync => $check_for_resync }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { check_for_resync => $check_for_resync }});
} }
} }
# If we have a "last_db_count" and it's the lower than the current number of connections, check for a # If we have a "last_db_count" and it's the lower than the current number of connections, check for a
# resync. # resync.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::database::connections" => $anvil->data->{sys}{database}{connections}, "sys::database::connections" => $anvil->data->{sys}{database}{connections},
check_for_resync => $check_for_resync, check_for_resync => $check_for_resync,
}}); }});
@ -1787,11 +1788,11 @@ sub connect
# Hold if a lock has been requested. # Hold if a lock has been requested.
$anvil->Database->locking({debug => $debug}); $anvil->Database->locking({debug => $debug});
# Mark that we're not active. # Mark that we're now active.
$anvil->Database->mark_active({debug => $debug, set => 1}); $anvil->Database->mark_active({debug => $debug, set => 1});
# Sync the database, if needed. # Sync the database, if needed.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"sys::database::resync_needed" => $anvil->data->{sys}{database}{resync_needed}, "sys::database::resync_needed" => $anvil->data->{sys}{database}{resync_needed},
check_for_resync => $check_for_resync, check_for_resync => $check_for_resync,
}}); }});
@ -1832,8 +1833,8 @@ sub disconnect
# Clear locks and mark that we're done running. # Clear locks and mark that we're done running.
if (not $marked_inactive) if (not $marked_inactive)
{ {
$anvil->Database->mark_active({set => 0}); $anvil->Database->mark_active({debug => $debug, set => 0});
$anvil->Database->locking({release => 1}); $anvil->Database->locking({debug => $debug, release => 1});
$marked_inactive = 1; $marked_inactive = 1;
} }
@ -1846,7 +1847,7 @@ sub disconnect
delete $anvil->data->{sys}{database}{timestamp}; delete $anvil->data->{sys}{database}{timestamp};
delete $anvil->data->{sys}{database}{read_uuid}; delete $anvil->data->{sys}{database}{read_uuid};
delete $anvil->data->{sys}{database}{identifier}; delete $anvil->data->{sys}{database}{identifier};
$anvil->Database->read({set => "delete"}); $anvil->Database->read({debug => $debug, set => "delete"});
# Delete any database information (reconnects should re-read anvil.conf anyway). # Delete any database information (reconnects should re-read anvil.conf anyway).
delete $anvil->data->{database}; delete $anvil->data->{database};
@ -15161,7 +15162,7 @@ sub resync_databases
# Add the host column. # Add the host column.
$query = "INSERT INTO public.$table ($host_column, $uuid_column, ".$columns."modified_date) VALUES (".$anvil->Database->quote($anvil->data->{sys}{host_uuid}).", ".$anvil->Database->quote($row_uuid).", ".$values.$anvil->Database->quote($modified_date)."::timestamp AT TIME ZONE 'UTC');"; $query = "INSERT INTO public.$table ($host_column, $uuid_column, ".$columns."modified_date) VALUES (".$anvil->Database->quote($anvil->data->{sys}{host_uuid}).", ".$anvil->Database->quote($row_uuid).", ".$values.$anvil->Database->quote($modified_date)."::timestamp AT TIME ZONE 'UTC');";
} }
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0460", variables => { uuid => $anvil->data->{database}{$uuid}{host}, query => $query }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0460", variables => { uuid => $anvil->data->{database}{$uuid}{host}, query => $query }});
### NOTE: After an archive operationg, a record can ### NOTE: After an archive operationg, a record can
### end up in the public schema while nothing ### end up in the public schema while nothing
@ -15185,14 +15186,14 @@ sub resync_databases
query => $query, query => $query,
}}); }});
$query =~ s/INSERT INTO public./INSERT INTO history./; $query =~ s/INSERT INTO public./INSERT INTO history./;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
push @{$anvil->data->{db_resync}{$uuid}{history}{sql}}, $query; push @{$anvil->data->{db_resync}{$uuid}{history}{sql}}, $query;
} }
else else
{ {
# No problem, record the query in the array # No problem, record the query in the array
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
push @{$anvil->data->{db_resync}{$uuid}{public}{sql}}, $query; push @{$anvil->data->{db_resync}{$uuid}{public}{sql}}, $query;
} }
} # if not exists } # if not exists
@ -15240,7 +15241,7 @@ sub resync_databases
# Add the host column. # Add the host column.
$query = "INSERT INTO history.$table ($host_column, $uuid_column, ".$columns."modified_date) VALUES (".$anvil->Database->quote($anvil->data->{sys}{host_uuid}).", ".$anvil->Database->quote($row_uuid).", ".$values.$anvil->Database->quote($modified_date)."::timestamp AT TIME ZONE 'UTC');"; $query = "INSERT INTO history.$table ($host_column, $uuid_column, ".$columns."modified_date) VALUES (".$anvil->Database->quote($anvil->data->{sys}{host_uuid}).", ".$anvil->Database->quote($row_uuid).", ".$values.$anvil->Database->quote($modified_date)."::timestamp AT TIME ZONE 'UTC');";
} }
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0460", variables => { uuid => $anvil->data->{database}{$uuid}{host}, query => $query }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0460", variables => { uuid => $anvil->data->{database}{$uuid}{host}, query => $query }});
# Now record the query in the array # Now record the query in the array
push @{$anvil->data->{db_resync}{$uuid}{history}{sql}}, $query; push @{$anvil->data->{db_resync}{$uuid}{history}{sql}}, $query;
@ -16519,7 +16520,7 @@ ORDER BY
# { # {
# # Resync needed. # # Resync needed.
# my $difference = $anvil->data->{sys}{database}{table}{$table}{last_updated} - $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated}; # my $difference = $anvil->data->{sys}{database}{table}{$table}{last_updated} - $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated};
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { # $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
# "s1:difference" => $anvil->Convert->add_commas({number => $difference }), # "s1:difference" => $anvil->Convert->add_commas({number => $difference }),
# "s2:sys::database::table::${table}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{last_updated}, # "s2:sys::database::table::${table}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{last_updated},
# "s3:sys::database::table::${table}::uuid::${uuid}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated}, # "s3:sys::database::table::${table}::uuid::${uuid}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated},
@ -16540,7 +16541,7 @@ ORDER BY
{ {
# Resync needed. # Resync needed.
my $difference = ($anvil->data->{sys}{database}{table}{$table}{row_count} - $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count}); my $difference = ($anvil->data->{sys}{database}{table}{$table}{row_count} - $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:difference" => $anvil->Convert->add_commas({number => $difference }), "s1:difference" => $anvil->Convert->add_commas({number => $difference }),
"s2:sys::database::table::${table}::row_count" => $anvil->data->{sys}{database}{table}{$table}{row_count}, "s2:sys::database::table::${table}::row_count" => $anvil->data->{sys}{database}{table}{$table}{row_count},
"s3:sys::database::table::${table}::uuid::${uuid}::row_count" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count}, "s3:sys::database::table::${table}::uuid::${uuid}::row_count" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count},

View File

@ -143,13 +143,23 @@ $anvil->data->{environment}{OCF_RESKEY_CRM_meta_stop_drbd_resources} = 0;
# We're used by anvil-boot-server and anvil-stop-server. They don't set environment variables, but instead # We're used by anvil-boot-server and anvil-stop-server. They don't set environment variables, but instead
# use switches. Pick those up, if passed. # use switches. Pick those up, if passed.
$anvil->data->{switches}{migrate_to} = ""; # Sets 'meta_migrate_target' $anvil->data->{switches}{migrate_to} = ""; # Sets 'meta_migrate_target'
$anvil->data->{switches}{migrate_from} = ""; # Sets 'meta_migrate_source' When set without 'migrate_to', does a status check after migration $anvil->data->{switches}{'migrate-to'} = "";
$anvil->data->{switches}{server} = ""; # Sets 'name'. $anvil->data->{switches}{migrate_from} = ""; # Sets 'meta_migrate_source' When set without 'migrate_to', does a status check after migration
$anvil->data->{switches}{start} = ""; $anvil->data->{switches}{'migrate-from'} = "";
$anvil->data->{switches}{stop} = ""; $anvil->data->{switches}{server} = ""; # Sets 'name'.
$anvil->data->{switches}{monitor} = ""; $anvil->data->{switches}{start} = "";
$anvil->data->{switches}{stop} = "";
$anvil->data->{switches}{monitor} = "";
$anvil->Get->switches(); $anvil->Get->switches();
if (($anvil->data->{switches}{'migrate-to'}) && not ($anvil->data->{switches}{migrate_to}))
{
$anvil->data->{switches}{migrate_to} = $anvil->data->{switches}{'migrate-to'};
}
if (($anvil->data->{switches}{'migrate-from'}) && not ($anvil->data->{switches}{migrate_from}))
{
$anvil->data->{switches}{migrate_from} = $anvil->data->{switches}{'migrate-from'};
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"switches::migrate_to" => $anvil->data->{switches}{migrate_to}, "switches::migrate_to" => $anvil->data->{switches}{migrate_to},
"switches::migrate_from" => $anvil->data->{switches}{migrate_from}, "switches::migrate_from" => $anvil->data->{switches}{migrate_from},
@ -161,13 +171,13 @@ $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list
# If we can connect to a database, we'll set/clear the 'migrating' flag during migrations. For timing reasons # If we can connect to a database, we'll set/clear the 'migrating' flag during migrations. For timing reasons
# we don't let the RA do resyncs. # we don't let the RA do resyncs.
$anvil->Database->connect({sensitive => 1}); # $anvil->Database->connect({sensitive => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"}); # $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections}) # if (not $anvil->data->{sys}{database}{connections})
{ # {
# No databases, # # No databases,
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, secure => 0, key => "warning_0073"}); # $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, secure => 0, key => "warning_0073"});
} # }
if ($anvil->data->{switches}{stop_drbd_resources}) if ($anvil->data->{switches}{stop_drbd_resources})
{ {
@ -180,64 +190,24 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level
=cut =cut
Start: Start:
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [start] environment::OCF_RESKEY_CRM_meta_name: [start]
environment::OCF_RESKEY_CRM_meta_on_fail: [block] environment::OCF_RESKEY_CRM_meta_on_fail: [block]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01] environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1] environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [300000] environment::OCF_RESKEY_CRM_meta_timeout: [300000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu] environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
Monitor after start: Monitor:
environment::OCF_RESKEY_CRM_meta_interval: [60000] environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor] environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01] environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1] environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000] environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu] environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
Monitor one minute later:
environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
Migrate from an-a02n01 to an-a02n02 Migrate from an-a02n01 to an-a02n02
environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
<2 seconds later>
environment::OCF_RESKEY_CRM_meta_migrate_source: [an-a02n01] environment::OCF_RESKEY_CRM_meta_migrate_source: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_migrate_target: [an-a02n02] environment::OCF_RESKEY_CRM_meta_migrate_target: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_name: [migrate_to] environment::OCF_RESKEY_CRM_meta_name: [migrate_to]
@ -247,120 +217,59 @@ environment::OCF_RESKEY_CRM_meta_record_pending: [true]
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0] environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [86400000] environment::OCF_RESKEY_CRM_meta_timeout: [86400000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu] environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu] # Post migration on an-a02n01; stop is called:
environment::OCF_ROOT: [/usr/lib/ocf]
Post migration on an-a02n01 Post migration on an-a02n02:
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [stop]
environment::OCF_RESKEY_CRM_meta_on_fail: [block]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [86400000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::PCMK_debug: [0]
Post migration on an-a02n02
environment::OCF_RESKEY_CRM_meta_migrate_source: [an-a02n01] environment::OCF_RESKEY_CRM_meta_migrate_source: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_migrate_target: [an-a02n02] environment::OCF_RESKEY_CRM_meta_migrate_target: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_name: [migrate_from] environment::OCF_RESKEY_CRM_meta_name: [migrate_from]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02] environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2] environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [600000] environment::OCF_RESKEY_CRM_meta_timeout: [600000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu] environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_PROVIDER: [alteeve]
environment::OCF_RESOURCE_TYPE: [server]
environment::OCF_ROOT: [/usr/lib/ocf]
environment::PCMK_debug: [0]
Checking server state after: [srv02-c8s-fujitsu] was migrated to this host. Checking server state after: [srv02-c8s-fujitsu] was migrated to an-a02n02;
environment::OCF_EXIT_REASON_PREFIX: [ocf-exit-reason:]
environment::OCF_RA_VERSION_MAJOR: [1]
environment::OCF_RA_VERSION_MINOR: [0]
environment::OCF_RESKEY_CRM_meta_interval: [60000] environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor] environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02] environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2] environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000] environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_crm_feature_set: [3.7.1]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu] environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_PROVIDER: [alteeve]
environment::OCF_RESOURCE_TYPE: [server]
environment::OCF_ROOT: [/usr/lib/ocf]
environment::PCMK_debug: [0]
Stop server (on an-a02n02):
Monitor on an-a02n02 after a minute
environment::OCF_EXIT_REASON_PREFIX: [ocf-exit-reason:]
environment::OCF_RA_VERSION_MAJOR: [1]
environment::OCF_RA_VERSION_MINOR: [0]
environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_crm_feature_set: [3.7.1]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_PROVIDER: [alteeve]
environment::OCF_RESOURCE_TYPE: [server]
environment::OCF_ROOT: [/usr/lib/ocf]
environment::PCMK_debug: [0]
Stop server:
environment::OCF_EXIT_REASON_PREFIX: [ocf-exit-reason:]
environment::OCF_RA_VERSION_MAJOR: [1]
environment::OCF_RA_VERSION_MINOR: [0]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [stop] environment::OCF_RESKEY_CRM_meta_name: [stop]
environment::OCF_RESKEY_CRM_meta_on_fail: [block] environment::OCF_RESKEY_CRM_meta_on_fail: [block]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02] environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2] environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [86400000] environment::OCF_RESKEY_CRM_meta_timeout: [86400000]
environment::OCF_RESKEY_crm_feature_set: [3.7.1]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu] environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_PROVIDER: [alteeve]
environment::OCF_RESOURCE_TYPE: [server]
environment::OCF_ROOT: [/usr/lib/ocf]
environment::PCMK_debug: [0]
=cut =cut
foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{environment}}) foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{environment}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => {
"environment::${key}" => $anvil->data->{environment}{$key}, "environment::${key}" => $anvil->data->{environment}{$key},
}}); }});
} }
foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{switches}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => {
"switches::${key}" => $anvil->data->{switches}{$key},
}});
}
# Set environment variables from switches, if otherwise not set. # Set environment variables from switches, if otherwise not set.
if (($anvil->data->{switches}{server}) && (not $anvil->data->{environment}{OCF_RESKEY_name}))
{
$anvil->data->{environment}{OCF_RESKEY_name} = $anvil->data->{switches}{server};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"environment::OCF_RESKEY_name" => $anvil->data->{environment}{OCF_RESKEY_name},
}});
}
if (($anvil->data->{switches}{migrate_to}) && (not $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target})) if (($anvil->data->{switches}{migrate_to}) && (not $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target}))
{ {
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} = $anvil->data->{switches}{migrate_to}; $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} = $anvil->data->{switches}{migrate_to};
@ -376,13 +285,6 @@ if (($anvil->data->{switches}{migrate_from}) && (not $anvil->data->{environment}
"environment::OCF_RESKEY_CRM_meta_migrate_source" => $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source}, "environment::OCF_RESKEY_CRM_meta_migrate_source" => $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source},
}}); }});
} }
if (($anvil->data->{switches}{server}) && (not $anvil->data->{environment}{OCF_RESKEY_name}))
{
$anvil->data->{environment}{OCF_RESKEY_name} = $anvil->data->{switches}{server};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"environment::OCF_RESKEY_name" => $anvil->data->{environment}{OCF_RESKEY_name},
}});
}
# This is for debugging. # This is for debugging.
if (not $anvil->data->{switches}{monitor}) if (not $anvil->data->{switches}{monitor})
@ -486,7 +388,8 @@ sub check_daemons
{ {
my ($anvil, $task) = @_; my ($anvil, $task) = @_;
my $problem = $anvil->Cluster->parse_cib(); my $problem = $anvil->Cluster->parse_cib({debug => 3});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { problem => $problem }});
if ($problem) if ($problem)
{ {
# Pacemaker isn't running, or some other problem. Someone must have called this script # Pacemaker isn't running, or some other problem. Someone must have called this script
@ -498,7 +401,7 @@ sub check_daemons
# Is the peer running? We'll use this to know whether to try and start daemons on the peer. # Is the peer running? We'll use this to know whether to try and start daemons on the peer.
my $peer_name = $anvil->data->{cib}{parsed}{peer}{name}; my $peer_name = $anvil->data->{cib}{parsed}{peer}{name};
my $peer_ready = $anvil->data->{cib}{parsed}{peer}{ready}; my $peer_ready = $anvil->data->{cib}{parsed}{peer}{ready};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
peer_name => $peer_name, peer_name => $peer_name,
peer_ready => $peer_ready, peer_ready => $peer_ready,
}}); }});
@ -513,7 +416,7 @@ sub check_daemons
my $running_peer = 0; my $running_peer = 0;
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon}); my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
}}); }});
@ -522,7 +425,7 @@ sub check_daemons
# It is stopped, start it.. # It is stopped, start it..
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0482", variables => { daemon => $daemon }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0482", variables => { daemon => $daemon }});
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." start ".$daemon}); my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." start ".$daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
}}); }});
@ -532,7 +435,7 @@ sub check_daemons
until ($running) until ($running)
{ {
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon}); my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
}}); }});
@ -588,7 +491,7 @@ sub check_daemons
target => $peer_name, target => $peer_name,
shell_call => $anvil->data->{path}{exe}{systemctl}." start ".$daemon, shell_call => $anvil->data->{path}{exe}{systemctl}." start ".$daemon,
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
output => $output, output => $output,
error => $error, error => $error,
return_code => $return_code, return_code => $return_code,
@ -602,7 +505,7 @@ sub check_daemons
target => $peer_name, target => $peer_name,
shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon, shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon,
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
output => $output, output => $output,
error => $error, error => $error,
return_code => $return_code, return_code => $return_code,
@ -847,6 +750,14 @@ sub start_server
my $server = $anvil->data->{environment}{OCF_RESKEY_name}; my $server = $anvil->data->{environment}{OCF_RESKEY_name};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0303", variables => { server => $server }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0303", variables => { server => $server }});
if ((not $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node}) && ($anvil->data->{switches}{target}))
{
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node} = $anvil->data->{switches}{target};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"environment::OCF_RESKEY_CRM_meta_on_node" => $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node},
}});
}
# Make sure things are sane. # Make sure things are sane.
validate_all($anvil); validate_all($anvil);

View File

@ -229,7 +229,7 @@ sub prepare_for_run
$anvil->Storage->read_config(); $anvil->Storage->read_config();
$anvil->Get->switches(); $anvil->Get->switches();
$anvil->Words->read(); $anvil->Words->read();
$anvil->Database->connect(); $anvil->Database->connect({check_for_resync => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0132"});
# See if the mail server needs to be updated. # See if the mail server needs to be updated.
@ -243,7 +243,9 @@ sub wait_for_database
{ {
my ($anvil) = @_; my ($anvil) = @_;
$anvil->Database->connect({check_for_resync => 1}); # Don't check for resync here as we may need to load agent schemas. We'll check for resync in the
# main loop.
$anvil->Database->connect({check_for_resync => 0});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections}) if (not $anvil->data->{sys}{database}{connections})
{ {
@ -259,7 +261,7 @@ sub wait_for_database
$anvil->_set_paths(); $anvil->_set_paths();
$anvil->_set_defaults(); $anvil->_set_defaults();
$anvil->Storage->read_config(); $anvil->Storage->read_config();
$anvil->Database->connect({check_for_resync => 1}); $anvil->Database->connect({check_for_resync => 0});
if ($anvil->data->{sys}{database}{connections}) if ($anvil->data->{sys}{database}{connections})
{ {
# We're good # We're good
@ -323,6 +325,35 @@ sub startup_tasks
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0572"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0572"});
# Make sure all agents schemas are loaded so that resyncs where a table on one DB doesn't exist on
# another, causing a fault.
$anvil->ScanCore->_scan_directory({directory => $anvil->data->{path}{directories}{scan_agents}});
foreach my $scan_agent (sort {$a cmp $b} keys %{$anvil->data->{scancore}{agent}})
{
my $schema_file = $anvil->data->{path}{directories}{scan_agents}."/".$scan_agent."/".$scan_agent.".sql";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
scan_agent => $scan_agent,
schema_file => $schema_file,
}});
if (-e $schema_file)
{
my $tables = $anvil->Database->get_tables_from_schema({debug => 3, schema_file => $schema_file});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { tables => $tables }});
my $table_count = @{$tables};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { table_count => $table_count }});
# It's possible that some agents don't have a database (or use core database tables only)
if (@{$tables} > 0)
{
$anvil->Database->check_agent_data({
agent => $scan_agent,
tables => $tables,
});
}
}
}
# Update our status # Update our status
$anvil->Database->get_hosts({debug => 3}); $anvil->Database->get_hosts({debug => 3});
my $host_uuid = $anvil->Get->host_uuid(); my $host_uuid = $anvil->Get->host_uuid();