@@ -44,7 +44,6 @@ import (
4444 "fmt"
4545 "strings"
4646 "time"
47-
4847 "github.com/go-logr/logr"
4948 corev1 "k8s.io/api/core/v1"
5049 apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -543,8 +542,8 @@ func (r *DataguardBrokerReconciler) setupDataguardBrokerConfigurationForGivenDB(
543542 }
544543 log .Info ("DB Admin pwd file created" )
545544
545+ // ORA-16532: Oracle Data Guard broker configuration does not exist , so create one
546546 if strings .Contains (out , "ORA-16532" ) {
547- // ORA-16532: Oracle Data Guard broker configuration does not exist , so create one
548547 if m .Spec .ProtectionMode == "MaxPerformance" {
549548 // Construct the password file and dgbroker command file
550549 out , err := dbcommons .ExecCommand (r , r .Config , standbyDatabaseReadyPod .Name , standbyDatabaseReadyPod .Namespace , "" , ctx , req , false , "bash" , "-c" ,
@@ -565,7 +564,6 @@ func (r *DataguardBrokerReconciler) setupDataguardBrokerConfigurationForGivenDB(
565564 }
566565 log .Info ("DgConfigurationMaxPerformance Output" )
567566 log .Info (out )
568-
569567 } else if m .Spec .ProtectionMode == "MaxAvailability" {
570568 // ## DG CONFIGURATION FOR PRIMARY DB || MODE : MAX AVAILABILITY ##
571569 out , err := dbcommons .ExecCommand (r , r .Config , standbyDatabaseReadyPod .Name , standbyDatabaseReadyPod .Namespace , "" , ctx , req , false , "bash" , "-c" ,
@@ -586,7 +584,6 @@ func (r *DataguardBrokerReconciler) setupDataguardBrokerConfigurationForGivenDB(
586584 }
587585 log .Info ("DgConfigurationMaxAvailability Output" )
588586 log .Info (out )
589-
590587 } else {
591588 log .Info ("SPECIFY correct Protection Mode . Either MaxAvailability or MaxPerformance" )
592589 return requeueY
@@ -602,10 +599,11 @@ func (r *DataguardBrokerReconciler) setupDataguardBrokerConfigurationForGivenDB(
602599 log .Info ("ShowConfiguration Output" )
603600 log .Info (out )
604601 }
605- // Set DG Configured status to true for this standbyDatabase. so that in next reconcilation, we dont configure this again
602+ // Set DG Configured status to true for this standbyDatabase and primary Database. so that in next reconcilation, we dont configure this again
603+ n .Status .DgBrokerConfigured = true
606604 standbyDatabase .Status .DgBrokerConfigured = true
607605 r .Status ().Update (ctx , standbyDatabase )
608-
606+ r . Status (). Update ( ctx , n )
609607 // Remove admin pwd file
610608 _ , err = dbcommons .ExecCommand (r , r .Config , standbyDatabaseReadyPod .Name , standbyDatabaseReadyPod .Namespace , "" , ctx , req , true , "bash" , "-c" ,
611609 dbcommons .RemoveAdminPasswordFile )
@@ -1173,6 +1171,9 @@ func (r *DataguardBrokerReconciler) cleanupDataguardBroker(req ctrl.Request, ctx
11731171 r .Status ().Update (ctx , standbyDatabase )
11741172 }
11751173
1174+ singleInstanceDatabase .Status .DgBrokerConfigured = false
1175+ r .Status ().Update (ctx , singleInstanceDatabase )
1176+
11761177 log .Info ("Successfully cleaned up Dataguard Broker" )
11771178 return requeueN , nil
11781179}
0 commit comments