From 4ba36e9593b4d00fbd8130eaf87b86c9442ac23c Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Han?= Date: Mon, 18 Dec 2017 16:43:37 +0100 Subject: [PATCH] osd: best effort if no device is found during activation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We have a scenario when we switch from non-container to containers. This means we don't know anything about the ceph partitions associated to an OSD. Normally in a containerized context we have files containing the preparation sequence. From these files we can get the capabilities of each OSD. As a last resort we use a ceph-disk call inside a dummy bash container to discover the ceph journal on the current osd. Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1525612 Signed-off-by: Sébastien Han (cherry picked from commit bbc79765f3e8b93b707b0f25f94e975c1bd85c66) Signed-off-by: Sébastien Han --- roles/ceph-osd/templates/ceph-osd-run.sh.j2 | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/roles/ceph-osd/templates/ceph-osd-run.sh.j2 b/roles/ceph-osd/templates/ceph-osd-run.sh.j2 index 6651eb6b0..7778896eb 100644 --- a/roles/ceph-osd/templates/ceph-osd-run.sh.j2 +++ b/roles/ceph-osd/templates/ceph-osd-run.sh.j2 @@ -1,6 +1,7 @@ #!/bin/bash # {{ ansible_managed }} +DOCKER_ENV="" ############# # FUNCTIONS # @@ -27,11 +28,23 @@ function expose_partitions { fi if [[ -f {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-devdev${1}.log ]]; then part=$(grep "Journal is GPT partition" {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-devdev${1}.log | grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq) - DOCKER_ENV="$DOCKER_ENV -e OSD_JOURNAL=$part" + DOCKER_ENV="-e OSD_JOURNAL=$part" fi if [[ -f {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-${1}.log ]]; then part=$(grep "Journal is GPT partition" {{ ceph_osd_docker_run_script_path }}/ceph-osd-prepare-{{ ansible_hostname }}-${1}.log | grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq) - DOCKER_ENV="$DOCKER_ENV -e OSD_JOURNAL=$part" + DOCKER_ENV="-e OSD_JOURNAL=$part" + fi + if [[ -z $DOCKER_ENV ]]; then + # NOTE(leseb): if we arrive here this probably means we just switched from non-containers to containers. + # This is tricky as we don't have any info on the type of OSD, this is 'only' a problem for non-collocated scenarios + # We can't assume that the 'ceph' is still present so calling Docker exec instead + part=$(docker run --privileged=true -v /dev:/dev --entrypoint /usr/sbin/ceph-disk {{ ceph_docker_registry}}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} list /dev/${1} | awk '/journal / {print $1}') + DOCKER_ENV="-e OSD_JOURNAL=$part" + fi + # if empty, the previous command didn't find anything so we fail + if [[ -z $DOCKER_ENV ]]; then + echo "ERROR: could not discover ceph partitions" + exit 1 fi } {% endif -%} -- 2.39.5