Skip to content

Commit 1761367

Browse files
gpocentekdsavineau
authored andcommitted
fix: delete temporary mount point
[file] disk_list.sh: delete the temporary folder created as a mount point for Ceph devices. Closes ceph#1473 Signed-off-by: Gauvain Pocentek <[email protected]>
1 parent 1408d99 commit 1761367

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/daemon/disk_list.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ set -e
66
# VARIABLES #
77
#############
88

9-
mkdir -p /var/lib/ceph/tmp/
10-
tmp_dir="$(mktemp --directory --tmpdir=/var/lib/ceph/tmp/)"
119
DOCKER_ENV=""
1210

1311

@@ -26,21 +24,25 @@ function mandatory_checks () {
2624
}
2725

2826
function mount_ceph_data () {
27+
local mount_point="$1"
2928
if is_dmcrypt; then
30-
mount /dev/mapper/"${data_uuid}" "$tmp_dir"
29+
mount /dev/mapper/"${data_uuid}" "$mount_point"
3130
else
3231
data_part=$(dev_part "${OSD_DEVICE}" 1)
33-
mount /dev/disk/by-partuuid/"$(blkid -t PARTLABEL="ceph data" -s PARTUUID -o value ${data_part})" "$tmp_dir"
32+
mount /dev/disk/by-partuuid/"$(blkid -t PARTLABEL="ceph data" -s PARTUUID -o value ${data_part})" "$mount_point"
3433
fi
3534
}
3635

3736
function umount_ceph_data () {
38-
umount "$tmp_dir"
37+
local mount_point="$1"
38+
umount "$mount_point"
3939
}
4040

4141
function get_docker_env () {
42-
mount_ceph_data
43-
cd "$tmp_dir" || return
42+
mkdir -p /var/lib/ceph/tmp/
43+
local mount_point="$(mktemp --directory --tmpdir=/var/lib/ceph/tmp/)"
44+
mount_ceph_data "$mount_point"
45+
cd "$mount_point" || return
4446
if [[ -n ${1} ]]; then
4547
if [[ "${1}" == "whoami" ]]; then
4648
if is_dmcrypt; then
@@ -88,7 +90,8 @@ function get_docker_env () {
8890
fi
8991

9092
cd || return
91-
umount_ceph_data
93+
umount_ceph_data "$mount_point"
94+
rmdir "$mount_point"
9295
}
9396

9497
function start_disk_list () {

0 commit comments

Comments
 (0)