From 284a2957d6fdf2fe066b5655cab41eb64b26eae6 Mon Sep 17 00:00:00 2001 From: digimer Date: Mon, 8 May 2023 15:03:29 -0400 Subject: [PATCH] * Fixes issue #329; When multiple attributes exist when checking if we're in maintenance mode in fence_pacemaker, the expected hash reference was actually an array reference. * Fixed a bug in anvil-version-changes where update_file_location_ready() needed to be called before update_file_locations(). * Added a bit more logging for future debugging. Signed-off-by: digimer --- ocf/alteeve/server | 6 ++++++ tools/anvil-version-changes | 6 +++--- tools/fence_pacemaker | 41 ++++++++++++++++++++++++++++--------- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/ocf/alteeve/server b/ocf/alteeve/server index 8e9b9842..e670dd64 100755 --- a/ocf/alteeve/server +++ b/ocf/alteeve/server @@ -908,10 +908,16 @@ sub start_drbd_resource { # This is set to '1' if either the volumes are UpToDate or Sync'ing. $anvil->data->{drbd}{status}{$local_host}{resource}{$resource}{ok} = 0; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "drbd::status::${local_host}::resource::${resource}::ok" => $anvil->data->{drbd}{status}{$local_host}{resource}{$resource}{ok}, + }}); foreach my $volume (sort {$a cmp $b} keys %{$anvil->data->{drbd}{status}{$local_host}{resource}{$resource}{devices}{volume}}) { # This will be used to mark if a volume is being sync'ed later, if needed. $anvil->data->{drbd}{status}{$local_host}{resource}{$resource}{devices}{volume}{$volume}{ok} = 0; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "drbd::status::${local_host}::resource::${resource}::devices::volume::${volume}::ok" => $anvil->data->{drbd}{status}{$local_host}{resource}{$resource}{devices}{volume}{$volume}{ok}, + }}); my $disk_state = lc($anvil->data->{drbd}{status}{$local_host}{resource}{$resource}{devices}{volume}{$volume}{'disk-state'}); $disk_state = "" if not defined $disk_state; diff --git a/tools/anvil-version-changes b/tools/anvil-version-changes index 87c1ab5a..70f88873 100755 --- a/tools/anvil-version-changes +++ b/tools/anvil-version-changes @@ -62,6 +62,9 @@ $anvil->nice_exit({exit_code => 0}); sub striker_checks { my ($anvil) = @_; + + # This checks to make sure that the new 'file_locations' -> 'file_location_ready' column exists. + update_file_location_ready($anvil); # This replaces anvil_uuid with host_uuid to support more granular location info to support the new # multi-target DR system @@ -81,9 +84,6 @@ sub striker_checks # entries are copied. update_dr_links($anvil); - # This checks to make sure that the new 'file_locations' -> 'file_location_ready' column exists. - update_file_location_ready($anvil); - ### TODO: Remove these later. This is here to clean up how we used to handle db_in_use and lock_request flags. if (1) { diff --git a/tools/fence_pacemaker b/tools/fence_pacemaker index af202975..352656bf 100755 --- a/tools/fence_pacemaker +++ b/tools/fence_pacemaker @@ -481,15 +481,36 @@ sub identify_peer # This is me. Am I in maintenance mode? if (exists $hash_ref->{instance_attributes}) { - # We've got some data... - my $name = defined $hash_ref->{instance_attributes}{nvpair}{name} ? $hash_ref->{instance_attributes}{nvpair}{name} : ""; - my $value = defined $hash_ref->{instance_attributes}{nvpair}{value} ? $hash_ref->{instance_attributes}{nvpair}{value} : ""; - to_log($conf, {message => "node: [".$node."] instance attribyte name: [".$name."], value: [".$value."]", 'line' => __LINE__, level => 1}); - if (($name eq "maintenance") and ($value eq "on")) + next if not exists $hash_ref->{instance_attributes}{nvpair}; + my $reference = ref($hash_ref->{instance_attributes}{nvpair}); + to_log($conf, {message => "Instance attribute reference type: [".$reference."]", 'line' => __LINE__, level => 3}); + if ($reference eq "ARRAY") { - # We're in maintenance mode, abort. - to_log($conf, {message => "This node is in maintenance mode. Not able to fence!", 'line' => __LINE__, level => 0, priority => "err"}); - exit(1); + foreach my $array_ref (@{$hash_ref->{instance_attributes}{nvpair}}) + { + my $id = $array_ref->{id}; + my $name = $array_ref->{name}; + my $value = $array_ref->{value}; + to_log($conf, {message => "Instance attribute ID: [".$id."], name: [".$name."], value: [".$value."]", 'line' => __LINE__, level => 3}); + if (($name eq "maintenance") and ($value eq "on")) + { + # We're in maintenance mode, abort. + to_log($conf, {message => "This node is in maintenance mode. Not able to fence!", 'line' => __LINE__, level => 0, priority => "err"}); + exit(1); + } + } + } + elsif ($reference eq "HASH") + { + my $name = defined $hash_ref->{instance_attributes}{nvpair}{name} ? $hash_ref->{instance_attributes}{nvpair}{name} : ""; + my $value = defined $hash_ref->{instance_attributes}{nvpair}{value} ? $hash_ref->{instance_attributes}{nvpair}{value} : ""; + to_log($conf, {message => "node: [".$node."] instance attribyte name: [".$name."], value: [".$value."]", 'line' => __LINE__, level => 1}); + if (($name eq "maintenance") and ($value eq "on")) + { + # We're in maintenance mode, abort. + to_log($conf, {message => "This node is in maintenance mode. Not able to fence!", 'line' => __LINE__, level => 0, priority => "err"}); + exit(1); + } } } } @@ -627,7 +648,7 @@ sub find_executables my @dirs = split/:/, $ENV{PATH}; foreach my $exe (sort {$b cmp $a} keys %{$conf->{path}{exe}}) { - if ( not -e $conf->{path}{exe}{$exe} ) + if (not -e $conf->{path}{exe}{$exe}) { to_log($conf, {message => "The program: [".$exe."] is not at: [".$conf->{path}{exe}{$exe}."]. Looking for it now...", 'line' => __LINE__, level => 1}); foreach my $path (@dirs) @@ -655,7 +676,7 @@ sub find_executables } else { - to_log($conf, {message => "Found!", 'line' => __LINE__, level => 3}); + to_log($conf, {message => "Found: [".$exe."] at: [".$conf->{path}{exe}{$exe}."]!", 'line' => __LINE__, level => 3}); next; }