Files
my-rook-config/pkg/operator/ceph/file/mds/livenessprobe.sh
T
parth-gr 2dd9b00ca3 mds: improve the mds liveness probe calls
Instead of checking the socket files for mds daemon,
check the mds daemon in fs maps

Closes: https://github.com/rook/rook/issues/12789

Signed-off-by: parth-gr <paarora@redhat.com>
2023-10-05 00:54:06 +05:30

29 lines
1.2 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 }}"
outp="$(ceph fs dump --mon-host="$ROOK_CEPH_MON_HOST" --mon-initial-members="$ROOK_CEPH_MON_INITIAL_MEMBERS" --keyring "$KEYRING" --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