Files
my-rook-config/pkg/operator/ceph/file/mds/livenessprobe.sh
T
parth-gr 0999cf9b56 mds: fix mds liveness probe
mds liveness probe call ceph cmd with mons and keyring,
but ceph actually looks for the ceph keyring at default folder
first and then use the cmd line keyring path,
So to avoid that use ceph_args env variable to expose the keyring
folder path,
Workaround for https://tracker.ceph.com/issues/70167

closes: https://github.com/rook/rook/issues/15373

Signed-off-by: parth-gr <partharora1010@gmail.com>
2025-02-25 18:05:07 +05:30

31 lines
1.3 KiB
Bash

#!/usr/bin/env bash
# do not use 'set -e -u' etc. because it is important to only fail this probe when failure is certain
# spurious failures risk destabilizing ceph or the filesystem
MDS_ID="{{ .MdsId }}"
FILESYSTEM_NAME="{{ .FilesystemName }}"
KEYRING="{{ .Keyring }}"
CMD_TIMEOUT="{{ .CmdTimeout }}"
export CEPH_ARGS="--keyring $KEYRING" # workaround for https://tracker.ceph.com/issues/70167
outp="$(ceph fs dump --mon-host="$ROOK_CEPH_MON_HOST" --mon-initial-members="$ROOK_CEPH_MON_INITIAL_MEMBERS" --name="mds.$MDS_ID" --connect-timeout="$CMD_TIMEOUT" --format json)"
rc=$?
if [ $rc -ne 0 ]; then
echo "ceph MDS dump check failed with the following output:"
echo "$outp"
echo "passing probe to avoid restarting MDS. cannot determine if MDS is unhealthy. restarting MDS risks destabilizing ceph/filesystem, which is likely unreachable or in error state"
exit 0
fi
# get the active and standby MDS in the fs map
standbyMds=$(echo "$outp" | jq ".standbys | map(.name) | any(.[]; . == \"$MDS_ID\")")
activeMds=$(echo "$outp" | jq ".filesystems[] | select(.mdsmap.fs_name == \"$FILESYSTEM_NAME\") | .mdsmap.info | map(.name) | any(.[]; . == \"$MDS_ID\")")
if [[ $standbyMds == true || $activeMds == true ]]; then
echo "MDS ID present in MDS map, no need to re-start the container"
exit 0
fi
echo "Error: MDS ID not present in MDS map"
exit 1