Skip to content

Commit

Permalink
osd_volume_activate: manage ceph-disk based OSD
Browse files Browse the repository at this point in the history
After upgrading to nautilus, the OSD deployed by ceph-disk needs to be
manage by ceph-volume with the simple subcommand.
This was part of the osd_ceph_disk_activate entrypoint but there's no
need to have a separate entrypoint because at the end we are using the
same command : ceph-volume.

Signed-off-by: Dimitri Savineau <dsavinea@redhat.com>
(cherry picked from commit d467a30)
  • Loading branch information
dsavineau committed Jun 18, 2020
1 parent 71f6e23 commit 760f5e2
Showing 1 changed file with 39 additions and 7 deletions.
46 changes: 39 additions & 7 deletions src/daemon/osd_scenarios/osd_volume_activate.sh
@@ -1,19 +1,36 @@
#!/bin/bash
set -e

function osd_volume_activate {
: "${OSD_ID:?Give me an OSD ID to activate, eg: -e OSD_ID=0}"
function osd_volume_simple {
# Find the devices used by ceph-disk
DEVICES=$(ceph-volume inventory --format json | python -c 'import sys, json; print(" ".join([d.get("path") for d in json.load(sys.stdin) if "Used by ceph-disk" in d.get("rejected_reasons")]))')

ulimit -Sn 1024
ulimit -Hn 4096
# Scan devices with ceph data partition
for device in ${DEVICES}; do
if parted --script "${device}" print | grep -qE '^ 1.*ceph data'; then
if [[ "${device}" =~ ^/dev/(cciss|nvme) ]]; then
device+="p"
fi
ceph-volume simple scan ${device}1 --force || true
fi
done

CEPH_VOLUME_LIST_JSON="$(ceph-volume lvm list --format json)"
# Find the OSD json file associated to the ID
OSD_JSON=$(grep -l "whoami\": ${OSD_ID}$" /etc/ceph/osd/*.json)
if [ -z "${OSD_JSON}" ]; then
log "OSD id ${OSD_ID} does not exist"
exit 1
fi

if ! echo "$CEPH_VOLUME_LIST_JSON" | python -c "import sys, json; print(json.load(sys.stdin)[\"$OSD_ID\"])" &> /dev/null; then
log "OSD id $OSD_ID does not exist"
# Activate the OSD
# The command can fail so if it does, let's output the ceph-volume logs
if ! ceph-volume simple activate --file ${OSD_JSON} --no-systemd; then
cat /var/log/ceph
exit 1
fi
}

function osd_volume_lvm {
# Find the OSD FSID from the OSD ID
OSD_FSID="$(echo "$CEPH_VOLUME_LIST_JSON" | python -c "import sys, json; print(json.load(sys.stdin)[\"$OSD_ID\"][0][\"tags\"][\"ceph.osd_fsid\"])")"

Expand All @@ -36,6 +53,21 @@ function osd_volume_activate {
cat /var/log/ceph
exit 1
fi
}

function osd_volume_activate {
: "${OSD_ID:?Give me an OSD ID to activate, eg: -e OSD_ID=0}"

ulimit -Sn 1024
ulimit -Hn 4096

CEPH_VOLUME_LIST_JSON="$(ceph-volume lvm list --format json)"

if echo "$CEPH_VOLUME_LIST_JSON" | python -c "import sys, json; print(json.load(sys.stdin)[\"$OSD_ID\"])" &> /dev/null; then
osd_volume_lvm
else
osd_volume_simple
fi

log "SUCCESS"
# This ensures all resources have been unmounted after the OSD has exited
Expand Down

0 comments on commit 760f5e2

Please sign in to comment.