#!/bin/bash RETRIES="{{ handler_health_rgw_check_retries }}" DELAY="{{ handler_health_rgw_check_delay }}" RGW_NAME="{{ ansible_hostname }}" RGW_PORT="{{ radosgw_frontend_port }}" {% if containerized_deployment %} DOCKER_EXEC="docker exec ceph-rgw-{{ ansible_hostname }}" {% endif %} # 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 RGW_IP={{ hostvars[inventory_hostname]['_radosgw_address'] }} check_for_curl_or_wget() { if $DOCKER_EXEC command -v wget &>/dev/null; then rgw_test_command="wget --quiet" elif $DOCKER_EXEC command -v curl &>/dev/null; then 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 $DOCKER_EXEC test -S $SOCKET && check_rest sleep $DELAY let COUNT=COUNT-1 done echo "Socket file ${SOCKET} could not be found, which means Rados Gateway is not running." exit 1