Skip to content

Commit

Permalink
Handle behavior if only database.disableHealthCheck specified
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
gmfrasca committed Jul 24, 2023
1 parent 0563af3 commit 7363daf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions controllers/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,12 @@ func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha
// DB field can be specified as an empty obj, confirm that subfields are also specified
// By default if Database is empty, we deploy mariadb
externalDBSpecified := params.UsingExternalDB(dsp)
mariaDBSpecified := !databaseSpecified || dsp.Spec.Database.MariaDB != nil
deployMariaDB := !databaseSpecified || (mariaDBSpecified && dsp.Spec.Database.MariaDB.Deploy)
mariaDBSpecified := dsp.Spec.Database.MariaDB != nil
defaultDBRequired := (!databaseSpecified || (!externalDBSpecified && !mariaDBSpecified))

deployMariaDB := (mariaDBSpecified && dsp.Spec.Database.MariaDB.Deploy)
// Default DB is currently MariaDB as well, but storing these bools seperately in case that changes
deployDefaultDB := (!databaseSpecified || defaultDBRequired)

// If external db is specified, it takes precedence
if externalDBSpecified {
Expand All @@ -103,7 +107,7 @@ func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha
if err != nil {
return err
}
} else if deployMariaDB {
} else if deployMariaDB || deployDefaultDB {
log.Info("Applying mariaDB resources.")
for _, template := range dbTemplates {
err := r.Apply(dsp, params, template)
Expand All @@ -116,6 +120,8 @@ func (r *DSPAReconciler) ReconcileDatabase(ctx context.Context, dsp *dspav1alpha
// desired state.
if !databaseSpecified {
dsp.Spec.Database = &dspav1alpha1.Database{}
}
if !databaseSpecified || defaultDBRequired {
dsp.Spec.Database.MariaDB = params.MariaDB.DeepCopy()
dsp.Spec.Database.MariaDB.Deploy = true
if err := r.Update(ctx, dsp); err != nil {
Expand Down

0 comments on commit 7363daf

Please sign in to comment.