write_one_line(path, 'type', 'bluestore')
-#
-# Temporary workaround: if ceph-osd --mkfs does not
-# complete within 5 minutes, assume it is blocked
-# because of http://tracker.ceph.com/issues/13522
-# and retry a few times.
-#
-# Remove this function calls with command_check_call
-# when http://tracker.ceph.com/issues/13522 is fixed
-#
-def ceph_osd_mkfs(arguments):
- timeout = _get_command_executable(['timeout'])
- mkfs_ok = False
- error = 'unknown error'
- for delay in os.environ.get('CEPH_OSD_MKFS_DELAYS',
- '300 300 300 300 300').split():
- try:
- _check_output(timeout + [delay] + arguments)
- mkfs_ok = True
- break
- except subprocess.CalledProcessError as e:
- error = e.output
- if e.returncode == 124: # timeout fired, retry
- LOG.debug('%s timed out : %s (retry)'
- % (str(arguments), error))
- else:
- break
- if not mkfs_ok:
- raise Error('%s failed : %s' % (str(arguments), error))
-
-
def mkfs(
path,
cluster,
osd_type = read_one_line(path, 'type')
if osd_type == 'bluestore':
- ceph_osd_mkfs(
+ command_check_call(
[
'ceph-osd',
'--cluster', cluster,
],
)
elif osd_type == 'filestore':
- ceph_osd_mkfs(
+ command_check_call(
[
'ceph-osd',
'--cluster', cluster,
grep --quiet "keyring $dir/bootstrap-osd/ceph.keyring" $dir/test_keyring || return 1
}
-# http://tracker.ceph.com/issues/13522
-function ceph_osd_fail_once_fixture() {
- local dir=$1
- local command=ceph-osd
- local fpath=`readlink -f $(which $command)`
- [ "$fpath" = `readlink -f $CEPH_BIN/$command` ] || [ "$fpath" = `readlink -f $(pwd)/$command` ] || return 1
-
- cat > $dir/$command <<EOF
-#!/bin/bash
-if echo "\$@" | grep -e --mkfs && ! test -f $dir/used-$command ; then
- touch $dir/used-$command
- # sleep longer than the first CEPH_OSD_MKFS_DELAYS value (5) below
- sleep 600
-else
- exec $CEPH_BIN/$command "\$@"
-fi
-EOF
- chmod +x $dir/$command
-}
-
-function test_ceph_osd_mkfs() {
- local dir=$1
- ceph_osd_fail_once_fixture $dir || return 1
- CEPH_OSD_MKFS_DELAYS='5 300 300' use_path $dir test_activate_dir || return 1
- [ -f $dir/used-ceph-osd ] || return 1
-}
-
function test_crush_device_class() {
local dir=$1
shift
default_actions+="test_zap "
[ `uname` != FreeBSD ] && \
default_actions+="test_activate_dir_bluestore "
- default_actions+="test_ceph_osd_mkfs "
default_actions+="test_crush_device_class "
default_actions+="test_reuse_osd_id "
local actions=${@:-$default_actions}