Skip to content

Commit

Permalink
csi-debug: command to check network conn b/w csi
Browse files Browse the repository at this point in the history
with new command `csi-debug test-connection` we can verify
the connection between csi-cephfs/rbd and ceph cluster.

Signed-off-by: subhamkrai <[email protected]>
  • Loading branch information
subhamkrai committed Nov 14, 2022
1 parent e9c483e commit f1f7f41
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions kubectl-rook-ceph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,42 @@ function run_dr_health() {
set -e
}

function run_debug_csi() {
[[ -z "${1:-""}" ]] && fail_error "Missing csi-debug subcommand"
subcommand="$1"
shift # remove the subcommand from the front of the arg list

case $subcommand in
test-connection)
run_test_connection "$@"
;;
*)
fail_error "'csi-debug' subcommand '$subcommand' does not exit"
;;
esac
}

function run_test_connection() {
end_of_command_parsing "$@" # end of command tree

info_msg "checking 'csi-cephfsplugin-provisioner' network connection"
cephfs_out="$(KUBECTL_NS_CLUSTER exec deploy/csi-cephfsplugin-provisioner -c csi-cephfsplugin -- curl "$(kubectl -n rook-ceph get svc -l app=rook-ceph-mon -o jsonpath='{.items[0].spec.clusterIP}')":3300 2>/dev/null | tr '\0' '\n')"
if [[ "$cephfs_out" =~ "ceph v2" ]]; then
info_msg "Network connection between cluster and csi-cephfs is: Connected"
else
error_msg "Network connection between cluster and csi-cephfs is: Not Connected"
fi
echo

info_msg "checking 'csi-rbdplugin-provisioner' network connection"
cephrbd_out="$(KUBECTL_NS_CLUSTER exec deploy/csi-rbdplugin-provisioner -c csi-rbdplugin -- curl "$(KUBECTL_NS_CLUSTER get svc -l app=rook-ceph-mon -o jsonpath='{.items[0].spec.clusterIP}')":3300 2>/dev/null | tr '\0' '\n')"
if [[ "$cephrbd_out" =~ "ceph v2" ]]; then
info_msg "Network connection between cluster and csi-rbd is: Connected"
else
error_msg "Network connection between cluster and csi-rbd is: Not Connected"
fi
}

####################################################################################################
# 'kubectl rook-ceph status' command
####################################################################################################
Expand Down Expand Up @@ -631,6 +667,9 @@ function run_main_command() {
dr)
run_dr_subcommands "$@"
;;
csi-debug)
run_debug_csi "$@"
;;
# status)
# run_status_command "$@"
# ;;
Expand Down

0 comments on commit f1f7f41

Please sign in to comment.