From 7451d6ea295ca16b6ba3bd2e7ed2412d18f2bec4 Mon Sep 17 00:00:00 2001 From: John Fulton Date: Fri, 17 Feb 2017 23:33:46 +0000 Subject: [PATCH] Fail deployment if non-existent block devices are passed for OSDs If a user passes a block device, e.g. /dev/sdx, that doesn't actually exist, then the user made a mistake and the deployment should fail. Without this change if /dev/sdx doesn't exist, then a directory is created called /dev/sdx and set up as a directory-backed OSD. This patch adds a check to fail the deployment if the requested OSD is a directory with a name starting with /dev. Change-Id: I5f03fc332b8df3914dc8609a203eb38693cb87a7 Closes-Bug: 1665697 --- manifests/osd.pp | 2 ++ .../osd-check-non-existent-block-device-6f827dba142a3aa5.yaml | 3 +++ spec/defines/ceph_osd_spec.rb | 4 ++++ 3 files changed, 9 insertions(+) create mode 100644 releasenotes/notes/osd-check-non-existent-block-device-6f827dba142a3aa5.yaml diff --git a/manifests/osd.pp b/manifests/osd.pp index 41114e9f..8f2c5d5a 100644 --- a/manifests/osd.pp +++ b/manifests/osd.pp @@ -160,6 +160,7 @@ test -z \$(ceph-disk list ${data} | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a command => "/bin/true # comment to satisfy puppet syntax requirements set -ex if ! test -b ${data} ; then + echo ${data} | egrep -e '^/dev' -q -v mkdir -p ${data} if getent passwd ceph >/dev/null 2>&1; then chown -h ceph:ceph ${data} @@ -192,6 +193,7 @@ ceph-disk list | grep -E ' *${data}1? .*ceph data, (prepared|active)' || command => "/bin/true # comment to satisfy puppet syntax requirements set -ex if ! test -b ${data} ; then + echo ${data} | egrep -e '^/dev' -q -v mkdir -p ${data} if getent passwd ceph >/dev/null 2>&1; then chown -h ceph:ceph ${data} diff --git a/releasenotes/notes/osd-check-non-existent-block-device-6f827dba142a3aa5.yaml b/releasenotes/notes/osd-check-non-existent-block-device-6f827dba142a3aa5.yaml new file mode 100644 index 00000000..eb0d30b3 --- /dev/null +++ b/releasenotes/notes/osd-check-non-existent-block-device-6f827dba142a3aa5.yaml @@ -0,0 +1,3 @@ +--- +fixes: + - Bug 1665697 non-existent block device should make deploy fail, not create directory whose name starts with /dev \ No newline at end of file diff --git a/spec/defines/ceph_osd_spec.rb b/spec/defines/ceph_osd_spec.rb index b41ba79b..e8876e22 100644 --- a/spec/defines/ceph_osd_spec.rb +++ b/spec/defines/ceph_osd_spec.rb @@ -60,6 +60,7 @@ test -f /usr/lib/udev/rules.d/95-ceph-osd.rules && test \$DISABLE_UDEV -eq 1 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex if ! test -b /srv ; then + echo /srv | egrep -e '^/dev' -q -v mkdir -p /srv if getent passwd ceph >/dev/null 2>&1; then chown -h ceph:ceph /srv @@ -79,6 +80,7 @@ ceph-disk list | grep -E ' */srv1? .*ceph data, (prepared|active)' || 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex if ! test -b /srv ; then + echo /srv | egrep -e '^/dev' -q -v mkdir -p /srv if getent passwd ceph >/dev/null 2>&1; then chown -h ceph:ceph /srv @@ -170,6 +172,7 @@ test -z \$(ceph-disk list /srv/data | egrep -o '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0- 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex if ! test -b /srv/data ; then + echo /srv/data | egrep -e '^/dev' -q -v mkdir -p /srv/data if getent passwd ceph >/dev/null 2>&1; then chown -h ceph:ceph /srv/data @@ -189,6 +192,7 @@ ceph-disk list | grep -E ' */srv/data1? .*ceph data, (prepared|active)' || 'command' => "/bin/true # comment to satisfy puppet syntax requirements set -ex if ! test -b /srv/data ; then + echo /srv/data | egrep -e '^/dev' -q -v mkdir -p /srv/data if getent passwd ceph >/dev/null 2>&1; then chown -h ceph:ceph /srv/data