@@ -507,23 +507,23 @@ func GetDatabaseRole(readyPod corev1.Pod, r client.Reader,
507
507
508
508
func GetDatabaseOpenMode (readyPod corev1.Pod , r client.Reader ,
509
509
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 )
511
511
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
526
524
}
525
+ return "" , errors .New ("database open mode is nil" )
526
+ }
527
527
528
528
// Returns true if any of the pod in 'pods' is with pod.Status.Phase == phase
529
529
func 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 {
590
590
}
591
591
592
592
// 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 ) {
594
594
595
- log := ctrllog .FromContext (ctx ).WithValues ("GetNodeIp " , req .NamespacedName )
595
+ log := ctrllog .FromContext (ctx ).WithValues ("GetSidbPdbEdition " , req .NamespacedName )
596
596
597
597
readyPod , _ , _ , _ , err := FindPods (r , "" , "" , req .Name , req .Namespace , ctx , req )
598
598
if err != nil {
599
599
log .Error (err , err .Error ())
600
- return "" , "" , ""
600
+ return "" , "" , "" , fmt . Errorf ( "error while fetching ready pod %s : \n %s" , readyPod . Name , err . Error ())
601
601
}
602
602
if readyPod .Name != "" {
603
603
out , err := ExecCommand (r , config , readyPod .Name , readyPod .Namespace , "" ,
604
604
ctx , req , false , "bash" , "-c" , GetSidPdbEditionCMD )
605
605
if err != nil {
606
606
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
612
608
}
609
+ log .Info ("GetSidPdbEditionCMD output \n " + out )
610
+ splitstr := strings .Split ((strings .TrimSpace (out )), "," )
611
+ return splitstr [0 ], splitstr [1 ], splitstr [2 ], nil
613
612
}
614
-
615
- return "" , "" , ""
613
+ err = errors .New ("ready pod name is nil" )
614
+ log .Error (err , err .Error ())
615
+ return "" , "" , "" , err
616
616
}
617
617
618
618
// Get Datapatch Status
0 commit comments