mirror of
https://github.com/ceph/ceph
synced 2025-01-31 07:22:56 +00:00
qa/workunits/ceph-helpers: add wait_for_quorum()
Takes optional timeout and desired quorum size Signed-off-by: Joao Eduardo Luis <joao@suse.de>
This commit is contained in:
parent
11c4946b63
commit
3cabcb7d51
@ -710,6 +710,42 @@ function test_get_osds() {
|
||||
|
||||
#######################################################################
|
||||
|
||||
##
|
||||
# Wait for the monitor to form quorum (optionally, of size N)
|
||||
#
|
||||
# @param timeout duration (lower-bound) to wait for quorum to be formed
|
||||
# @param quorumsize size of quorum to wait for
|
||||
# @return 0 on success, 1 on error
|
||||
#
|
||||
function wait_for_quorum() {
|
||||
local timeout=$1
|
||||
local quorumsize=$2
|
||||
|
||||
if [[ -z "$timeout" ]]; then
|
||||
timeout=300
|
||||
fi
|
||||
|
||||
if [[ -z "$quorumsize" ]]; then
|
||||
timeout $timeout ceph mon_status --format=json >&/dev/null || return 1
|
||||
return 0
|
||||
fi
|
||||
|
||||
no_quorum=1
|
||||
wait_until=$((`date +%s` + $timeout))
|
||||
while [[ $(date +%s) -lt $wait_until ]]; do
|
||||
jqfilter='.quorum | length == '$quorumsize
|
||||
jqinput="$(timeout $timeout ceph mon_status --format=json 2>/dev/null)"
|
||||
res=$(echo $jqinput | jq "$jqfilter")
|
||||
if [[ "$res" == "true" ]]; then
|
||||
no_quorum=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
return $no_quorum
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
|
||||
##
|
||||
# Return the PG of supporting the **objectname** stored in
|
||||
# **poolname**, as reported by ceph osd map.
|
||||
|
Loading…
Reference in New Issue
Block a user