From 4e3301d3614bb9e9ee40d531fcd4421ccf5ea18b Mon Sep 17 00:00:00 2001 From: Dimitri Savineau Date: Fri, 26 Jun 2020 13:49:17 -0400 Subject: [PATCH] ceph-osd: exit gracefully when no data partition When using collocated or non-collocated osd_scenarios (ceph-disk) and trying to deterime the OSD_DEVICE from the OSD_ID passed to the systemd unit then we can be in a situation where the OSD hasn't been activated but the OSD ID exists. This means the data partition isn't in activate state and the ceph-disk list command won't show the OSD ID on the data partition. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1850377 Signed-off-by: Dimitri Savineau --- roles/ceph-osd/templates/ceph-osd-run.sh.j2 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/roles/ceph-osd/templates/ceph-osd-run.sh.j2 b/roles/ceph-osd/templates/ceph-osd-run.sh.j2 index 773259263..675f221be 100644 --- a/roles/ceph-osd/templates/ceph-osd-run.sh.j2 +++ b/roles/ceph-osd/templates/ceph-osd-run.sh.j2 @@ -17,6 +17,10 @@ function id_to_device () { {{ container_binary }} run --rm --net=host --ulimit nofile=1024:4096 --ipc=host --pid=host --privileged=true -v /etc/ceph:/etc/ceph:z -v /var/lib/ceph/:/var/lib/ceph/:z -v /dev:/dev -v /etc/localtime:/etc/localtime:ro -e DEBUG=verbose -e CLUSTER={{ cluster }} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} osd_ceph_disk_dmcrypt_data_map {% endif %} DATA_PART=$(docker run --rm --ulimit nofile=1024:4096 --privileged=true -v /dev/:/dev/ -v /etc/ceph:/etc/ceph:z --entrypoint ceph-disk {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} list | grep ", osd\.${1}," | awk '{ print $1 }') + if [ -z "${DATA_PART}" ]; then + echo "No data partition found for OSD ${i}" + exit 1 + fi if [[ "${DATA_PART}" =~ ^/dev/(cciss|nvme|loop) ]]; then OSD_DEVICE=${DATA_PART:0:-2} else