Allow setting explicit osd type as well as wal and db locations.

Since the luminous release bluestore has become the default.
ceph-disk silently ignores the journal specification and it's not
possible to create filestore backed OSDs.

Change-Id: Ie5a19d347bdcb162a2aa3607425478062d4f004d
This commit is contained in:
Dan Williams 2018-12-15 17:30:06 +00:00
parent 436437acda
commit c6292183b5
2 changed files with 133 additions and 10 deletions

View File

@ -31,10 +31,22 @@
# If set to absent, it will stop the OSD service and remove
# the associated data directory.
#
# [*journal*] The OSD journal path.
# [*journal*] The OSD filestore journal path.
# Optional. Defaults to co-locating the journal with the data
# defined by *title*.
#
# [*bluestore_wal*] The OSD bluestore WAL path.
# Optional. Defaults to co-locating the WAL with the data
# defined by *title*.
#
# [*bluestore_db*] The OSD bluestore WAL path.
# Optional. Defaults to co-locating the DB with the data
# defined by *title*.
#
# [*store_type*] The OSD backing store type.
# Optional. Defaults undef and will follow the ceph version default.
# should be either filestore or bluestore.
#
# [*cluster*] The ceph cluster
# Optional. Same default as ceph.
#
@ -52,6 +64,9 @@ define ceph::osd (
$ensure = present,
$journal = "''",
$cluster = undef,
$bluestore_wal = undef,
$bluestore_db = undef,
$store_type = undef,
$exec_timeout = $::ceph::params::exec_timeout,
$selinux_file_context = 'ceph_var_lib_t',
$fsid = $::ceph::profile::params::fsid,
@ -68,6 +83,23 @@ define ceph::osd (
}
$cluster_option = "--cluster ${cluster_name}"
if $store_type {
$osd_type = "--${store_type}"
}
if ($bluestore_wal) or ($bluestore_db) {
if $bluestore_wal {
$wal_opts = "--block-wal $(readlink -f ${bluestore_wal})"
}
if $bluestore_db {
$block_opts = "--block-db $(readlink -f ${bluestore_db})"
}
$journal_opts = "${wal_opts} ${block_opts}"
} else {
$journal_opts = "$(readlink -f ${journal})"
}
if $ensure == present {
$ceph_check_udev = "ceph-osd-check-udev-${name}"
@ -130,7 +162,7 @@ if ! test -b \$disk ; then
chown -h ceph:ceph \$disk
fi
fi
ceph-disk prepare ${cluster_option} ${fsid_option} $(readlink -f ${data}) $(readlink -f ${journal})
ceph-disk prepare ${osd_type} ${cluster_option} ${fsid_option} $(readlink -f ${data}) ${journal_opts}
udevadm settle
",
unless => "/bin/true # comment to satisfy puppet syntax requirements

View File

@ -50,7 +50,7 @@ if ! test -b $disk ; then
chown -h ceph:ceph $disk
fi
fi
ceph-disk prepare --cluster ceph $(readlink -f /srv) $(readlink -f '')
ceph-disk prepare --cluster ceph $(readlink -f /srv) $(readlink -f '')
udevadm settle
",
'unless' => "/bin/true # comment to satisfy puppet syntax requirements
@ -89,16 +89,19 @@ ls -ld /var/lib/ceph/osd/ceph-* | grep \" $(readlink -f /srv)\$\"
) }
end
describe "with custom params" do
describe "with bluestore params" do
let :title do
'/srv/data'
end
let :params do
{
:cluster => 'testcluster',
:journal => '/srv/journal',
:fsid => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5',
:cluster => 'testcluster',
:journal => '/srv/journal',
:fsid => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5',
:store_type => 'bluestore',
:bluestore_wal => '/srv/wal',
:bluestore_db => '/srv/db',
}
end
@ -137,7 +140,95 @@ if ! test -b $disk ; then
chown -h ceph:ceph $disk
fi
fi
ceph-disk prepare --cluster testcluster --cluster-uuid f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 $(readlink -f /srv/data) $(readlink -f /srv/journal)
ceph-disk prepare --bluestore --cluster testcluster --cluster-uuid f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 $(readlink -f /srv/data) --block-wal $(readlink -f /srv/wal) --block-db $(readlink -f /srv/db)
udevadm settle
",
'unless' => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
disk=$(readlink -f /srv/data)
ceph-disk list | egrep \" *(${disk}1?|${disk}p1?) .*ceph data, (prepared|active)\" ||
{ test -f $disk/fsid && test -f $disk/ceph_fsid && test -f $disk/magic ;}
",
'logoutput' => true
) }
it { should contain_exec('ceph-osd-activate-/srv/data').with(
'command' => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
disk=$(readlink -f /srv/data)
if ! test -b $disk ; then
echo $disk | egrep -e '^/dev' -q -v
mkdir -p $disk
if getent passwd ceph >/dev/null 2>&1; then
chown -h ceph:ceph $disk
fi
fi
# activate happens via udev when using the entire device
if ! test -b \$disk && ! ( test -b \${disk}1 || test -b \${disk}p1 ); then
ceph-disk activate $disk || true
fi
if test -f /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && ( test -b ${disk}1 || test -b ${disk}p1 ); then
ceph-disk activate ${disk}1 || true
fi
",
'unless' => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
ceph-disk list | egrep \" *(\${disk}1?|\${disk}p1?) .*ceph data, active\" ||
ls -ld /var/lib/ceph/osd/testcluster-* | grep \" $(readlink -f /srv/data)\$\"
",
'logoutput' => true
) }
end
describe "with custom params" do
let :title do
'/srv/data'
end
let :params do
{
:cluster => 'testcluster',
:journal => '/srv/journal',
:fsid => 'f39ace04-f967-4c3d-9fd2-32af2d2d2cd5',
:store_type => 'filestore'
}
end
it { should contain_exec('ceph-osd-check-udev-/srv/data').with(
'command' => "/bin/true # comment to satisfy puppet syntax requirements
# Before Infernalis the udev rules race causing the activation to fail so we
# disable them. More at: http://www.spinics.net/lists/ceph-devel/msg28436.html
mv -f /usr/lib/udev/rules.d/95-ceph-osd.rules /usr/lib/udev/rules.d/95-ceph-osd.rules.disabled && udevadm control --reload || true
",
'onlyif' => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
DISABLE_UDEV=$(ceph --version | awk 'match(\$3, /[0-9]+\\.[0-9]+/) {if (substr(\$3, RSTART, RLENGTH) <= 0.94) {print 1} else { print 0 } }')
test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1
",
'logoutput' => true,
) }
it { should contain_exec('ceph-osd-check-fsid-mismatch-/srv/data').with(
'command' => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
test f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 = $(ceph-disk list $(readlink -f /srv/data) | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}')
",
'unless' => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
test -z $(ceph-disk list $(readlink -f /srv/data) | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}')
",
'logoutput' => true
) }
it { should contain_exec('ceph-osd-prepare-/srv/data').with(
'command' => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
disk=$(readlink -f /srv/data)
if ! test -b $disk ; then
echo $disk | egrep -e '^/dev' -q -v
mkdir -p $disk
if getent passwd ceph >/dev/null 2>&1; then
chown -h ceph:ceph $disk
fi
fi
ceph-disk prepare --filestore --cluster testcluster --cluster-uuid f39ace04-f967-4c3d-9fd2-32af2d2d2cd5 $(readlink -f /srv/data) $(readlink -f /srv/journal)
udevadm settle
",
'unless' => "/bin/true # comment to satisfy puppet syntax requirements
@ -206,7 +297,7 @@ if ! test -b $disk ; then
chown -h ceph:ceph $disk
fi
fi
ceph-disk prepare --cluster ceph $(readlink -f /dev/nvme0n1) $(readlink -f '')
ceph-disk prepare --cluster ceph $(readlink -f /dev/nvme0n1) $(readlink -f '')
udevadm settle
",
'unless' => "/bin/true # comment to satisfy puppet syntax requirements
@ -275,7 +366,7 @@ if ! test -b $disk ; then
chown -h ceph:ceph $disk
fi
fi
ceph-disk prepare --cluster ceph $(readlink -f /dev/cciss/c0d0) $(readlink -f '')
ceph-disk prepare --cluster ceph $(readlink -f /dev/cciss/c0d0) $(readlink -f '')
udevadm settle
",
'unless' => "/bin/true # comment to satisfy puppet syntax requirements