From bc341809caf8e2c28248721741ac660d3beb650a Mon Sep 17 00:00:00 2001 From: Digimer Date: Wed, 4 Sep 2019 18:58:43 -0400 Subject: [PATCH] * Finished (for now) ocf:alteeve:server! It can boot, migrate and stop a server cleanly. It still checks to see if DRBD needs to be started and does so when needed, but it won't stop it anymore. * Fixed a couple typos in tools/anvil-check-memory that prevented it from running. Signed-off-by: Digimer --- notes | 2 ++ ocf/alteeve/server | 17 ++++------------- share/words.xml | 1 + tools/anvil-check-memory | 4 ++-- tools/anvil-daemon | 8 ++++---- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/notes b/notes index 0ee75c88..205a43a6 100644 --- a/notes +++ b/notes @@ -507,6 +507,8 @@ pcs resource clone hypervisor clone-max=2 notify="false" pcs resource create drbd systemd:drbd op monitor interval=60 pcs resource clone drbd clone-max=2 notify="false" +pcs resource create test_server ocf:alteeve:server name="test_server" meta allow-migrate="true" op monitor interval="60" +- or - pcs resource update test_server ocf:alteeve:server name="test_server" meta allow-migrate="true" op monitor interval="60" # Test diff --git a/ocf/alteeve/server b/ocf/alteeve/server index 0d02270e..127fa56d 100755 --- a/ocf/alteeve/server +++ b/ocf/alteeve/server @@ -98,9 +98,6 @@ my $anvil = Anvil::Tools->new(); $anvil->Log->level({set => 2}); $anvil->Log->secure({set => 1}); -# For the logs... -$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, secure => 0, key => "log_0115", variables => { program => 'ocf:alteeve:'.$THIS_FILE }}); - ### Read or Set the environment variables # This is the name of the server we're managing. # Example values: $anvil->data->{environment}{OCF_RESKEY_name} = defined $ENV{OCF_RESKEY_name} ? $ENV{OCF_RESKEY_name} : ""; # srv01-c7 @@ -146,14 +143,8 @@ if ($anvil->data->{switches}{stop_drbd_resources}) $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source} = 1; } -#$anvil->DRBD->get_status({debug => 2}); -#die; - # Something for the logs -if ((not $anvil->data->{switches}{metadaata}) and (not $anvil->data->{switches}{'meta-data'})) -{ - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 3, key => "log_0298"}); -} +$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 3, key => "log_0298"}); ### TEST: to be removed later if ($anvil->data->{switches}{test1}) @@ -163,7 +154,7 @@ if ($anvil->data->{switches}{test1}) $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node} = "el8-a01n01.digimer.ca"; $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source} = "el8-a01n01.digimer.ca"; $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} = "el8-a01n02.digimer.ca"; - print "Running test 1; Migrate: [".$anvil->data->{environment}{OCF_RESKEY_name}."] from: [".$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source}."] to: [".$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target}."]\n"; + #print "Running test 1; Migrate: [".$anvil->data->{environment}{OCF_RESKEY_name}."] from: [".$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source}."] to: [".$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target}."]\n"; } if ($anvil->data->{switches}{test2}) { @@ -172,7 +163,7 @@ if ($anvil->data->{switches}{test2}) $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node} = "el8-a01n02.digimer.ca"; $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source} = "el8-a01n02.digimer.ca"; $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} = "el8-a01n01.digimer.ca"; - print "Running test 2; Migrate: [".$anvil->data->{environment}{OCF_RESKEY_name}."] from: [".$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source}."] to: [".$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target}."]\n"; + #print "Running test 2; Migrate: [".$anvil->data->{environment}{OCF_RESKEY_name}."] from: [".$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source}."] to: [".$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target}."]\n"; } if ($anvil->data->{switches}{test3}) { @@ -428,7 +419,7 @@ sub start_drbd_resource } else { - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0419", variables => { + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0434", variables => { resource => $resource, role => $role, }}); diff --git a/share/words.xml b/share/words.xml index cc7a0bc0..3f63e858 100644 --- a/share/words.xml +++ b/share/words.xml @@ -751,6 +751,7 @@ Failed to promote the DRBD resource: [#!variable!resource!#] primary. Expected a All DRBD resources appear to be up, skipping individual DRBD resource startup. archive_database() was not passed an array reference of tables to archive. Please pass an array reference using the 'tables' parameter.]]> The 'smaps' proc file for the process ID: [#!variable!pid!#] was not found. Did the program just close? + - The DRBD resource: [#!variable!resource!#] is in the role: [#!variable!role!#] already, no need to bring it up. Test diff --git a/tools/anvil-check-memory b/tools/anvil-check-memory index 3abe96af..29369579 100755 --- a/tools/anvil-check-memory +++ b/tools/anvil-check-memory @@ -69,7 +69,7 @@ foreach my $pid (sort {$a cmp $b} @{$anvil->data->{sys}{pids}}) $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { smaps_path => $smaps_path }}); # This will store the amount of RAM used by this specific PID. - $an->data->{memory}{pid}{$pid} = 0; + $anvil->data->{memory}{pid}{$pid} = 0; if (not -e $smaps_path) { @@ -115,5 +115,5 @@ foreach my $pid (sort {$a cmp $b} @{$anvil->data->{sys}{pids}}) } # Report and exit. -print $anvil->data->{switches}{program}." = ".$an->data->{memory}{total}." # ".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{memory}{total}})."\n"; +print $anvil->data->{switches}{program}." = ".$anvil->data->{memory}{total}." # ".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{memory}{total}})."\n"; $anvil->nice_exit({exit_code => 0}); diff --git a/tools/anvil-daemon b/tools/anvil-daemon index 5d49c523..36d22b5b 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -153,7 +153,7 @@ while(1) $anvil->Get->switches; # Re-read to let switches override again. $anvil->Words->read(); $anvil->Database->connect({check_if_configured => $check_if_database_is_configured}); - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"}); # Mark that we don't want to check the database now. $check_if_database_is_configured = 0; @@ -824,8 +824,8 @@ sub check_firewall my ($anvil) = @_; # Don't call this if we're not configured yet. - my $configured = $anvil->System->check_if_configured({debug => 2}); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { configured => $configured }}); + my $configured = $anvil->System->check_if_configured({debug => 3}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { configured => $configured }}); # Check the firewall needs to be updated. if ($configured) @@ -973,7 +973,7 @@ sub keep_running # Update hardware state files if the system isn't configured. Running it always is too intensive. my $configured = $anvil->System->check_if_configured; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { configured => $configured }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { configured => $configured }}); if (not $configured) { update_state_file($anvil);