* Updated anvil-daemon, in its daily checks, to disable ksm and ksmtuned daemons.

* Updated scan-drbd to purge peer records that no longer have corresponding LVM data.
* Updated System->{en,dis}able-service to take the 'now' paramter which, when passed, causes the action to take immediate effect.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 1580ffbb24
commit ab9b00a2f7
  1. 36
      Anvil/Tools/System.pm
  2. 1
      notes
  3. 35
      scancore-agents/scan-drbd/scan-drbd
  4. 1
      scancore-agents/scan-drbd/scan-drbd.xml
  5. 1
      share/words.xml
  6. 20
      tools/anvil-daemon

@ -2587,6 +2587,10 @@ Parameters;
This is the name of the daemon to disable. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes. This is the name of the daemon to disable. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes.
=head3 now (optional, default '0')
If set to C<< 1 >>, the daemon will be stopped as well as disabled
=cut =cut
sub disable_daemon sub disable_daemon
{ {
@ -2597,9 +2601,19 @@ sub disable_daemon
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->disable_daemon()" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->disable_daemon()" }});
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : ""; my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }}); my $now = defined $parameter->{now} ? $parameter->{now} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
daemon => $daemon,
now => $now,
}});
my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $anvil->data->{path}{exe}{systemctl}." disable ".$daemon}); my $shell_call = $anvil->data->{path}{exe}{systemctl}." disable ".$daemon;
if ($now)
{
$shell_call = $anvil->data->{path}{exe}{systemctl}." disable --now ".$daemon;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,
@ -3033,6 +3047,10 @@ Parameters;
This is the name of the daemon to enable. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes. This is the name of the daemon to enable. The exact name given is passed to C<< systemctl >>, so please be mindful of appropriate suffixes.
=head3 now (optional, default '0'
If set to c<< 1 >>, the daemon will be started now.
=cut =cut
sub enable_daemon sub enable_daemon
{ {
@ -3043,9 +3061,19 @@ sub enable_daemon
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->enable_daemon()" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->enable_daemon()" }});
my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : ""; my $daemon = defined $parameter->{daemon} ? $parameter->{daemon} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { daemon => $daemon }}); my $now = defined $parameter->{now} ? $parameter->{now} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
daemon => $daemon,
now => $now,
}});
my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $anvil->data->{path}{exe}{systemctl}." enable ".$daemon." 2>&1"}); my $shell_call = $anvil->data->{path}{exe}{systemctl}." enable ".$daemon." 2>&1";
if ($now)
{
$shell_call = $anvil->data->{path}{exe}{systemctl}." enable --now ".$daemon." 2>&1";
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
output => $output, output => $output,
return_code => $return_code, return_code => $return_code,

@ -14,6 +14,7 @@ web -s enable
snmp -S enable -c1 private -a1 writeplus snmp -S enable -c1 private -a1 writeplus
snmp -S enable -c2 public -a2 writeplus snmp -S enable -c2 public -a2 writeplus
Anvil! to Anvil! live migration; Anvil! to Anvil! live migration;
1. Create LVs 1. Create LVs
2. Make sure /etc/hosts is populated 2. Make sure /etc/hosts is populated

@ -1325,17 +1325,50 @@ WHERE
my $scan_drbd_peer_uuid = $row->[0]; my $scan_drbd_peer_uuid = $row->[0];
my $scan_drbd_peer_scan_drbd_volume_uuid = $row->[1]; my $scan_drbd_peer_scan_drbd_volume_uuid = $row->[1];
my $scan_drbd_peer_host_name = $row->[2]; my $scan_drbd_peer_host_name = $row->[2];
my $scan_drbd_peer_connection_state = $row->[3];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
scan_drbd_peer_uuid => $scan_drbd_peer_uuid, scan_drbd_peer_uuid => $scan_drbd_peer_uuid,
scan_drbd_peer_scan_drbd_volume_uuid => $scan_drbd_peer_scan_drbd_volume_uuid, scan_drbd_peer_scan_drbd_volume_uuid => $scan_drbd_peer_scan_drbd_volume_uuid,
scan_drbd_peer_host_name => $scan_drbd_peer_host_name, scan_drbd_peer_host_name => $scan_drbd_peer_host_name,
scan_drbd_peer_connection_state => $scan_drbd_peer_connection_state,
}}); }});
# It's possible that a DELETED resource no longer has corresponding LVM data. If so, we'll
# purge this record.
if (($scan_drbd_peer_connection_state eq "DELETED") && (not exists $anvil->data->{volume_to_uuid}{$scan_drbd_peer_scan_drbd_volume_uuid}))
{
# Purge it.
my $resource_uuid = $anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_peer_scan_drbd_volume_uuid}{scan_drbd_volume_scan_drbd_resource_uuid};
my $volume_number = $anvil->data->{old}{scan_drbd_volume}{scan_drbd_volume_uuid}{$scan_drbd_peer_scan_drbd_volume_uuid}{scan_drbd_volume_number};
my $resource_name = $anvil->data->{old}{scan_drbd_resource}{scan_drbd_resource_uuid}{$resource_uuid}{scan_drbd_resource_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
resource_uuid => $resource_uuid,
volume_number => $volume_number,
resource_name => $resource_name,
}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "scan_drbd_message_0035", variables => {
peer_name => $scan_drbd_peer_host_name,
resource_name => $resource_name,
volume_number => $volume_number,
}});
my $queries = [];
push @{$queries}, "DELETE FROM history.scan_drbd_peers WHERE scan_drbd_peer_uuid = '".$scan_drbd_peer_uuid."';";
push @{$queries}, "DELETE FROM scan_drbd_peers WHERE scan_drbd_peer_uuid = '".$scan_drbd_peer_uuid."';";
foreach my $query (@{$queries})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { query => $query }});
}
$anvil->Database->write({query => $queries, source => $THIS_FILE, line => __LINE__});
next;
}
# Store the old data now. # Store the old data now.
$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{processed} = 0; $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{processed} = 0;
$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_scan_drbd_volume_uuid} = $scan_drbd_peer_scan_drbd_volume_uuid; $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_scan_drbd_volume_uuid} = $scan_drbd_peer_scan_drbd_volume_uuid;
$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_host_name} = $scan_drbd_peer_host_name; $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_host_name} = $scan_drbd_peer_host_name;
$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_connection_state} = $row->[3]; $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_connection_state} = $scan_drbd_peer_connection_state;
$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_local_disk_state} = $row->[4]; $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_local_disk_state} = $row->[4];
$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_disk_state} = $row->[5]; $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_disk_state} = $row->[5];
$anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_local_role} = $row->[6]; $anvil->data->{old}{scan_drbd_peer}{scan_drbd_peer_uuid}{$scan_drbd_peer_uuid}{scan_drbd_peer_local_role} = $row->[6];

