From 2936d5d56892ee98b7c5613714f7e89545614123 Mon Sep 17 00:00:00 2001 From: Daniel Badea Date: Wed, 31 Oct 2018 19:34:14 +0000 Subject: [PATCH] ceph-disk prepare invalid data disk value ceph-disk prepare data OSD parameter contains a new line causing puppet manifest to fail: 1. $data = generate('/bin/bash','-c',"/bin/readlink -f ${name}") is expanded together with a new line in: exec { $ceph_prepare: command => "/usr/sbin/ceph-disk prepare ${cluster_option} ${cluster_uuid_option} ${uuid_option} --fs-type xfs --zap-disk ${data} ${journal}" just before ${journal} is expanded. Puppet reports: sh: line 1: : command not found when trying to run '' (default journal value). 2. 'readlink' should be called when running ceph-disk prepare command, not when the puppet resource is defined. Let exec's shell call readlink instead of using puppet's generate() . See also: https://github.com/openstack/puppet-ceph/commit/ff2b2e689846dd3d980c7c706c591e8cfb8f33a9 Added --verbose and --log-stdout options to log commands executed by 'ceph-disk prepare' and identify where it fails. Closes-Bug: 1800889 Change-Id: I6b71147706edb97d5a1e6579924d45b999efe98f Signed-off-by: Daniel Badea --- .../puppet-ceph-2.2.0/centos/build_srpm.data | 2 +- ...repare-invalid-data-disk-value-patch.patch | 32 +++++++++ .../centos/meta_patches/PATCH_ORDER | 1 + ...disk-prepare-invalid-data-disk-value.patch | 68 +++++++++++++++++++ 4 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/meta_patches/0006-add-ceph-disk-prepare-invalid-data-disk-value-patch.patch create mode 100644 config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/patches/0006-ceph-disk-prepare-invalid-data-disk-value.patch diff --git a/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/build_srpm.data b/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/build_srpm.data index 0eac83bbb..024e3e138 100644 --- a/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/build_srpm.data +++ b/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/build_srpm.data @@ -1 +1 @@ -TIS_PATCH_VER=4 +TIS_PATCH_VER=5 diff --git a/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/meta_patches/0006-add-ceph-disk-prepare-invalid-data-disk-value-patch.patch b/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/meta_patches/0006-add-ceph-disk-prepare-invalid-data-disk-value-patch.patch new file mode 100644 index 000000000..c22695168 --- /dev/null +++ b/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/meta_patches/0006-add-ceph-disk-prepare-invalid-data-disk-value-patch.patch @@ -0,0 +1,32 @@ +From a7400d67bc6c89ea0aa9a408f7f35689924c8a99 Mon Sep 17 00:00:00 2001 +From: Daniel Badea +Date: Wed, 31 Oct 2018 19:29:45 +0000 +Subject: [PATCH] add ceph-disk-prepare-invalid-data-disk-value patch + +--- + SPECS/puppet-ceph.spec | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/SPECS/puppet-ceph.spec b/SPECS/puppet-ceph.spec +index 78e4a1b..f4dc098 100644 +--- a/SPECS/puppet-ceph.spec ++++ b/SPECS/puppet-ceph.spec +@@ -15,6 +15,7 @@ Patch0002: 0002-Newton-rebase-fixes.patch + Patch0003: 0003-Ceph-Jewel-rebase.patch + Patch0004: 0004-US92424-Add-OSD-support-for-persistent-naming.patch + Patch0005: 0005-Remove-puppetlabs-apt-as-ceph-requirement.patch ++Patch0006: 0006-ceph-disk-prepare-invalid-data-disk-value.patch + + BuildArch: noarch + +@@ -35,6 +36,7 @@ Community Developed Ceph Module + %patch0003 -p1 + %patch0004 -p1 + %patch0005 -p1 ++%patch0006 -p1 + + find . -type f -name ".*" -exec rm {} + + find . -size 0 -exec rm {} + +-- +1.8.3.1 + diff --git a/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/meta_patches/PATCH_ORDER b/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/meta_patches/PATCH_ORDER index 4e3db139e..a2c4b1bfa 100644 --- a/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/meta_patches/PATCH_ORDER +++ b/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/meta_patches/PATCH_ORDER @@ -3,3 +3,4 @@ 0003-Ceph-Jewel-rebase.patch 0004-Add-OSD-support-for-persistent-naming.patch 0005-meta-patch-for-patch5.patch +0006-add-ceph-disk-prepare-invalid-data-disk-value-patch.patch diff --git a/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/patches/0006-ceph-disk-prepare-invalid-data-disk-value.patch b/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/patches/0006-ceph-disk-prepare-invalid-data-disk-value.patch new file mode 100644 index 000000000..08535e0e3 --- /dev/null +++ b/config/puppet-modules/openstack/puppet-ceph-2.2.0/centos/patches/0006-ceph-disk-prepare-invalid-data-disk-value.patch @@ -0,0 +1,68 @@ +From 90e9f692040a804f74bd32a8032a34b0f1e31ae9 Mon Sep 17 00:00:00 2001 +From: Daniel Badea +Date: Wed, 31 Oct 2018 16:28:45 +0000 +Subject: [PATCH] ceph-disk prepare invalid data disk value + +ceph-disk prepare data OSD parameter contains a new line causing +puppet manifest to fail: + +1. $data = generate('/bin/bash','-c',"/bin/readlink -f ${name}") + + is expanded together with a new line in: + + exec { $ceph_prepare: + command => "/usr/sbin/ceph-disk prepare ${cluster_option} + ${cluster_uuid_option} ${uuid_option} + --fs-type xfs --zap-disk ${data} ${journal}" + + just before ${journal} is expanded. Puppet reports: + + sh: line 1: : command not found + + when trying to run '' (default journal value). + +2. 'readlink' should be called when running ceph-disk prepare + command, not when the puppet resource is defined. Let + exec's shell call readlink instead of using puppet's + generate() . See also: + + https://github.com/openstack/puppet-ceph/commit/ff2b2e689846dd3d980c7c706c591e8cfb8f33a9 + +Added --verbose and --log-stdout options to log commands executed +by 'ceph-disk prepare' and identify where it fails. +--- + manifests/osd.pp | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/manifests/osd.pp b/manifests/osd.pp +index d9cf5b1..53709bb 100644 +--- a/manifests/osd.pp ++++ b/manifests/osd.pp +@@ -61,7 +61,7 @@ define ceph::osd ( + + include ::ceph::params + +- $data = generate('/bin/bash','-c',"/bin/readlink -f ${name}") ++ $data = $name + + if $cluster { + $cluster_name = $cluster +@@ -131,13 +131,13 @@ test -z $(ceph-disk list $(readlink -f ${data}) | egrep -o '[0-9a-f]{8}-([0-9a-f + # ceph-disk: prepare should be idempotent http://tracker.ceph.com/issues/7475 + exec { $ceph_prepare: + +- command => "/usr/sbin/ceph-disk prepare ${cluster_option} ${cluster_uuid_option} ${uuid_option} --fs-type xfs --zap-disk ${data} ${journal}", ++ command => "/usr/sbin/ceph-disk --verbose --log-stdout prepare ${cluster_option} ${cluster_uuid_option} ${uuid_option} --fs-type xfs --zap-disk $(readlink -f ${data}) $(readlink -f ${journal})", + # We don't want to erase the disk if: + # 1. There is already ceph data on the disk for our cluster AND + # 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 ' *${data}.*ceph data' | grep 'osd uuid ${uuid}'", ++ unless => "/usr/sbin/ceph-disk list | grep -v 'unknown cluster' | grep ' *$(readlink -f ${data}).*ceph data' | grep 'osd uuid ${uuid}'", + + logoutput => true, + timeout => $exec_timeout, +-- +1.8.3.1 +