@@ -705,11 +705,15 @@ run_mongo() {
705
705
local suffix=${4:- .svc.cluster.local}
706
706
local client_container=$( kubectl_bin get pods --selector=name=psmdb-client -o ' jsonpath={.items[].metadata.name}' )
707
707
local mongo_flag=" $5 "
708
- local replica_set=$( echo " $uri " | sed -r ' s/.*\-(rs[0-9]|cfg)(\.|-).*/\1/' )
709
-
710
- kubectl_bin exec ${client_container} -- \
711
- bash -c " printf '$command \n' | mongo $driver ://$uri$suffix /admin?ssl=false\&replicaSet=$replica_set $mongo_flag "
708
+ local replica_set=$( echo " $uri " | grep -oE ' \-(rs[0-9]|cfg)(\.|-)' | sed ' s/^.//;s/.$//' )
712
709
710
+ if [[ ${FUNCNAME[1]} == " collect_k8s_logs" ]]; then
711
+ kubectl exec ${client_container} -- \
712
+ bash -c " printf '$command \n' | mongo $driver ://$uri$suffix /admin?ssl=false\&replicaSet=$replica_set $mongo_flag "
713
+ else
714
+ kubectl_bin exec ${client_container} -- \
715
+ bash -c " printf '$command \n' | mongo $driver ://$uri$suffix /admin?ssl=false\&replicaSet=$replica_set $mongo_flag "
716
+ fi
713
717
}
714
718
715
719
run_mongo_tls () {
@@ -719,11 +723,15 @@ run_mongo_tls() {
719
723
local suffix=${4:- .svc.cluster.local}
720
724
local client_container=$( kubectl_bin get pods --selector=name=psmdb-client -o ' jsonpath={.items[].metadata.name}' )
721
725
local mongo_flag=" $5 "
722
- local replica_set=$( echo " $uri " | sed -r ' s/.*\-(rs[0-9]|cfg)(\.|-).*/\1/' )
723
-
724
- kubectl_bin exec ${client_container} -- \
725
- bash -c " printf '$command \n' | mongo $driver ://$uri$suffix /admin?replicaSet=$replica_set --tls --tlsCAFile /etc/mongodb-ssl/ca.crt --tlsCertificateKeyFile /tmp/tls.pem --tlsAllowInvalidHostnames $mongo_flag "
726
+ local replica_set=$( echo " $uri " | grep -oE ' \-(rs[0-9]|cfg)(\.|-)' | sed ' s/^.//;s/.$//' )
726
727
728
+ if [[ ${FUNCNAME[1]} == " collect_k8s_logs" ]]; then
729
+ kubectl exec ${client_container} -- \
730
+ bash -c " printf '$command \n' | mongo $driver ://$uri$suffix /admin?replicaSet=$replica_set --tls --tlsCAFile /etc/mongodb-ssl/ca.crt --tlsCertificateKeyFile /tmp/tls.pem --tlsAllowInvalidHostnames $mongo_flag "
731
+ else
732
+ kubectl_bin exec ${client_container} -- \
733
+ bash -c " printf '$command \n' | mongo $driver ://$uri$suffix /admin?replicaSet=$replica_set --tls --tlsCAFile /etc/mongodb-ssl/ca.crt --tlsCertificateKeyFile /tmp/tls.pem --tlsAllowInvalidHostnames $mongo_flag "
734
+ fi
727
735
}
728
736
729
737
run_mongos () {
0 commit comments