From 968ef04324e9064fcecfe88bc5464ad9c2673a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Fri, 20 Oct 2017 15:15:38 +0200 Subject: [PATCH] osd: bring backward compatibility with old Jewel images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There was a huge resync from luminous to jewel in ceph-docker: https://github.com/ceph/ceph-docker/pull/797 This change brought a new handy function to discover partitions tight to an OSD. This function doesn't exist in the old image so the ceph-osd-run.sh script breaks when trying to deploy Jewel OSD with that old Jewel image version. Signed-off-by: Sébastien Han --- roles/ceph-osd/tasks/docker/start_docker_osd.yml | 8 ++++++++ roles/ceph-osd/templates/ceph-osd-run.sh.j2 | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/roles/ceph-osd/tasks/docker/start_docker_osd.yml b/roles/ceph-osd/tasks/docker/start_docker_osd.yml index fce8a7fbc..c038e9164 100644 --- a/roles/ceph-osd/tasks/docker/start_docker_osd.yml +++ b/roles/ceph-osd/tasks/docker/start_docker_osd.yml @@ -10,6 +10,14 @@ when: - ceph_docker_on_openstack +- name: test if the container image has the disk_list function + command: docker run --entrypoint=stat {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} disk_list.sh + changed_when: false + failed_when: false + register: disk_list + when: + - ceph_release_num[ceph_release] < ceph_release_num.kraken + - name: generate ceph osd docker run script become: true template: diff --git a/roles/ceph-osd/templates/ceph-osd-run.sh.j2 b/roles/ceph-osd/templates/ceph-osd-run.sh.j2 index 0ff07ede8..9dc67143f 100644 --- a/roles/ceph-osd/templates/ceph-osd-run.sh.j2 +++ b/roles/ceph-osd/templates/ceph-osd-run.sh.j2 @@ -5,12 +5,23 @@ ############# # FUNCTIONS # ############# - - +{% if disk_list.get("rc", 1) == 0 -%} function expose_partitions () { DOCKER_ENV=$(docker run --name expose_partitions_${1} --privileged=true -v /dev/:/dev/ -v /etc/ceph:/etc/ceph -e CLUSTER={{ cluster }} -e OSD_DEVICE=/dev/${1} {{ ceph_docker_registry }}/{{ ceph_docker_image }}:{{ ceph_docker_image_tag }} disk_list) docker rm -f expose_partitions_${1} } +{% else -%} +# NOTE(leseb): maintains backwards compatibility with old ceph-docker Jewel images +# Jewel images prior to https://github.com/ceph/ceph-docker/pull/797 +REGEX="[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}" +function expose_partitions { + local partition + if docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} |& grep -Eo "$partition is GPT partition"; then + part=$(docker logs ceph-osd-prepare-{{ ansible_hostname }}-devdev${1} |& grep "$partition is GPT partition" | grep -Eo /dev/disk/by-partuuid/${REGEX} | uniq) + DOCKER_ENV="$DOCKER_ENV -e OSD_JOURNAL=$part" + fi +} +{% endif -%} expose_partitions "$1"