@@ -150,6 +150,12 @@ get_version(){
150150 fi
151151}
152152
153+ # Return the major version, for instance if version is 4.x.y, return 4.
154+ major_version () {
155+ local version=" $1 "
156+ echo " ${version%% .* } "
157+ }
158+
153159# Usage: compare_version VER_1 VER_2.
154160# Output: return -1 if VER_1 < VER_2, 0 if VER_1 == VER_2, and +1 if VER_1 > VER_2.
155161compare_version (){
@@ -926,7 +932,8 @@ get_pg_configmap(){
926932 local wd_version=${WD_VERSION:- $(get_version)}
927933 if [ $( compare_version " ${wd_version} " " 2.2.1" ) -le 0 ] ; then
928934 echo $( oc get ${OC_ARGS} configmap -l tenant=${TENANT_NAME} ,app.kubernetes.io/component=postgres-cxn -o jsonpath=" {.items[0].metadata.name}" )
929- elif [ $( compare_version " ${wd_version} " " 5.1.0" ) -lt 0 ] ; then
935+ elif { [ $( major_version " ${wd_version} " ) -eq 4 ] && [ $( compare_version " ${wd_version} " " 4.8.8" ) -lt 0 ]; } ||
936+ { [ $( major_version " ${wd_version} " ) -eq 5 ] && [ $( compare_version " ${wd_version} " " 5.1.0" ) -lt 0 ]; }; then
930937 echo $( oc get ${OC_ARGS} configmap -l tenant=${TENANT_NAME} ,app=cn-postgres -o jsonpath=" {.items[0].metadata.name}" )
931938 else
932939 echo $( oc get ${OC_ARGS} configmap -l tenant=${TENANT_NAME} ,app=cn-postgres16 -o jsonpath=" {.items[0].metadata.name}" )
@@ -937,7 +944,8 @@ get_pg_secret(){
937944 local wd_version=${WD_VERSION:- $(get_version)}
938945 if [ $( compare_version " ${wd_version} " " 2.2.1" ) -le 0 ] ; then
939946 echo $( oc ${OC_ARGS} get secret -l tenant=${TENANT_NAME} ,cr=${TENANT_NAME} -discovery-postgres -o jsonpath=" {.items[*].metadata.name}" )
940- elif [ $( compare_version " ${wd_version} " " 5.1.0" ) -lt 0 ] ; then
947+ elif { [ $( major_version " ${wd_version} " ) -eq 4 ] && [ $( compare_version " ${wd_version} " " 4.8.8" ) -lt 0 ]; } ||
948+ { [ $( major_version " ${wd_version} " ) -eq 5 ] && [ $( compare_version " ${wd_version} " " 5.1.0" ) -lt 0 ]; }; then
941949 echo $( oc ${OC_ARGS} get secret -l tenant=${TENANT_NAME} ,run=cn-postgres -o jsonpath=" {.items[*].metadata.name}" | tr ' [[:space:]]' ' \n' | grep " cn-postgres-wd" )
942950 else
943951 echo $( oc ${OC_ARGS} get secret -l tenant=${TENANT_NAME} ,run=cn-postgres16 -o jsonpath=" {.items[*].metadata.name}" | tr ' [[:space:]]' ' \n' | grep " cn-postgres16-wd" )
@@ -1128,7 +1136,8 @@ require_mt_mt_migration(){
11281136
11291137get_primary_pg_pod (){
11301138 local wd_version=${WD_VERSION:- $(get_version)}
1131- if [ $( compare_version " ${wd_version} " " 5.1.0" ) -ge 0 ] ; then
1139+ if { [ $( major_version " ${wd_version} " ) -eq 4 ] && [ $( compare_version " ${wd_version} " " 4.8.8" ) -ge 0 ]; } ||
1140+ { [ $( major_version " ${wd_version} " ) -eq 5 ] && [ $( compare_version " ${wd_version} " " 5.1.0" ) -ge 0 ]; }; then
11321141 echo " $( oc get pod ${OC_ARGS} -l " icpdsupport/podSelector=discovery-cn-postgres16,role=primary" -o jsonpath=' {.items[0].metadata.name}' ) "
11331142 elif [ $( compare_version " ${wd_version} " " 5.0.0" ) -ge 0 ] ; then
11341143 echo " $( oc get pod ${OC_ARGS} -l " icpdsupport/podSelector=discovery-cn-postgres,role=primary" -o jsonpath=' {.items[0].metadata.name}' ) "
0 commit comments