---
 src/fm/Makefile.am    |  1 +
 src/fm/fmd/fm_main.cc | 12 ++++++++++++
 src/fm/fmd/fm_rda.cc  | 26 ++++++++++++++++++++++++++
 src/fm/fmd/fmd.conf   |  8 ++++++++
 4 files changed, 47 insertions(+)

diff --git a/src/fm/Makefile.am b/src/fm/Makefile.am
index d48a9146c..0f254b94f 100644
--- a/src/fm/Makefile.am
+++ b/src/fm/Makefile.am
@@ -49,4 +49,5 @@ bin_osaffmd_SOURCES = \
 bin_osaffmd_LDADD = \
        lib/libSaAmf.la \
        lib/libSaClm.la \
+       lib/libosaf_common.la \
        lib/libopensaf_core.la
diff --git a/src/fm/fmd/fm_main.cc b/src/fm/fmd/fm_main.cc
index db8395ee7..1d3cba766 100644
--- a/src/fm/fmd/fm_main.cc
+++ b/src/fm/fmd/fm_main.cc
@@ -24,6 +24,7 @@ This file contains the main() routine for FM.
 ******************************************************************************/
 
 #include "osaf/configmake.h"
+#include "osaf/consensus/service.h"
 #include <stdlib.h>
 #include <stdbool.h>
 #include "base/daemon.h"
@@ -593,6 +594,12 @@ static void fm_mbx_msg_handler(FM_CB *fm_cb, FM_EVT 
*fm_mbx_evt)
                                 * trigerred quicker than the node_down event
                                 * has been received.
                                 */
+                               if (fm_cb->role == PCS_RDA_STANDBY) {
+                                       // update consensus service, before 
fencing old active controller
+                                       Consensus consensus_service;
+                                       consensus_service.DemoteCurrentActive();
+                               }
+
                                if (fm_cb->use_remote_fencing) {
                                        if (fm_cb->peer_node_terminated ==
                                            false) {
@@ -659,6 +666,11 @@ static void fm_mbx_msg_handler(FM_CB *fm_cb, FM_EVT 
*fm_mbx_evt)
                                    0, NULL,
                                    "Failover occurred, but this node is not 
yet ready");
                        }
+
+                       // update consensus service, before fencing old active 
controller
+                       Consensus consensus_service;
+                       consensus_service.DemoteCurrentActive();
+
                        /* Now. Try resetting other blade */
                        fm_cb->role = PCS_RDA_ACTIVE;
 
diff --git a/src/fm/fmd/fm_rda.cc b/src/fm/fmd/fm_rda.cc
index 5c1b33e2f..0cec70a05 100644
--- a/src/fm/fmd/fm_rda.cc
+++ b/src/fm/fmd/fm_rda.cc
@@ -19,7 +19,9 @@
 #include <string.h>
 #include <syslog.h>
 #include "rde/agent/rda_papi.h"
+#include "osaf/consensus/service.h"
 #include "base/logtrace.h"
+
 extern void rda_cb(uint32_t cb_hdl, PCS_RDA_CB_INFO *cb_info,
        PCSRDA_RETURN_CODE error_code);
 /****************************************************************************
@@ -83,8 +85,27 @@ uint32_t fm_rda_set_role(FM_CB *fm_cb, PCS_RDA_ROLE role)
        rda_req.req_type = PCS_RDA_SET_ROLE;
        rda_req.info.io_role = role;
 
+       osafassert(role == PCS_RDA_ACTIVE);
+
+       Consensus consensus_service;
+       rc = consensus_service.DemoteCurrentActive();
+       if (rc != SA_AIS_OK) {
+               LOG_ER("Failed to demote old active node from consensus 
service");
+       }
+
+       rc = consensus_service.BeginActivePromotion();
+       if (rc != SA_AIS_OK) {
+               LOG_ER("Unable to set active controller in consensus service");
+               LOG_ER("Split brain is possible");
+       }
+
        rc = pcs_rda_request(&rda_req);
        if (rc != PCSRDA_RC_SUCCESS) {
+               rc = consensus_service.EndActivePromotion();
+               if (rc != SA_AIS_OK) {
+                       LOG_ER("Unable to remove lock in consensus service");
+               }
+
                syslog(
                    LOG_INFO,
                    "fm_rda_set_role() Failed: CurrentState: %s, AskedState: 
%s",
@@ -92,6 +113,11 @@ uint32_t fm_rda_set_role(FM_CB *fm_cb, PCS_RDA_ROLE role)
                return NCSCC_RC_FAILURE;
        }
 
+       rc = consensus_service.EndActivePromotion();
+       if (rc != SA_AIS_OK) {
+               LOG_ER("Unable to remove lock in consensus service");
+       }
+
        syslog(LOG_INFO,
               "fm_rda_set_role() Success: CurrentState: %s, AskedState: %s",
               role_string[fm_cb->role], role_string[role]);
diff --git a/src/fm/fmd/fmd.conf b/src/fm/fmd/fmd.conf
index 6921017f7..521bfcabc 100644
--- a/src/fm/fmd/fmd.conf
+++ b/src/fm/fmd/fmd.conf
@@ -26,6 +26,14 @@ export FMS_NODE_ISOLATION_TIMEOUT=0
 # To enable remote fencing change to 1
 export FMS_USE_REMOTE_FENCING=0
 
+# TODO: change before pushing
+#export SPLIT_BRAIN_PREVENTION=0
+export SPLIT_BRAIN_PREVENTION=1
+
+# TODO: change before pushing
+#export KEYVALUE_STORE_PLUGIN_CMD=
+export KEYVALUE_STORE_PLUGIN_CMD=/usr/local/lib/opensaf/etcd.plugin
+
 # FM will supervise transitions to the ACTIVE role when this variable is set to
 # a non-zero value. The value is the time in the unit of 10 ms to wait for a
 # role change to ACTIVE to take effect. If AMF has not give FM an active
-- 
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to