From b0dd34d2d580c817f9ef6eb62927ba63bebe73c3 Mon Sep 17 00:00:00 2001 From: Daniel Badea Date: Thu, 25 Apr 2019 15:37:53 +0000 Subject: [PATCH] fix ceph osd disk partition for nvme disks --- manifests/osd.pp | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/manifests/osd.pp b/manifests/osd.pp index c51a445..5bd30c5 100644 --- a/manifests/osd.pp +++ b/manifests/osd.pp @@ -138,10 +138,17 @@ test -z $(ceph-disk list $(readlink -f ${data}) | egrep -o '[0-9a-f]{8}-([0-9a-f command => "/bin/true # comment to satisfy puppet syntax requirements set -ex -ceph-disk --verbose --log-stdout prepare --filestore ${cluster_uuid_option} ${uuid_option} ${osdid_option} --fs-type xfs --zap-disk $(readlink -f ${data}) $(readlink -f ${journal}) +disk=$(readlink -f ${data}) +ceph-disk --verbose --log-stdout prepare --filestore ${cluster_uuid_option} ${uuid_option} ${osdid_option} --fs-type xfs --zap-disk \${disk} $(readlink -f ${journal}) mkdir -p /var/lib/ceph/osd/ceph-${osdid} ceph auth del osd.${osdid} || true -mount $(readlink -f ${data})1 /var/lib/ceph/osd/ceph-${osdid} +part=\${disk} +if [[ \$part == *nvme* ]]; then + part=\${part}p1 +else + part=\${part}1 +fi +mount $(readlink -f \${part}) /var/lib/ceph/osd/ceph-${osdid} ceph-osd --id ${osdid} --mkfs --mkkey --mkjournal ceph auth add osd.${osdid} osd 'allow *' mon 'allow rwx' -i /var/lib/ceph/osd/ceph-${osdid}/keyring umount /var/lib/ceph/osd/ceph-${osdid} @@ -183,12 +190,17 @@ if ! test -b \$disk ; then chown -h ceph:ceph \$disk fi fi -# activate happens via udev when using the entire device +part=\${disk} +if [[ \${part} == *nvme* ]]; then + part=\${part}p1 +else + part=\${part}1 +fi if ! test -b \$disk || ! test -b \${disk}1 || ! test -b \${disk}p1 ; then - ceph-disk activate \${disk}1 || true + ceph-disk activate \${part} || true fi if test -f ${udev_rules_file}.disabled && ( test -b \${disk}1 || test -b \${disk}p1 ); then - ceph-disk activate \${disk}1 || true + ceph-disk activate \${part} || true fi ", unless => "/bin/true # comment to satisfy puppet syntax requirements @@ -206,8 +218,14 @@ ls -ld /var/lib/ceph/osd/${cluster_name}-* | grep \" $(readlink -f ${data})\$\" command => "/bin/true # comment to satisfy puppet syntax requirements set -ex disk=$(readlink -f ${data}) +part=\${disk} +if [[ \${part} == *nvme* ]]; then + part=\${part}p1 +else + part=\${part}1 +fi if [ -z \"\$id\" ] ; then - id=$(ceph-disk list | sed -nEe \"s:^ *\${disk}1? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\") + id=$(ceph-disk list | sed -nEe \"s:^ *\${part}? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\") fi if [ -z \"\$id\" ] ; then id=$(ls -ld /var/lib/ceph/osd/${cluster_name}-* | sed -nEe \"s:.*/${cluster_name}-([0-9]+) *-> *\${disk}\$:\\1:p\" || true) @@ -227,8 +245,14 @@ fi unless => "/bin/true # comment to satisfy puppet syntax requirements set -ex disk=$(readlink -f ${data}) +part=${disk} +if [[ \$part == *nvme* ]]; then + part=\${part}p1 +else + part=\${part}1 +fi if [ -z \"\$id\" ] ; then - id=$(ceph-disk list | sed -nEe \"s:^ *\${disk}1? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\") + id=$(ceph-disk list | sed -nEe \"s:^ *\${part}? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\") fi if [ -z \"\$id\" ] ; then id=$(ls -ld /var/lib/ceph/osd/${cluster_name}-* | sed -nEe \"s:.*/${cluster_name}-([0-9]+) *-> *\${disk}\$:\\1:p\" || true) -- 1.8.3.1