Use consistent indent in .sh files

This change fixes the inconsistent indents in the bash script files.
Details are described below.

* Use 4 spaces instead of tabs. Currently tabs are used partially.

* Ensures the corresponding items(like if/else/fi) are placed at
  the same indent level.

Change-Id: Iccf01cd325e171fba8e399d22ee9e0a00f3e781b
This commit is contained in:
Takashi Kajinami 2022-02-28 23:54:34 +09:00
parent 71f5ceb459
commit e99a251ad4
2 changed files with 61 additions and 61 deletions

View File

@ -37,7 +37,7 @@ if [ x"${TRIPLEO_MINOR_UPDATE,,}" != x"true" ]; then
SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${TRIPLEO_SERVICE}_short_bootstrap_node_name") SERVICE_NODEID=$(/bin/hiera -c /etc/puppet/hiera.yaml "${TRIPLEO_SERVICE}_short_bootstrap_node_name")
if [[ "${HOSTNAME,,}" == "${SERVICE_NODEID,,}" ]]; then if [[ "${HOSTNAME,,}" == "${SERVICE_NODEID,,}" ]]; then
log "Initial deployment, skipping the restart of ${BUNDLE_NAME}" log "Initial deployment, skipping the restart of ${BUNDLE_NAME}"
fi fi
exit 0 exit 0
else else
# During a stack update, this script is called in parallel on # During a stack update, this script is called in parallel on
@ -76,28 +76,28 @@ else
HOST=$(facter hostname) HOST=$(facter hostname)
if bundle_can_be_restarted ${BUNDLE_NAME}; then if bundle_can_be_restarted ${BUNDLE_NAME}; then
# if the resource is running locally, restart it # if the resource is running locally, restart it
if crm_resource -r $BUNDLE_NAME --locate 2>&1 | grep -w -q "${HOST}"; then if crm_resource -r $BUNDLE_NAME --locate 2>&1 | grep -w -q "${HOST}"; then
log "Restarting ${BUNDLE_NAME} locally on '${HOST}'" log "Restarting ${BUNDLE_NAME} locally on '${HOST}'"
/sbin/pcs resource restart $BUNDLE_NAME "${HOST}" /sbin/pcs resource restart $BUNDLE_NAME "${HOST}"
else else
# At this point, if no resource is running locally, it's # At this point, if no resource is running locally, it's
# either because a) it has failed previously, or b) because # either because a) it has failed previously, or b) because
# it's an A/P resource running elsewhere. # it's an A/P resource running elsewhere.
# By cleaning up resource, we ensure that a) it will try to # By cleaning up resource, we ensure that a) it will try to
# restart, or b) it won't do anything if the resource is # restart, or b) it won't do anything if the resource is
# already running elsewhere. # already running elsewhere.
log "${BUNDLE_NAME} is currently not running on '${HOST}'," \ log "${BUNDLE_NAME} is currently not running on '${HOST}'," \
"cleaning up its state to restart it if necessary" "cleaning up its state to restart it if necessary"
/sbin/pcs resource cleanup $BUNDLE_NAME node="${HOST}" /sbin/pcs resource cleanup $BUNDLE_NAME node="${HOST}"
fi fi
# Wait until the resource is in the expected target state # Wait until the resource is in the expected target state
$RESTART_SCRIPTS_DIR/pacemaker_wait_bundle.sh \ $RESTART_SCRIPTS_DIR/pacemaker_wait_bundle.sh \
$RESOURCE_NAME $BUNDLE_NAME \ $RESOURCE_NAME $BUNDLE_NAME \
"$WAIT_TARGET_LOCAL" "$WAIT_TARGET_ANYWHERE" \ "$WAIT_TARGET_LOCAL" "$WAIT_TARGET_ANYWHERE" \
"${HOST}" __PCMKTIMEOUT__ "${HOST}" __PCMKTIMEOUT__
else else
log "No restart needed for ${BUNDLE_NAME}." log "No restart needed for ${BUNDLE_NAME}."
fi fi

View File

@ -55,8 +55,8 @@ bundle_failures_locally() {
local last=$(($replicas - 1)) local last=$(($replicas - 1))
local replica_name local replica_name
for i in $(seq 0 $last); do for i in $(seq 0 $last); do
replica_name=${BUNDLE_NAME}-${engine}-${i} replica_name=${BUNDLE_NAME}-${engine}-${i}
crm_failcount -q -G -r $replica_name -N $HOST crm_failcount -q -G -r $replica_name -N $HOST
done done
} }
@ -65,7 +65,7 @@ bundle_failures_globally() {
local replicas=$BUNDLE_REPLICAS local replicas=$BUNDLE_REPLICAS
local last=$(($replicas - 1)) local last=$(($replicas - 1))
for i in $(seq 0 $last); do for i in $(seq 0 $last); do
crm_failcount -q -G -r ${BUNDLE_NAME}-${engine}-${i} crm_failcount -q -G -r ${BUNDLE_NAME}-${engine}-${i}
done done
} }
@ -81,8 +81,8 @@ ocf_failures_globally() {
local last=$(($replicas - 1)) local last=$(($replicas - 1))
local bundle_node local bundle_node
for i in $(seq 0 $last); do for i in $(seq 0 $last); do
bundle_node=${BUNDLE_NAME}-${i} bundle_node=${BUNDLE_NAME}-${i}
crm_failcount -q -G -r $NAME -N $bundle_node crm_failcount -q -G -r $NAME -N $bundle_node
done done
} }
@ -91,18 +91,18 @@ did_resource_failed_locally() {
local running local running
local remotehost local remotehost
if [ "${NAME}" != "${BUNDLE_NAME}" ]; then if [ "${NAME}" != "${BUNDLE_NAME}" ]; then
# if we're dealing with an ocf resource, it is running on a # if we're dealing with an ocf resource, it is running on a
# pacemaker_remote rather that on the real host, and the # pacemaker_remote rather that on the real host, and the
# failcounts are thus associated to the pcmk remote. Replace # failcounts are thus associated to the pcmk remote. Replace
# the host's name with the pcmk remote's name. # the host's name with the pcmk remote's name.
remotehost=$(crm_mon --as-xml | xmllint --xpath "string(//resources/bundle[@id='${BUNDLE_NAME}']/replica/resource/node[@name='${HOST}']/../../resource[@resource_agent='${OCF}:pacemaker:remote']/@id)" -) remotehost=$(crm_mon --as-xml | xmllint --xpath "string(//resources/bundle[@id='${BUNDLE_NAME}']/replica/resource/node[@name='${HOST}']/../../resource[@resource_agent='${OCF}:pacemaker:remote']/@id)" -)
if [ -n "${remotehost}" ]; then if [ -n "${remotehost}" ]; then
crm_failcount -q -G -r $NAME -N $remotehost | grep -q -w INFINITY crm_failcount -q -G -r $NAME -N $remotehost | grep -q -w INFINITY
return $? return $?
fi fi
# If no pcmk remote is currently running, the failcount from # If no pcmk remote is currently running, the failcount from
# the ocf resource is useless, compute the failcount from the # the ocf resource is useless, compute the failcount from the
# bundle case instead (computed below). # bundle case instead (computed below).
fi fi
# for bundles, pacemaker can run any bundle replica locally # for bundles, pacemaker can run any bundle replica locally
@ -120,25 +120,25 @@ did_resource_failed_globally() {
local remotecount local remotecount
local failures local failures
if [ "${NAME}" != "${BUNDLE_NAME}" ]; then if [ "${NAME}" != "${BUNDLE_NAME}" ]; then
# we check the state of an ocf resource only if the # we check the state of an ocf resource only if the
# pcmkremotes are started # pcmkremotes are started
remotecount=$(crm_mon --as-xml | xmllint --xpath "count(//resources/bundle[@id='${BUNDLE_NAME}']/replica/resource[@resource_agent='${OCF}:pacemaker:remote']/node)" -) remotecount=$(crm_mon --as-xml | xmllint --xpath "count(//resources/bundle[@id='${BUNDLE_NAME}']/replica/resource[@resource_agent='${OCF}:pacemaker:remote']/node)" -)
if [ "${remotecount}" = "0" ]; then if [ "${remotecount}" = "0" ]; then
# no pcmkremote is running, so check the bundle state # no pcmkremote is running, so check the bundle state
# instead of checking the ocf resource # instead of checking the ocf resource
# bundle failed if all ${BUNDLE_REPLICAS} replicas failed # bundle failed if all ${BUNDLE_REPLICAS} replicas failed
failures=$(bundle_failures_globally | grep -c -w INFINITY) failures=$(bundle_failures_globally | grep -c -w INFINITY)
test $failures -eq $BUNDLE_REPLICAS test $failures -eq $BUNDLE_REPLICAS
else else
# ocf resource failed if it failed to start on # ocf resource failed if it failed to start on
# all $BUNDLE_REPLICAS bundle nodes # all $BUNDLE_REPLICAS bundle nodes
failures=$(ocf_failures_globally | grep -c -w INFINITY) failures=$(ocf_failures_globally | grep -c -w INFINITY)
test $failures -eq $BUNDLE_REPLICAS test $failures -eq $BUNDLE_REPLICAS
fi fi
else else
# bundle failed if all ${BUNDLE_REPLICAS} replicas failed # bundle failed if all ${BUNDLE_REPLICAS} replicas failed
failures=$(bundle_failures_globally | grep -c -w INFINITY) failures=$(bundle_failures_globally | grep -c -w INFINITY)
test $failures -eq $BUNDLE_REPLICAS test $failures -eq $BUNDLE_REPLICAS
fi fi
} }
@ -206,15 +206,15 @@ TIMEOUT=${6:-__PCMKTIMEOUT__}
# So instead, we implement various searches with XPath directly. # So instead, we implement various searches with XPath directly.
if [ "${BUNDLE_NAME}" != "${NAME}" ]; then if [ "${BUNDLE_NAME}" != "${NAME}" ]; then
# ocf resource # ocf resource
local_resource_xpath="//bundle/replica/resource[@resource_agent='${OCF}:pacemaker:remote']/node[@name='${HOST}']/../../resource[@id='${NAME}']" local_resource_xpath="//bundle/replica/resource[@resource_agent='${OCF}:pacemaker:remote']/node[@name='${HOST}']/../../resource[@id='${NAME}']"
any_resource_xpath="//bundle//resource[@id='${NAME}']" any_resource_xpath="//bundle//resource[@id='${NAME}']"
replicas_xpath="//bundle/primitive[@id='${BUNDLE_NAME}']/../*[boolean(@image) and boolean(@replicas)]" replicas_xpath="//bundle/primitive[@id='${BUNDLE_NAME}']/../*[boolean(@image) and boolean(@replicas)]"
else else
# bundle resource # bundle resource
local_resource_xpath="//bundle[@id='${NAME}']/replica/resource/node[@name='${HOST}']/../../resource" local_resource_xpath="//bundle[@id='${NAME}']/replica/resource/node[@name='${HOST}']/../../resource"
any_resource_xpath="//bundle[@id='${NAME}']//resource" any_resource_xpath="//bundle[@id='${NAME}']//resource"
replicas_xpath="//bundle[@id='${BUNDLE_NAME}']/*[boolean(@image) and boolean(@replicas)]" replicas_xpath="//bundle[@id='${BUNDLE_NAME}']/*[boolean(@image) and boolean(@replicas)]"
fi fi
bundle_def_xpath="//bundle[@id='${BUNDLE_NAME}']/*[boolean(@image) and boolean(@replicas)]" bundle_def_xpath="//bundle[@id='${BUNDLE_NAME}']/*[boolean(@image) and boolean(@replicas)]"
@ -244,11 +244,11 @@ if [ -n "$ROLE_LOCAL" ]; then
resource=$(crm_mon -r --as-xml | xmllint --xpath "${local_resource_xpath}" - 2>/dev/null) resource=$(crm_mon -r --as-xml | xmllint --xpath "${local_resource_xpath}" - 2>/dev/null)
role=$(echo "${resource}" | sed -ne 's/.*\Wrole="\([^"]*\)".*/\1/p') role=$(echo "${resource}" | sed -ne 's/.*\Wrole="\([^"]*\)".*/\1/p')
if [ "$(crm_resource --meta -r ${NAME} -g is-managed 2>/dev/null)" = "false" ]; then if [ "$(crm_resource --meta -r ${NAME} -g is-managed 2>/dev/null)" = "false" ]; then
log "${NAME} is unmanaged, will never reach target role. Bailing out" log "${NAME} is unmanaged, will never reach target role. Bailing out"
bailout=0 bailout=0
continue continue
elif [ "$(crm_resource --meta -r ${NAME} -g target-role 2>/dev/null)" = "Stopped" ]; then elif [ "$(crm_resource --meta -r ${NAME} -g target-role 2>/dev/null)" = "Stopped" ]; then
log "${NAME} is disabled, will never reach target role. Bailing out" log "${NAME} is disabled, will never reach target role. Bailing out"
bailout=0 bailout=0
continue continue
@ -256,7 +256,7 @@ if [ -n "$ROLE_LOCAL" ]; then
log "${NAME} is blocked, will never reach target role. Bailing out" log "${NAME} is blocked, will never reach target role. Bailing out"
bailout=0 bailout=0
continue continue
elif did_resource_failed_locally; then elif did_resource_failed_locally; then
log "${NAME} is in failed state, will never reach target role. Bailing out" log "${NAME} is in failed state, will never reach target role. Bailing out"
bailout=0 bailout=0
continue continue
@ -287,11 +287,11 @@ if [ $timeout -gt 0 ] && [ -n "$ROLE_ANYWHERE" ] && [ "$role" != "$ROLE_ANYWHERE
bailout=1 bailout=1
while [ $timeout -gt 0 ] && [ $bailout -ne 0 ] && [ $success -ne 0 ]; do while [ $timeout -gt 0 ] && [ $bailout -ne 0 ] && [ $success -ne 0 ]; do
resources=$(crm_mon -r --as-xml | xmllint --xpath "${any_resource_xpath}" - 2>/dev/null) resources=$(crm_mon -r --as-xml | xmllint --xpath "${any_resource_xpath}" - 2>/dev/null)
if [ "$(crm_resource --meta -r ${NAME} -g is-managed 2>/dev/null)" = "false" ]; then if [ "$(crm_resource --meta -r ${NAME} -g is-managed 2>/dev/null)" = "false" ]; then
log "${NAME} is unmanaged, will never reach target role. Bailing out" log "${NAME} is unmanaged, will never reach target role. Bailing out"
bailout=0 bailout=0
continue continue
elif [ "$(crm_resource --meta -r ${NAME} -g target-role 2>/dev/null)" = "Stopped" ]; then elif [ "$(crm_resource --meta -r ${NAME} -g target-role 2>/dev/null)" = "Stopped" ]; then
log "${NAME} is disabled, will never reach target role. Bailing out" log "${NAME} is disabled, will never reach target role. Bailing out"
bailout=0 bailout=0
continue continue
@ -299,7 +299,7 @@ if [ $timeout -gt 0 ] && [ -n "$ROLE_ANYWHERE" ] && [ "$role" != "$ROLE_ANYWHERE
log "${NAME} blocked, will never reach target role. Bailing out" log "${NAME} blocked, will never reach target role. Bailing out"
bailout=0 bailout=0
continue continue
elif did_resource_failed_globally; then elif did_resource_failed_globally; then
log "${NAME} is in failed state, will never reach target role. Bailing out" log "${NAME} is in failed state, will never reach target role. Bailing out"
bailout=0 bailout=0
continue continue