Merge pull request #407 from ClusterLabs/ocf-alteeve-server-fixes

Ocf alteeve server fixes
main
Digimer 1 year ago committed by GitHub
commit 05165da193
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      Anvil/Tools.pm
  2. 20
      Anvil/Tools/Cluster.pm
  3. 44
      ocf/alteeve/server
  4. 3
      tools/Makefile.am
  5. 10
      tools/anvil-virsh-wrapper

@ -1308,7 +1308,7 @@ sub _set_paths
useradd => "/usr/sbin/useradd",
usermod => "/usr/sbin/usermod",
uuidgen => "/usr/bin/uuidgen",
virsh => "/usr/bin/virsh",
virsh => "/usr/sbin/anvil-virsh-wrapper",
'virt-install' => "/usr/bin/virt-install",
websockify => "/usr/bin/websockify",
wipefs => "/usr/sbin/wipefs",

@ -253,7 +253,14 @@ sub add_server
undef $output;
undef $return_code;
my $resource_command = $anvil->data->{path}{exe}{pcs}." -f ".$pcs_file." resource create ".$server_name." ocf:alteeve:server name=\"".$server_name."\" meta allow-migrate=\"true\" target-role=\"".$target_role."\" op monitor interval=\"60\" start timeout=\"60\" on-fail=\"block\" stop timeout=\"300\" on-fail=\"block\" migrate_to timeout=\"600\" on-fail=\"block\" migrate_from timeout=\"600\" on-fail=\"block\"";
my $resource_command = $anvil->data->{path}{exe}{pcs}." -f ".$pcs_file." resource create ".$server_name." ocf:alteeve:server ";
$resource_command .= "name=\"".$server_name."\" log_level=".$anvil->Log->level." log_secure=".$anvil->Log->secure." ";
$resource_command .= "meta allow-migrate=\"true\" target-role=\"".$target_role."\" ";
$resource_command .= "op monitor interval=\"60\" timeout=\"60\" ";
$resource_command .= "start timeout=\"60\" on-fail=\"block\" ";
$resource_command .= "stop timeout=\"300\" on-fail=\"block\" ";
$resource_command .= "migrate_to timeout=\"600\" on-fail=\"block\" ";
$resource_command .= "migrate_from timeout=\"600\" on-fail=\"block\"";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { resource_command => $resource_command }});
($output, $return_code) = $anvil->System->call({shell_call => $resource_command});
@ -747,15 +754,14 @@ sub boot_server
if ($node)
{
$anvil->Cluster->_set_server_constraint({
debug => $debug,
server => $server,
preferred_node => $node,
});
}
### TODO: Make sure that the drbd fence rule exists in pacemaker and add it, if not.
# Now boot the server.
my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{pcs}." resource enable ".$server});
my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $anvil->data->{path}{exe}{pcs}." resource enable ".$server});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
output => $output,
return_code => $return_code,
@ -965,6 +971,7 @@ sub check_server_constraints
# Make us the preferred node.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0641", variables => { server => $resource }});
$anvil->Cluster->_set_server_constraint({
debug => $debug,
server => $resource,
preferred_node => $local_node_name,
});
@ -3079,7 +3086,7 @@ sub migrate_server
if ($node)
{
$anvil->Cluster->_set_server_constraint({
debug => 2,
debug => $debug,
server => $server,
preferred_node => $node,
});
@ -4703,7 +4710,8 @@ sub _set_server_constraint
}
# Change the location constraint
my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call});
$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 => {
output => $output,
return_code => $return_code,

@ -110,7 +110,7 @@ $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node} = defined $ENV{O
# This says "UUID", but it's the node ID.
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node_uuid} = defined $ENV{OCF_RESKEY_CRM_meta_on_node_uuid} ? $ENV{OCF_RESKEY_CRM_meta_on_node_uuid} : ""; # Not used here, contains the pacemaker node ID
# This is the timeout for the called action in millisecond.
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_timeout} = defined $ENV{OCF_RESKEY_CRM_meta_timeout} ? $ENV{OCF_RESKEY_CRM_meta_timeout} : ""; # 20000
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_timeout} = defined $ENV{OCF_RESKEY_CRM_meta_timeout} ? $ENV{OCF_RESKEY_CRM_meta_timeout} : ""; # 60000
# If this is set, we'll bump our log level as well.
$anvil->data->{environment}{PCMK_debug} = defined $ENV{PCMK_debug} ? $ENV{PCMK_debug} : "0"; # Disable debug by default
# These are other variables that are set, but we don't currently care about them
@ -122,6 +122,8 @@ $anvil->data->{environment}{OCF_RESOURCE_INSTANCE} = defined $ENV{O
$anvil->data->{environment}{OCF_RESOURCE_PROVIDER} = defined $ENV{OCF_RESOURCE_PROVIDER} ? $ENV{OCF_RESOURCE_PROVIDER} : "alteeve";
$anvil->data->{environment}{OCF_RESOURCE_TYPE} = defined $ENV{OCF_RESOURCE_TYPE} ? $ENV{OCF_RESOURCE_TYPE} : "server";
$anvil->data->{environment}{OCF_ROOT} = defined $ENV{OCF_ROOT} ? $ENV{OCF_ROOT} : "/usr/lib/ocf";
$anvil->data->{environment}{OCF_RESKEY_log_level} = defined $ENV{OCF_RESKEY_log_level} ? $ENV{OCF_RESKEY_log_level} : "";
$anvil->data->{environment}{OCF_RESKEY_log_secure} = defined $ENV{OCF_RESKEY_log_secure} ? $ENV{OCF_RESKEY_log_secure} : "";
# These are set during a migration
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source} = defined $ENV{OCF_RESKEY_CRM_meta_migrate_source} ? $ENV{OCF_RESKEY_CRM_meta_migrate_source} : "";
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} = defined $ENV{OCF_RESKEY_CRM_meta_migrate_target} ? $ENV{OCF_RESKEY_CRM_meta_migrate_target} : "";
@ -147,6 +149,16 @@ if ($anvil->data->{environment}{PCMK_debug})
$anvil->Log->level({set => 2});
}
### TODO: Use the running log level in anvil-provision-server is used to set these log levels in the pcs call.
if (($anvil->data->{environment}{OCF_RESKEY_log_level}) && ($anvil->data->{environment}{OCF_RESKEY_log_level} >= 1) && ($anvil->data->{environment}{OCF_RESKEY_log_level} <= 3))
{
$anvil->Log->level({set => $anvil->data->{environment}{OCF_RESKEY_log_level}});
}
if ($anvil->data->{environment}{OCF_RESKEY_log_secure} == 1)
{
$anvil->Log->secure({set => 1});
}
# Originally, this was designed to start and stop a server's DRBD resources on demand. Early testing appears
# to show this prone to higher risk of fencing if something goes wrong. As such, we're changing the default
# behaviour to leave DRBD resources up. Set this to '1' (here or by switch) to revert back to the old
@ -342,9 +354,11 @@ elsif (($anvil->data->{switches}{help}) or ($anvil->data->{switches}{usage}))
}
elsif ($anvil->data->{switches}{notify})
{
### NOTE: See issue 392 (https://github.com/ClusterLabs/anvil/issues/392) to explain why we switched
### the RC from 3 to 0.
# We don't implement this
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level =>0, key => "log_0301"});
$anvil->nice_exit({exit_code => 3});
$anvil->nice_exit({exit_code => 0});
}
else
{
@ -1153,7 +1167,7 @@ sub server_status
if (not $anvil->data->{environment}{OCF_RESKEY_CRM_meta_timeout})
{
# Set a sane default of 20 seconds.
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_timeout} = 20000;
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_timeout} = 60000;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0331", variables => { timeout => $anvil->data->{environment}{OCF_RESKEY_CRM_meta_timeout} }});
}
@ -2056,7 +2070,7 @@ sub show_metadata
<version>1.0</version>
<longdesc lang="en">
This resource agent manages KVM+qemu virtual servers on an Anvil! m3 Intelligent Availability(tm) system.
It manages underlying components like DRBD 9 storage resources, brodge connections and so forth.
It manages underlying components like DRBD 9 storage resources, bridge connections and so forth.
</longdesc>
<shortdesc lang="en">Anvil! m3 server resource agent</shortdesc>
<parameters>
@ -2067,16 +2081,30 @@ It manages underlying components like DRBD 9 storage resources, brodge connectio
<shortdesc lang="en">Server name</shortdesc>
<content type="string"/>
</parameter>
<parameter name="log_level" unique="0" required="0">
<longdesc lang="en">
Set the logging level, valid values are 1 to 3, with 3 being extremely loud.
</longdesc>
<shortdesc lang="en">Set log level</shortdesc>
<content type="integer"/>
</parameter>
<parameter name="log_secure" unique="0" required="0">
<longdesc lang="en">
Enable logging of potentially sensitive data, like passwords.
</longdesc>
<shortdesc lang="en">Log secure data.</shortdesc>
<content type="integer"/>
</parameter>
</parameters>
<actions>
<action name="start" timeout="30" />
<action name="start" timeout="60" />
<action name="stop" timeout="60" />
<action name="monitor" timeout="10" />
<action name="notify" timeout="20" />
<action name="monitor" timeout="60" />
<action name="notify" timeout="60" />
<action name="migrate_to" timeout="600" />
<action name="migrate_from" timeout="600" />
<action name="meta-data" timeout="5" />
<action name="validate-all" timeout="20" />
<action name="validate-all" timeout="60" />
</actions>
</resource-agent>
';

@ -1,7 +1,5 @@
MAINTAINERCLEANFILES = Makefile.in
# XXX recheck after rebase!
dist_sbin_SCRIPTS = \
anvil-access-module \
anvil-boot-server \
@ -46,6 +44,7 @@ dist_sbin_SCRIPTS = \
anvil-update-states \
anvil-update-system \
anvil-version-changes \
anvil-virsh-wrapper \
anvil-watch-bonds \
anvil-watch-drbd \
anvil-watch-power \

@ -0,0 +1,10 @@
#!/bin/sh -e
(
if [ "$1" != "list" ]; then
virsh $@
exit $?
fi
flock -e 200
virsh $@
) 200>/tmp/virsh.lock
Loading…
Cancel
Save