'etcdctl watch' will return if connection to the etcd server is lost.
If that occurs, send a 'fake' takeover request to rded so rded
will reboot the node. This is in alignment with the etcd v3 plugin.
---
src/osaf/consensus/plugins/etcd.plugin | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/src/osaf/consensus/plugins/etcd.plugin
b/src/osaf/consensus/plugins/etcd.plugin
index f62cc89..f88a7e7 100644
--- a/src/osaf/consensus/plugins/etcd.plugin
+++ b/src/osaf/consensus/plugins/etcd.plugin
@@ -17,7 +17,9 @@
# backward compatible. This plugin may need to be adapted.
readonly keyname="opensaf_consensus_lock"
+readonly takeover_request="takeover_request"
readonly directory="/opensaf/"
+readonly node_name_file="/etc/opensaf/node_name"
readonly etcd_options="--no-sync"
readonly etcd_timeout="5s"
@@ -27,7 +29,8 @@ readonly etcd_timeout="5s"
# $1 - <key>
# returns:
# 0 - success, <value> is echoed to stdout
-# non-zero - failure
+# 1 - invalid param
+# other - failure
get() {
readonly key="$1"
@@ -36,7 +39,7 @@ get() {
echo "$value"
return 0
else
- return 1
+ return 2
fi
}
@@ -73,7 +76,8 @@ setkey() {
# returns:
# 0 - success
# 1 - already exists
-# 2 or above - other failure
+# 2 - invalid param
+# 3 or above - other failure
create_key() {
readonly key="$1"
readonly value="$2"
@@ -90,7 +94,7 @@ create_key() {
fi
fi
- return 2
+ return 3
}
# set
@@ -103,7 +107,8 @@ create_key() {
# $4 - <timeout>
# returns:
# 0 - success
-# non-zero - failure
+# 1 - invalid param
+# other - failure
setkey_match_prev() {
readonly key="$1"
readonly value="$2"
@@ -115,7 +120,7 @@ setkey_match_prev() {
then
return 0
else
- return 1
+ return 2
fi
}
@@ -158,7 +163,8 @@ lock() {
return 0
fi
- if current_owner=$(etcdctl get "$directory$keyname")
+ if current_owner=$(etcdctl $etcd_options --timeout $etcd_timeout \
+ get "$directory$keyname")
then
# see if we already hold the lock
if [ "$current_owner" = "$owner" ]; then
@@ -252,7 +258,14 @@ watch() {
echo "$value"
return 0
else
- return 1
+ # etcd down?
+ if [ "$key" = "$takeover_request" ]; then
+ hostname=`cat $node_name_file`
+ echo "$hostname SC-0 10000000 UNDEFINED"
+ return 0
+ else
+ return 1
+ fi
fi
}
--
2.7.4
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel