Skip to content

Commit 13751d9

Browse files
IshaanDesai45yunus-qureshi
authored andcommitted
Sidb Bug Fixes
1 parent 7120d8d commit 13751d9

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

apis/database/v1alpha1/singleinstancedatabase_webhook.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,12 @@ func (r *SingleInstanceDatabase) ValidateUpdate(oldRuntimeObject runtime.Object)
398398
}
399399
}
400400

401+
// if Db is in a dataguard configuration. Restrict enabling Tcps on the Primary DB
402+
if old.Status.DgBrokerConfigured && r.Spec.EnableTCPS {
403+
allErrs = append(allErrs,
404+
field.Forbidden(field.NewPath("spec").Child("enableTCPS"), "cannot enable tcps as database is in a dataguard configuration"))
405+
}
406+
401407
if old.Status.DatafilesCreated == "true" && (old.Status.PrebuiltDB != r.Spec.Image.PrebuiltDB) {
402408
allErrs = append(allErrs,
403409
field.Forbidden(field.NewPath("spec").Child("image").Child("prebuiltDB"), "cannot be changed"))

controllers/database/dataguardbroker_controller.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

controllers/database/singleinstancedatabase_controller.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,12 @@ func (r *SingleInstanceDatabaseReconciler) validate(m *dbapi.SingleInstanceDatab
527527
return requeueY, err
528528
}
529529

530+
if rp.Status.IsTcpsEnabled {
531+
r.Recorder.Eventf(m, corev1.EventTypeWarning, "Cannot Create", "Standby for TCPS enabled Primary Database is not supported ")
532+
m.Status.Status = dbcommons.StatusError
533+
return requeueY, nil
534+
}
535+
530536
if m.Status.DatafilesCreated == "true" ||
531537
!dbcommons.IsSourceDatabaseOnCluster(m.Spec.PrimaryDatabaseRef) {
532538
return requeueN, nil

0 commit comments

Comments
 (0)