@@ -507,23 +507,23 @@ func GetDatabaseRole(readyPod corev1.Pod, r client.Reader,
507507
508508func GetDatabaseOpenMode (readyPod corev1.Pod , r client.Reader ,
509509 config * rest.Config , ctx context.Context , req ctrl.Request , edition string ) (string , error ) {
510- log := ctrllog .FromContext (ctx ).WithValues ("GetDatabaseOpenMode" ,req .NamespacedName )
510+ log := ctrllog .FromContext (ctx ).WithValues ("GetDatabaseOpenMode" , req .NamespacedName )
511511
512- out ,err := ExecCommand (r , config , readyPod .Name , readyPod .Namespace , "" , ctx , req , false , "bash" , "-c" ,
513- fmt .Sprintf ("echo -e \" %s\" | %s" ,GetDBOpenMode ,SQLPlusCLI ))
514- if err != nil {
515- return "" ,err
516- }
517- log .Info (out )
518- if ! strings .Contains (out , "no rows selected" ) && ! strings .Contains (out , "ORA-" ) {
519- out1 := strings .Replace (out , " " , "_" , - 1 )
520- // filtering output and storing databse_role in "database_role"
521- databaseOpenMode := strings .Fields (out1 )[2 ]
522- // first 2 values in the slice will be column name(DATABASE_ROLE) and a seperator(--------------) .
523- return databaseOpenMode , nil
524- }
525- return "" , errors .New ("database open mode is nil" )
512+ out , err := ExecCommand (r , config , readyPod .Name , readyPod .Namespace , "" , ctx , req , false , "bash" , "-c" ,
513+ fmt .Sprintf ("echo -e \" %s\" | %s" , GetDBOpenMode , SQLPlusCLI ))
514+ if err != nil {
515+ return "" , err
516+ }
517+ log .Info (out )
518+ if ! strings .Contains (out , "no rows selected" ) && ! strings .Contains (out , "ORA-" ) {
519+ out1 := strings .Replace (out , " " , "_" , - 1 )
520+ // filtering output and storing databse_role in "database_role"
521+ databaseOpenMode := strings .Fields (out1 )[2 ]
522+ // first 2 values in the slice will be column name(DATABASE_ROLE) and a seperator(--------------) .
523+ return databaseOpenMode , nil
526524 }
525+ return "" , errors .New ("database open mode is nil" )
526+ }
527527
528528// Returns true if any of the pod in 'pods' is with pod.Status.Phase == phase
529529func IsAnyPodWithStatus (pods []corev1.Pod , phase corev1.PodPhase ) (bool , corev1.Pod ) {
@@ -590,29 +590,29 @@ func GetNodeIp(r client.Reader, ctx context.Context, req ctrl.Request) string {
590590}
591591
592592// GetSidPdbEdition to display sid, pdbname, edition in ConnectionString
593- func GetSidPdbEdition (r client.Reader , config * rest.Config , ctx context.Context , req ctrl.Request ) (string , string , string ) {
593+ func GetSidPdbEdition (r client.Reader , config * rest.Config , ctx context.Context , req ctrl.Request ) (string , string , string , error ) {
594594
595- log := ctrllog .FromContext (ctx ).WithValues ("GetNodeIp " , req .NamespacedName )
595+ log := ctrllog .FromContext (ctx ).WithValues ("GetSidbPdbEdition " , req .NamespacedName )
596596
597597 readyPod , _ , _ , _ , err := FindPods (r , "" , "" , req .Name , req .Namespace , ctx , req )
598598 if err != nil {
599599 log .Error (err , err .Error ())
600- return "" , "" , ""
600+ return "" , "" , "" , fmt . Errorf ( "error while fetching ready pod %s : \n %s" , readyPod . Name , err . Error ())
601601 }
602602 if readyPod .Name != "" {
603603 out , err := ExecCommand (r , config , readyPod .Name , readyPod .Namespace , "" ,
604604 ctx , req , false , "bash" , "-c" , GetSidPdbEditionCMD )
605605 if err != nil {
606606 log .Error (err , err .Error ())
607- return "" , "" , ""
608- }
609- splitstr := strings .Split (out , "," )
610- if len (splitstr ) == 4 {
611- return splitstr [0 ], splitstr [1 ], splitstr [2 ]
607+ return "" , "" , "" , err
612608 }
609+ log .Info ("GetSidPdbEditionCMD output \n " + out )
610+ splitstr := strings .Split ((strings .TrimSpace (out )), "," )
611+ return splitstr [0 ], splitstr [1 ], splitstr [2 ], nil
613612 }
614-
615- return "" , "" , ""
613+ err = errors .New ("ready pod name is nil" )
614+ log .Error (err , err .Error ())
615+ return "" , "" , "" , err
616616}
617617
618618// Get Datapatch Status
0 commit comments