puppet-ceph: add support for mpath device

The device node in /dev/ and device path in /dev/disk/by-path
can not be used directly for mpath devices, use /dev/mapper/mpathN
and /dev/disk/by-id/dm-uuid-mpath-<WWID> instead and change the
scripts in osd.pp accordingly.

Test Plan:

PASS: AIO-SX with Ceph, 1 osd
PASS: AIO-SX with Ceph, 2 osd
PASS: AIO-SX with Ceph, 4 osd

PASS: Installed and unlocked AIO-SX Debian

Story: 2010046
Task: 45426

Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
Signed-off-by: Thiago Miranda <ThiagoOliveira.Miranda@windriver.com>
Change-Id: Id1d3d2e72931f0518340214f2b049466db1fb012
This commit is contained in:
Joao Pedro Alexandroni 2022-05-24 13:54:06 -03:00
parent 53da7ef285
commit 39199deb60
3 changed files with 168 additions and 0 deletions

View File

@ -0,0 +1,34 @@
From c7d728032c05f1459e3d610f5c7762d0dab76c58 Mon Sep 17 00:00:00 2001
From: Joao Pedro Alexandroni
<JoaoPedroAlexandroni.CordovadeSouza@windriver.com>
Date: Mon, 23 May 2022 16:50:58 -0300
Subject: [PATCH] osd add support for mpath
Signed-off-by: Joao Pedro Alexandroni <JoaoPedroAlexandroni.CordovadeSouza@windriver.com>
---
SPECS/puppet-ceph.spec | 2 ++
1 file changed, 2 insertions(+)
diff --git a/SPECS/puppet-ceph.spec b/SPECS/puppet-ceph.spec
index 3b9adcf..6c2be4b 100644
--- a/SPECS/puppet-ceph.spec
+++ b/SPECS/puppet-ceph.spec
@@ -18,6 +18,7 @@ Patch0007: 0007-Add-StarlingX-specific-restart-command-for-Ceph-moni.patch
Patch0008: 0008-ceph-mimic-prepare-activate-osd.patch
Patch0009: 0009-fix-ceph-osd-disk-partition-for-nvme-disks.patch
Patch0010: 0010-wipe-unprepared-disks.patch
+Patch0011: 0011-osd-add-support-for-mpath.patch
BuildArch: noarch
@@ -43,6 +44,7 @@ Community Developed Ceph Module
%patch0008 -p1
%patch0009 -p1
%patch0010 -p1
+%patch0011 -p1
find . -type f -name ".*" -exec rm {} +
find . -size 0 -exec rm {} +
--
2.17.1

View File

@ -8,3 +8,4 @@
0008-ceph-mimic-prepare-activate-osd.patch
0009-fix-ceph-osd-disk-partition-for-nvme-disks.patch
0010-wipe-unprepared-disks.patch
0011-osd-add-support-for-mpath.patch

View File

