2017-08-31 17:22:33 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
RETRIES="{{ handler_health_rgw_check_retries }}"
|
|
|
|
DELAY="{{ handler_health_rgw_check_delay }}"
|
|
|
|
RGW_NAME="{{ ansible_hostname }}"
|
2018-07-27 23:46:38 +08:00
|
|
|
RGW_PORT="{{ radosgw_frontend_port }}"
|
2017-09-28 00:22:15 +08:00
|
|
|
{% if containerized_deployment %}
|
|
|
|
DOCKER_EXEC="docker exec ceph-rgw-{{ ansible_hostname }}"
|
|
|
|
{% endif %}
|
2018-07-31 21:18:28 +08:00
|
|
|
# Backward compatibility
|
|
|
|
$DOCKER_EXEC test -S /var/run/ceph/{{ cluster }}-client.rgw.{{ ansible_fqdn }}.asok && SOCKET=/var/run/ceph/{{ cluster }}-client.rgw.{{ ansible_fqdn }}.asok
|
|
|
|
$DOCKER_EXEC test -S /var/run/ceph/{{ cluster }}-client.rgw.{{ ansible_hostname }}.asok && SOCKET=/var/run/ceph/{{ cluster }}-client.rgw.{{ ansible_hostname }}.asok
|
2018-10-03 22:09:33 +08:00
|
|
|
RGW_IP={{ hostvars[inventory_hostname]['_radosgw_address'] }}
|
2017-08-31 17:22:33 +08:00
|
|
|
|
|
|
|
check_for_curl_or_wget() {
|
2017-09-28 00:22:15 +08:00
|
|
|
if $DOCKER_EXEC command -v wget &>/dev/null; then
|
2017-08-31 17:22:33 +08:00
|
|
|
rgw_test_command="wget --quiet"
|
2017-09-28 00:22:15 +08:00
|
|
|
elif $DOCKER_EXEC command -v curl &>/dev/null; then
|
2017-08-31 17:22:33 +08:00
|
|
|
rgw_test_command="curl --fail --silent --output /dev/null"
|
|
|
|
else
|
|
|
|
echo "It seems that neither curl or wget are available on your system."
|
|
|
|
echo "Cannot test rgw connection."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
check_rest() {
|
|
|
|
check_for_curl_or_wget
|
|
|
|
while [ $RETRIES -ne 0 ]; do
|
|
|
|
test "$rgw_test_command http://$RGW_IP:$RGW_PORT" && exit 0
|
|
|
|
sleep $DELAY
|
|
|
|
let RETRIES=RETRIES-1
|
|
|
|
done
|
|
|
|
# If we reach this point, it means there is a problem with the connection to rgw
|
|
|
|
echo "Error connecting locally to Rados Gateway service: http://$rgw_listen"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# First, restart the daemon
|
|
|
|
systemctl restart ceph-radosgw@rgw.${RGW_NAME}
|
|
|
|
|
|
|
|
COUNT=10
|
|
|
|
# Wait and ensure the socket exists after restarting the daemon
|
|
|
|
while [ $COUNT -ne 0 ]; do
|
2017-09-28 00:22:15 +08:00
|
|
|
$DOCKER_EXEC test -S $SOCKET && check_rest
|
2017-09-15 03:38:11 +08:00
|
|
|
sleep $DELAY
|
2017-08-31 17:22:33 +08:00
|
|
|
let COUNT=COUNT-1
|
|
|
|
done
|
|
|
|
echo "Socket file ${SOCKET} could not be found, which means Rados Gateway is not running."
|
|
|
|
exit 1
|