Check that ceph-mon service has started to get its version
Add an extra check to verify that ceph-mon service has started before trying to retrieve its version. An already existing function is being used, wait_for_daemon Since we now guarantee that we are using systemctl, we can use the is-active feature. If the service is running, the exit code will be 0. Also, change the command used to get the mon version. We can use the ceph version command provided by the new cli instead of using ceph daemon command which requires more privileges. Change-Id: I2d4f23721107c4b5cb1c09719c55424eecd0c880 Closes-Bug: #1872855
This commit is contained in:
1 changed files with 12 additions and 4 deletions
@@ -226,15 +226,23 @@ function is_ceph_enabled_for_service {
# and healthy.
function _get_ceph_version {
local ceph_version_str
local mon_started
if [[ 1ドル == 'cli' ]]; then
# ceph --version show CLI version
ceph_version_str=$(sudo ceph --version | cut -d ' ' -f 3 | \
cut -d '.' -f 1,2)
elif [[ 1ドル == 'mon' ]]; then
# TODO(frickler): Find a better way to make sure that ceph-mon has started
sleep 5
ceph_version_str=$(sudo ceph daemon mon.$(hostname) version | \
cut -d '"' -f 4 | cut -f 1,2 -d '.')
# ceph version show mon daemon version
mon_started=$(wait_for_daemon "sudo systemctl is-active --quiet ceph-mon@$(hostname)")
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
die $LINENO "Invalid argument. The get_ceph_version function needs \
an argument that can be 'cli' or 'mon'."
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.