MNAIO: Recovery the galera cluster with no gvwstate.dat file

On occasion, a set of saved images may not have a gvwstate.dat file.
Given that the MNAIO tooling is for test purposes only, we can take
the risk of just making one up in order to ensure that the cluster
starts on boot. DO NOT DO THIS IN PRODUCTION!

Change-Id: I1b055ef0d02d77afe03d1a90baa2e6890e986c32
This commit is contained in:
Jesse Pretorius 2018-12-12 12:51:45 +00:00
parent 3bb90710fe
commit bd82c6a3e5
2 changed files with 14 additions and 3 deletions

View File

@ -131,7 +131,7 @@
command: /opt/prepare-image-galera.sh
register: _galera_prepare
# guestfissh does not always give a return code which indicates
# guestfish does not always give a return code which indicates
# failure, so we look for our final stdout output as an indicator
- name: Fail if the preparation script did not complete
fail:

View File

@ -54,6 +54,10 @@ for cnt in $(ls -1 /tmp | grep galera_container); do
master_gvwstate_path=${gvwstate_path}
master_cnt=${cnt}
fi
else
# if there is no gvwstate.dat file, then we will
# need to use my_uuid later to generate one
my_uuid=${uuid_map[$cnt]}
fi
# if a master container was found, overwrite the uuid
@ -70,8 +74,15 @@ if [[ "${master_gvwstate_path:-none}" != "none" ]]; then
elif [[ "${last_gvwstate_path:-none}" != "none" ]]; then
cp ${last_gvwstate_path} ${tmp_gvwstate}
else
echo "ERROR: No gvwstate.dat file was found. Cannot prepare galera cluster for cluster initialization."
exit 1
echo "No gvwstate.dat file was found. Attempting to put one together."
cat > ${tmp_gvwstate}<< EOF
my_uuid: ${my_uuid}
#vwbeg
view_id: 3 ${my_uuid} 3
bootstrap: 0
member: ${my_uuid} 0
#vwend
EOF
fi
member_num=$(awk '/^member: '${my_uuid}'/ {print $3}' ${tmp_gvwstate})