From 7363daf3482b83f4932a21f5198f6fe8f99159db Mon Sep 17 00:00:00 2001 From: Giulio Frasca Date: Mon, 24 Jul 2023 16:51:19 -0400 Subject: [PATCH] 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 --- controllers/database.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/controllers/database.go b/controllers/database.go index 46cd0ed3..f5a5f245 100644 --- a/controllers/database.go +++ b/controllers/database.go @@ -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 { @@ -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) @@ -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 {