In etcd3.plugin, if the unlock transaction times out
for some reason, unlock() would return 1, indicating it is owned by
someone else when it isn't because lock_owner was not
being called correctly.

Also PromoteThisNode() would indicate a successful lock
attempt when it failed, because rc was overwritten.
---
 src/osaf/consensus/consensus.cc         |  8 ++++----
 src/osaf/consensus/plugins/etcd3.plugin | 23 +++++++++++++++--------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/src/osaf/consensus/consensus.cc b/src/osaf/consensus/consensus.cc
index a6248136d..ac5573585 100644
--- a/src/osaf/consensus/consensus.cc
+++ b/src/osaf/consensus/consensus.cc
@@ -89,8 +89,8 @@ SaAisErrorT Consensus::PromoteThisNode(const bool 
graceful_takeover,
     }
 
     if (take_over_request_created == true) {
-      rc = RemoveTakeoverRequest();
-      if (rc != SA_AIS_OK) {
+      SaAisErrorT rc1 = RemoveTakeoverRequest();
+      if (rc1 != SA_AIS_OK) {
         LOG_WA("Could not remove takeover request");
       }
     }
@@ -364,9 +364,9 @@ SaAisErrorT Consensus::CreateTakeoverRequest(const 
std::string& current_owner,
     return CreateTakeoverRequest(current_owner, proposed_owner, cluster_size);
   }
 
-  // wait up to 10s for request to be answered
+  // wait up to 15s for request to be answered
   retries = 0;
-  while (retries < kMaxTakeoverRetry) {
+  while (retries < (kMaxTakeoverRetry * 1.5)) {
     std::vector<std::string> tokens;
     if (ReadTakeoverRequest(tokens) == SA_AIS_OK) {
       const std::string state =
diff --git a/src/osaf/consensus/plugins/etcd3.plugin 
b/src/osaf/consensus/plugins/etcd3.plugin
index 07fc9f2e1..1023ea08f 100644
--- a/src/osaf/consensus/plugins/etcd3.plugin
+++ b/src/osaf/consensus/plugins/etcd3.plugin
@@ -38,8 +38,14 @@ get() {
     key_=$(echo "$output" | tail -n2 | head -n1)
     value=$(echo "$output" | tail -n1)
     if [ "$key_" = "$directory$key" ]; then
-      echo "$value"
-      return 0
+      if [ "$key_" = "$value" ]; then
+        # blank value returned
+        echo ""
+        return 0
+      else
+        echo "$value"
+        return 0
+      fi
     else
       # key missing!
       return 1
@@ -258,12 +264,13 @@ unlock() {
     fi
 
     # failed! check we own the lock
-    current_owner=lock_owner
-    if [[ "$owner" != "$current_owner" && -n "$current_owner" ]]; then
-      # for troubleshooting
-      echo "$output"
-      echo "$current_owner"
-      return 1
+    if current_owner=$(lock_owner); then
+      if [[ "$owner" != "$current_owner" && -n "$current_owner" ]]; then
+        # for troubleshooting
+        echo "$output"
+        echo "$current_owner"
+        return 1
+      fi
     fi
 
     # for troubleshooting
-- 
2.14.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to