From 66fb4a2b26ed409ac14290f25766205429876562 Mon Sep 17 00:00:00 2001 From: Vladimir Kozhukalov Date: Thu, 9 Mar 2023 20:18:45 +0300 Subject: [PATCH] Use free loop devices for ceph deployment This is for convenience when running deployment scripts manually. On ubuntu loop0 and loop1 could in use for snaps so we can find free loop devices before trying to use them. Change-Id: Iec54c0decd3a401c99f4770187d81f370bcee24c --- tools/deployment/multinode/030-ceph.sh | 6 ++++-- tools/deployment/osh-infra-logging-tls/020-ceph.sh | 6 ++++-- tools/deployment/osh-infra-logging/020-ceph.sh | 6 ++++-- tools/deployment/tenant-ceph/030-ceph.sh | 6 ++++-- tools/deployment/tenant-ceph/040-tenant-ceph.sh | 7 ++++--- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/tools/deployment/multinode/030-ceph.sh b/tools/deployment/multinode/030-ceph.sh index 07bbf6938..c340c20f6 100755 --- a/tools/deployment/multinode/030-ceph.sh +++ b/tools/deployment/multinode/030-ceph.sh @@ -15,8 +15,10 @@ set -xe # setup loopback devices for ceph -./tools/deployment/common/setup-ceph-loopback-device.sh --ceph-osd-data \ -${CEPH_OSD_DATA_DEVICE:=/dev/loop0} --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=/dev/loop1} +free_loop_devices=( $(ls -1 /dev/loop[0-7] | while read loopdev; do losetup | grep -q $loopdev || echo $loopdev; done) ) +./tools/deployment/common/setup-ceph-loopback-device.sh \ + --ceph-osd-data ${CEPH_OSD_DATA_DEVICE:=${free_loop_devices[0]}} \ + --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=${free_loop_devices[1]}} #NOTE: Lint and package chart make ceph-mon diff --git a/tools/deployment/osh-infra-logging-tls/020-ceph.sh b/tools/deployment/osh-infra-logging-tls/020-ceph.sh index 6d782a166..7044191ff 100755 --- a/tools/deployment/osh-infra-logging-tls/020-ceph.sh +++ b/tools/deployment/osh-infra-logging-tls/020-ceph.sh @@ -15,8 +15,10 @@ set -xe # setup loopback devices for ceph -./tools/deployment/common/setup-ceph-loopback-device.sh --ceph-osd-data \ -${CEPH_OSD_DATA_DEVICE:=/dev/loop0} --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=/dev/loop1} +free_loop_devices=( $(ls -1 /dev/loop[0-7] | while read loopdev; do losetup | grep -q $loopdev || echo $loopdev; done) ) +./tools/deployment/common/setup-ceph-loopback-device.sh \ + --ceph-osd-data ${CEPH_OSD_DATA_DEVICE:=${free_loop_devices[0]}} \ + --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=${free_loop_devices[1]}} #NOTE: Lint and package chart for CHART in ceph-mon ceph-osd ceph-client ceph-provisioners; do diff --git a/tools/deployment/osh-infra-logging/020-ceph.sh b/tools/deployment/osh-infra-logging/020-ceph.sh index 54caca757..4f22ccf70 100755 --- a/tools/deployment/osh-infra-logging/020-ceph.sh +++ b/tools/deployment/osh-infra-logging/020-ceph.sh @@ -15,8 +15,10 @@ set -xe # setup loopback devices for ceph -./tools/deployment/common/setup-ceph-loopback-device.sh --ceph-osd-data \ -${CEPH_OSD_DATA_DEVICE:=/dev/loop0} --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=/dev/loop1} +free_loop_devices=( $(ls -1 /dev/loop[0-7] | while read loopdev; do losetup | grep -q $loopdev || echo $loopdev; done) ) +./tools/deployment/common/setup-ceph-loopback-device.sh \ + --ceph-osd-data ${CEPH_OSD_DATA_DEVICE:=${free_loop_devices[0]}} \ + --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=${free_loop_devices[1]}} #NOTE: Lint and package chart for CHART in ceph-mon ceph-osd ceph-client ceph-provisioners; do diff --git a/tools/deployment/tenant-ceph/030-ceph.sh b/tools/deployment/tenant-ceph/030-ceph.sh index ccdced69a..8b5f9cb9c 100755 --- a/tools/deployment/tenant-ceph/030-ceph.sh +++ b/tools/deployment/tenant-ceph/030-ceph.sh @@ -15,8 +15,10 @@ set -xe # setup loopback devices for ceph -./tools/deployment/common/setup-ceph-loopback-device.sh --ceph-osd-data \ -${CEPH_OSD_DATA_DEVICE:=/dev/loop0} --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=/dev/loop1} +free_loop_devices=( $(ls -1 /dev/loop[0-7] | while read loopdev; do losetup | grep -q $loopdev || echo $loopdev; done) ) +./tools/deployment/common/setup-ceph-loopback-device.sh \ + --ceph-osd-data ${CEPH_OSD_DATA_DEVICE:=${free_loop_devices[0]}} \ + --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=${free_loop_devices[1]}} #NOTE: Deploy command [ -s /tmp/ceph-fs-uuid.txt ] || uuidgen > /tmp/ceph-fs-uuid.txt diff --git a/tools/deployment/tenant-ceph/040-tenant-ceph.sh b/tools/deployment/tenant-ceph/040-tenant-ceph.sh index 3ea85ef95..44bde6773 100755 --- a/tools/deployment/tenant-ceph/040-tenant-ceph.sh +++ b/tools/deployment/tenant-ceph/040-tenant-ceph.sh @@ -14,11 +14,12 @@ set -xe -: "${CEPH_OSD_DATA_DEVICE:=/dev/loop2}" -: "${CEPH_OSD_DB_WAL_DEVICE:=/dev/loop3}" # setup loopback devices for ceph +free_loop_devices=( $(ls -1 /dev/loop[0-7] | while read loopdev; do losetup | grep -q $loopdev || echo $loopdev; done) ) export CEPH_NAMESPACE="tenant-ceph" -./tools/deployment/common/setup-ceph-loopback-device.sh --ceph-osd-data ${CEPH_OSD_DATA_DEVICE} --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE} +./tools/deployment/common/setup-ceph-loopback-device.sh \ + --ceph-osd-data ${CEPH_OSD_DATA_DEVICE:=${free_loop_devices[0]}} \ + --ceph-osd-dbwal ${CEPH_OSD_DB_WAL_DEVICE:=${free_loop_devices[1]}} # setup loopback devices for ceph osds setup_loopback_devices $OSD_DATA_DEVICE $OSD_DB_WAL_DEVICE