@ -150,6 +150,7 @@ The global common configuration file: [#!variable!file!#] needs to be updated. T
#!variable!diff!# #!variable!diff!#
==== ====
</key> </key>
<key name="scan_drbd_message_0035">The DRBD peer: [#!variable!peer_name!#] resource: [#!variable!resource_name!#] volume: [#!variable!volume_number!#] was deleted, and the corresponding LVM data no longer exists. Purging this resource's data.</key>
<!-- Units --> <!-- Units -->
<key name="scan_drbd_unit_0001">Enabled</key> <key name="scan_drbd_unit_0001">Enabled</key>

@ -3224,6 +3224,7 @@ We will sleep a bit and try again.
<key name="warning_0142">[ Warning ] - The command: [#!variable!command!#] is still using our database.</key> <key name="warning_0142">[ Warning ] - The command: [#!variable!command!#] is still using our database.</key>
<key name="warning_0143">[ Warning ] - While evaluating database shutdown, the host UUID: [#!variable!host_uuid!#] was not yet found in the database on host: [#!variable!db_uuid!#]. DB shutdown will not happen until all hosts are in all DBs.</key> <key name="warning_0143">[ Warning ] - While evaluating database shutdown, the host UUID: [#!variable!host_uuid!#] was not yet found in the database on host: [#!variable!db_uuid!#]. DB shutdown will not happen until all hosts are in all DBs.</key>
<key name="warning_0144">[ Warning ] - While preparing to record the state: [#!variable!state_info!#], the host UUID: [#!variable!host_uuid!#] was not yet found in the database on host: [#!variable!db_uuid!#]. NOT recording the state!</key> <key name="warning_0144">[ Warning ] - While preparing to record the state: [#!variable!state_info!#], the host UUID: [#!variable!host_uuid!#] was not yet found in the database on host: [#!variable!db_uuid!#]. NOT recording the state!</key>
<key name="warning_0145">[ Warning ] - The daemon: [#!variable!daemon!#] was found running. It shouldn't be, and will now be stopped and disabled.</key>
<!-- The entries below here are not sequential, but use a key to find the entry. --> <!-- The entries below here are not sequential, but use a key to find the entry. -->
<!-- Run 'striker-parse-os-list to find new entries. --> <!-- Run 'striker-parse-os-list to find new entries. -->

@ -251,7 +251,7 @@ while(1)
check_ram($anvil); check_ram($anvil);
# Disconnect from the database(s) and sleep now. # Disconnect from the database(s) and sleep now.
$anvil->Database->disconnect({debug => 2}); $anvil->Database->disconnect();
sleep(2); sleep(2);
} }
@ -698,6 +698,24 @@ sub handle_periodic_tasks
# Now check to see if it's time to run daily tasks. # Now check to see if it's time to run daily tasks.
if ($now_time >= $anvil->data->{timing}{next_daily_check}) if ($now_time >= $anvil->data->{timing}{next_daily_check})
{ {
# Make sure ksm and ksmtuned are disabled.
foreach my $daemon ("ksm.service", "ksmtuned.service")
{
my $status = $anvil->System->check_daemon({daemon => $daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
daemon => $daemon,
status => $status,
}});
if ($status eq "1")
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, priority => "alert", key => "warning_0145", variables => { daemon => $daemon }});
$anvil->System->disable_daemon({
now => 1,
daemon => $daemon,
});
}
}
### NOTE: We call it once/day, but this will also trigger on restart of anvil-daemon. As such, we ### NOTE: We call it once/day, but this will also trigger on restart of anvil-daemon. As such, we
### don't use '--force' and let striker-manage-install-target skip the repo update if it happened ### don't use '--force' and let striker-manage-install-target skip the repo update if it happened
### recently enough. ### recently enough.

Loading…
Cancel
Save