@ -0,0 +1,133 @@
From 30fa8f9a648a8ed00adf7a1015199e63f2b20fd5 Mon Sep 17 00:00:00 2001
From: Joao Pedro Alexandroni
<JoaoPedroAlexandroni.CordovadeSouza@windriver.com>
Date: Mon, 23 May 2022 16:39:14 -0300
Subject: [PATCH] osd add support for mpath
The device node in /dev/ and device path in /dev/disk/by-path
can not be used directly for mpath devices, use /dev/mapper/mpathN
and /dev/disk/by-id/dm-uuid-mpath-<WWID> instead and change the
scripts in osd.pp accordingly.
Signed-off-by: Joao Pedro Alexandroni <JoaoPedroAlexandroni.CordovadeSouza@windriver.com>
---
manifests/osd.pp | 55 ++++++++++++++++++++++++++++++++++++++++--------
1 file changed, 46 insertions(+), 9 deletions(-)
diff --git a/manifests/osd.pp b/manifests/osd.pp
index df7489f..f4d566c 100644
--- a/manifests/osd.pp
+++ b/manifests/osd.pp
@@ -138,8 +138,14 @@ 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
-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})
+if [[ ${data} == *mpath* ]]; then
+ disk=$(find -L /dev/mapper/ -samefile ${data})
+ journal_part=${journal}
+else
+ disk=$(readlink -f ${data})
+ test -z ${journal} || journal_part=$(readlink -f ${journal})
+fi
+ceph-disk --verbose --log-stdout prepare --filestore ${cluster_uuid_option} ${uuid_option} ${osdid_option} --fs-type xfs --zap-disk \${disk} \${journal_part}
mkdir -p /var/lib/ceph/osd/ceph-${osdid}
ceph auth del osd.${osdid} || true
part=\${disk}
@@ -148,7 +154,11 @@ if [[ \$part == *nvme* ]]; then
else
part=\${part}1
fi
-mount $(readlink -f \${part}) /var/lib/ceph/osd/ceph-${osdid}
+if [[ ${data} == *mpath* ]]; then
+ mount \${part} /var/lib/ceph/osd/ceph-${osdid}
+else
+ mount $(readlink -f \${part}) /var/lib/ceph/osd/ceph-${osdid}
+fi
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}
@@ -158,7 +168,14 @@ umount /var/lib/ceph/osd/ceph-${osdid}
# 2. The uuid for the OSD we are configuring matches the uuid for the
# OSD on the disk. We don't want to attempt to re-use an OSD that
# had previously been deleted.
- unless => "/usr/sbin/ceph-disk list | grep -v 'unknown cluster' | grep \" *$(readlink -f ${data}).*ceph data\" | grep -v unprepared | grep 'osd uuid ${uuid}'",
+ unless => "/bin/true # comment to satisfy puppet syntax requirements
+set -ex
+if [[ ${data} == *mpath* ]]; then
+ ceph-disk list --format json ${data}| grep '\"type\": \"data\"'| grep '\"uuid\": \"${uuid}\"'
+else
+ ceph-disk list | grep -v 'unknown cluster' | grep \" *$(readlink -f ${data}).*ceph data\" | grep -v unprepared | grep 'osd uuid ${uuid}'
+fi
+",
logoutput => true,
timeout => $exec_timeout,
@@ -182,7 +199,11 @@ restorecon -R $(readlink -f ${data})
exec { $ceph_activate:
command => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
-disk=$(readlink -f ${data})
+if [[ ${data} == *mpath* ]]; then
+ disk=$(find -L /dev/mapper/ -samefile ${data})
+else
+ disk=$(readlink -f ${data})
+fi
if ! test -b \$disk ; then
echo \$disk | egrep -e '^/dev' -q -v
mkdir -p \$disk
@@ -217,7 +238,11 @@ ls -ld /var/lib/ceph/osd/${cluster_name}-* | grep \" $(readlink -f ${data})\$\"
exec { "remove-osd-${name}":
command => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
-disk=$(readlink -f ${data})
+if [[ ${data} == *mpath* ]]; then
+ disk=$(find -L /dev/mapper/ -samefile ${data})
+else
+ disk=$(readlink -f ${data})
+fi
part=\${disk}
if [[ \${part} == *nvme* ]]; then
part=\${part}p1
@@ -225,7 +250,11 @@ else
part=\${part}1
fi
if [ -z \"\$id\" ] ; then
- id=$(ceph-disk list | sed -nEe \"s:^ *\${part}? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\")
+ if [[ ${data} == *mpath* ]]; then
+ id=$(ceph-disk list --format json ${data} | sed -n 's/.*\"whoami\": \"\\([0-9]\\+\\)\".*/\\1/p')
+ else
+ id=$(ceph-disk list | sed -nEe \"s:^ *\${part}? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\")
+ fi
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)
@@ -244,7 +273,11 @@ fi
",
unless => "/bin/true # comment to satisfy puppet syntax requirements
set -ex
-disk=$(readlink -f ${data})
+if [[ ${data} == *mpath* ]]; then
+ disk=$(find -L /dev/mapper/ -samefile ${data})
+else
+ disk=$(readlink -f ${data})
+fi
part=${disk}
if [[ \$part == *nvme* ]]; then
part=\${part}p1
@@ -252,7 +285,11 @@ else
part=\${part}1
fi
if [ -z \"\$id\" ] ; then
- id=$(ceph-disk list | sed -nEe \"s:^ *\${part}? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\")
+ if [[ ${data} == *mpath* ]]; then
+ id=$(ceph-disk list --format json ${data} | sed -n 's/.*\"whoami\": \"\\([0-9]\\+\\)\".*/\\1/p')
+ else
+ id=$(ceph-disk list | sed -nEe \"s:^ *\${part}? .*(ceph data|mounted on).*osd\\.([0-9]+).*:\\2:p\")
+ fi
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)
--
2.17.1