Skip to content

Commit 7363daf

Browse files
committed
Handle behavior if only database.disableHealthCheck specified
- specifying Spec.Database.DsiableHealthCheck but not externalDB/mariaDB leads to an issue where the DSPO does not recognize the need for a default DB deployment. This handles that case by including it in the default-deploy behavior
1 parent 0563af3 commit 7363daf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

controllers/database.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,12 @@ func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha
9191
// DB field can be specified as an empty obj, confirm that subfields are also specified
9292
// By default if Database is empty, we deploy mariadb
9393
externalDBSpecified := params.UsingExternalDB(dsp)
94-
mariaDBSpecified := !databaseSpecified || dsp.Spec.Database.MariaDB != nil
95-
deployMariaDB := !databaseSpecified || (mariaDBSpecified && dsp.Spec.Database.MariaDB.Deploy)
94+
mariaDBSpecified := dsp.Spec.Database.MariaDB != nil
95+
defaultDBRequired := (!databaseSpecified || (!externalDBSpecified && !mariaDBSpecified))
96+
97+
deployMariaDB := (mariaDBSpecified && dsp.Spec.Database.MariaDB.Deploy)
98+
// Default DB is currently MariaDB as well, but storing these bools seperately in case that changes
99+
deployDefaultDB := (!databaseSpecified || defaultDBRequired)
96100

97101
// If external db is specified, it takes precedence
98102
if externalDBSpecified {
@@ -103,7 +107,7 @@ func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha
103107
if err != nil {
104108
return err
105109
}
106-
} else if deployMariaDB {
110+
} else if deployMariaDB || deployDefaultDB {
107111
log.Info("Applying mariaDB resources.")
108112
for _, template := range dbTemplates {
109113
err := r.Apply(dsp, params, template)
@@ -116,6 +120,8 @@ func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha
116120
// desired state.
117121
if !databaseSpecified {
118122
dsp.Spec.Database = &dspav1alpha1.Database{}
123+
}
124+
if !databaseSpecified || defaultDBRequired {
119125
dsp.Spec.Database.MariaDB = params.MariaDB.DeepCopy()
120126
dsp.Spec.Database.MariaDB.Deploy = true
121127
if err := r.Update(ctx, dsp); err != nil {

0 commit comments

Comments
 (0)