Skip to content

Commit

Permalink
Fix: wait until config has settled before starting services
Browse files Browse the repository at this point in the history
Ensure ceph.conf points to the correct run dir

Fixes: canonical#356

Signed-off-by: Peter Sabaini <[email protected]>
  • Loading branch information
sabaini committed Jun 5, 2024
1 parent 0b4cfdb commit 5cf61af
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 0 deletions.
20 changes: 20 additions & 0 deletions snapcraft/commands/common
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
wait_for_config() {

local confpath="${SNAP_DATA}/conf/ceph.conf"
local search_str="^run dir = ${SNAP_DATA}/run"
local max_attempts=300
local attempt=0

while [ $attempt -lt $max_attempts ]; do
if [ -f "${confpath}" ]; then
if grep -q "${search_str}" "${confpath}"; then
return 0
fi
fi
attempt=$((attempt + 1))
sleep 2
done

echo "No updated conf found in ${confpath}"
return 1
}
5 changes: 5 additions & 0 deletions snapcraft/commands/mds.start
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
#!/bin/sh

. "${SNAP}/commands/common"

wait_for_config

exec ceph-mds -f --cluster ceph --id "$(hostname)"
5 changes: 5 additions & 0 deletions snapcraft/commands/mgr.start
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
#!/bin/sh

. "${SNAP}/commands/common"

wait_for_config

exec ceph-mgr -f --cluster ceph --id "$(hostname)"
5 changes: 5 additions & 0 deletions snapcraft/commands/mon.start
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
#!/bin/sh

. "${SNAP}/commands/common"

wait_for_config

exec ceph-mon -f --cluster ceph --id "$(hostname)"
3 changes: 3 additions & 0 deletions snapcraft/commands/osd.start
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export SNAP_CURRENT="$(realpath "${SNAP_DATA}/..")/current"
echo $$ > "${SNAP_CURRENT}/run/ceph-osd.pid"
cd "${SNAP}"

. "${SNAP}/commands/common"

maybe_unlock() {
dev="${1:?missing}"
Expand Down Expand Up @@ -59,5 +60,7 @@ spawn() {
}
trap spawn HUP

wait_for_config

spawn
exit 0
1 change: 1 addition & 0 deletions snapcraft/commands/rados
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#!/bin/sh

exec "${SNAP}/bin/rados" "$@"
5 changes: 5 additions & 0 deletions snapcraft/commands/rgw.start
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh

. "${SNAP}/commands/common"

wait_for_config

conf="${SNAP_DATA}/conf/radosgw.conf"

if [ -n "${conf}" ] ; then
Expand Down

0 comments on commit 5cf61af

Please sign in to comment.