Merge "Check that ceph-mon service has started to get its version"

This commit is contained in:
Zuul
2020-05-04 19:18:24 +00:00
committed by Gerrit Code Review

View File

@@ -226,15 +226,23 @@ function is_ceph_enabled_for_service {
# and healthy. # and healthy.
function _get_ceph_version { function _get_ceph_version {
local ceph_version_str local ceph_version_str
local mon_started
if [[ $1 == 'cli' ]]; then if [[ $1 == 'cli' ]]; then
# ceph --version show CLI version
ceph_version_str=$(sudo ceph --version | cut -d ' ' -f 3 | \ ceph_version_str=$(sudo ceph --version | cut -d ' ' -f 3 | \
cut -d '.' -f 1,2) cut -d '.' -f 1,2)
elif [[ $1 == 'mon' ]]; then elif [[ $1 == 'mon' ]]; then
# TODO(frickler): Find a better way to make sure that ceph-mon has started # ceph version show mon daemon version
sleep 5 mon_started=$(wait_for_daemon "sudo systemctl is-active --quiet ceph-mon@$(hostname)")
ceph_version_str=$(sudo ceph daemon mon.$(hostname) version | \
cut -d '"' -f 4 | cut -f 1,2 -d '.') if $mon_started; then
ceph_version_str=$(sudo ceph version | cut -d ' ' -f 3 | \
cut -f 1,2 -d '.')
else
die $LINENO "ceph-mon@${hostname} is not running and it's not possible to \
retrieve it's version"
fi
else else
die $LINENO "Invalid argument. The get_ceph_version function needs \ die $LINENO "Invalid argument. The get_ceph_version function needs \
an argument that can be 'cli' or 'mon'." an argument that can be 'cli' or 'mon'."