From b06123cc04d5a6461f15eb1f837c12d04e98a62a Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 25 Feb 2019 11:52:47 +0100 Subject: [PATCH 1/3] sync host --- scripts/onehost_create_all | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/onehost_create_all b/scripts/onehost_create_all index fefb1c4..411f892 100755 --- a/scripts/onehost_create_all +++ b/scripts/onehost_create_all @@ -39,6 +39,21 @@ function register_node() return $? } +# Fix host creation error from 5.6.1 with sync methode rsync +function sync_host() +{ + CMD="onehost" + OPT="sync -f --rsync" + AUTH=$(get_one_auth) + res=$(su - oneadmin -c "${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:}") + if [[ ${?} -ne 0 ]] + then + error "Hosts sync failed" + else + echo "Hosts sync OK" + fi +} + # # NAME: wait_node_ok # AIM: Wait until the node is OK or ERROR @@ -58,7 +73,7 @@ function wait_node_ok() [[ ${st} == '' ]] && break if [[ ${st} == "ERROR" ]] then - RET=2 + RET=50 break fi @@ -122,6 +137,7 @@ for host in ${HAPY_SLV}; do EchoVert " * Enregistrement du noeud" register_node ${host} + sync_host ${host} wait_node_ok ${host} if [[ ${?} -ne 0 ]] then From 4c7ebd5d278761406e38cc806e9367a2ccf62c33 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 25 Feb 2019 11:56:15 +0100 Subject: [PATCH 2/3] sync host --- scripts/onehost_create_all | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/onehost_create_all b/scripts/onehost_create_all index 411f892..358c990 100755 --- a/scripts/onehost_create_all +++ b/scripts/onehost_create_all @@ -44,8 +44,7 @@ function sync_host() { CMD="onehost" OPT="sync -f --rsync" - AUTH=$(get_one_auth) - res=$(su - oneadmin -c "${CMD} ${OPT} --user ${AUTH%:*} --password ${AUTH#*:}") + res=$(su - oneadmin -c "${CMD} ${OPT}") if [[ ${?} -ne 0 ]] then error "Hosts sync failed" From 42dfb0cdaa3fb6a7740d089e91dd48e21aa1002c Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 25 Feb 2019 12:11:30 +0100 Subject: [PATCH 3/3] onehost_create_all --- postservice/30-one-mng | 4 +--- postservice/99-z-ha | 20 ------------------- scripts/onehost_create_all | 39 ++++++++++++++++++++++++++++++-------- 3 files changed, 32 insertions(+), 31 deletions(-) delete mode 100755 postservice/99-z-ha diff --git a/postservice/30-one-mng b/postservice/30-one-mng index 8a4bef8..98f4f57 100755 --- a/postservice/30-one-mng +++ b/postservice/30-one-mng @@ -462,9 +462,7 @@ function main() # # Creating Host # - if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then - /usr/share/eole/sbin/onehost_create_all - else + if [ ! "$(CreoleGet activer_one_ha)" = "oui" ]; then if [[ $(CreoleGet eole_module non) != 'hapy-master' ]] then host=$(CreoleGet nom_machine) diff --git a/postservice/99-z-ha b/postservice/99-z-ha deleted file mode 100755 index fcf1278..0000000 --- a/postservice/99-z-ha +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -function init_ha_leader() { - # server with index 1 exists if already instanciate - onezone show 0 | grep -A 3 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 1 " - if [ ! $? = 0 ]; then - FOLLOWER=$(CreoleGet one_nodes) - for follower in $FOLLOWER; do - onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2 - done - fi -} - -if [ "$(CreoleGet activer_one_ha)" = "oui" ]; then - if [ "$(CreoleGet one_ha_server_index)" = "0" ]; then - init_ha_leader - fi -fi - -exit 0 diff --git a/scripts/onehost_create_all b/scripts/onehost_create_all index 358c990..5849706 100755 --- a/scripts/onehost_create_all +++ b/scripts/onehost_create_all @@ -36,7 +36,12 @@ function register_node() { cmd="onehost create -i kvm -v kvm -c 0 ${1}" ret=$(su - ${ONEUSER} -c -- "${cmd}") - return $? + if [[ ${?} -ne 0 ]] + then + EchoRouge "Hosts register failed $res" + else + EchoVert "Hosts register OK" + fi } # Fix host creation error from 5.6.1 with sync methode rsync @@ -44,12 +49,12 @@ function sync_host() { CMD="onehost" OPT="sync -f --rsync" - res=$(su - oneadmin -c "${CMD} ${OPT}") + res=$(su - ${ONEUSER} -c "${CMD} ${OPT}") if [[ ${?} -ne 0 ]] then - error "Hosts sync failed" + EchoRouge "Hosts sync failed $res" else - echo "Hosts sync OK" + EchoVert "Hosts sync OK" fi } @@ -87,6 +92,17 @@ function wait_node_ok() return ${RET} } +function init_ha_leader() { + # server with index 1 exists if already instanciate + onezone show 0 | grep -A 3 ^"HA & FEDERATION SYNC STATUS" | tail -n 1 | grep -q ^" 1 " + if [ ! $? = 0 ]; then + FOLLOWER=$(CreoleGet one_nodes) + for follower in $FOLLOWER; do + onezone server-add 0 --name $follower --rpc http://$follower:2633/RPC2 + done + fi +} + # # MAIN # @@ -117,10 +133,14 @@ then exit 1 fi -if [ "$(CreoleGet activer_one_ha)" = "oui" ] && [ "$(CreoleGet one_ha_server_index)" != "0" ]; then - follower=0 -else - follower=1 +follower=1 +master=1 +if [ "$(CreoleGet activer_one_ha)" = "oui" ]; + if [ "$(CreoleGet one_ha_server_index)" != "0" ]; then + follower=0 + else + master=0 + fi fi for host in ${HAPY_SLV}; do echo -e "\n" @@ -144,5 +164,8 @@ for host in ${HAPY_SLV}; do fi done +if [ $master = 0 ]; then + init_ha_leader +fi echo -e "\n" EchoVert "Enregistrement des noeuds terminé"