osd: best effort if no device is found during activation

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 <seb@redhat.com>
pull/2283/head
Sébastien Han 2017-12-18 16:43:37 +01:00
parent 200785832f
commit bbc79765f3
1 changed files with 15 additions and 2 deletions

View File

@ -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 -%}