Skip to content

Commit b4fc90c

Browse files
committed
Make sure MariaDBAccount gets created with MariaDBDatabase
Currently the MariaDBAccount gets created in an early step before the password secret gets validated to be there. In case the service password is missing the deployment stops after the MariaDBAccount is there. If one deletes the ctlplane at this point, the nova-api MariaDBAccount won't be deleted because the loadDatabaseAndAccountCRs() will not return the account because the MariaDBDatabase object was not created. With this the nova-api MariaDBAccount remains with a finalizer. When the password secret now is created with a new ctlplane, the old nova-api MariaDBAccount conficts with the new deployment because it will not be created in the db instance and all nova tasks to initialize its DB fail with an access error. This change moves creating the nova-api MariaDBAccount right before creating the MariaDBDatabase. This reduces the situation that there will be a MariaDBAccount for nova-api without its MariaDBDatabase. Currently this situation could also happen when the service password is there, but galera is not created properly, like DB root pwd missing. Jira: OSPRH-10167 Signed-off-by: Martin Schuppert <[email protected]>
1 parent b05427a commit b4fc90c

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

controllers/nova_controller.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -206,32 +206,6 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
206206
return rbacResult, nil
207207
}
208208

209-
// ensure MariaDBAccount exists. This account record may be created by
210-
// openstack-operator or the cloud operator up front without a specific
211-
// MariaDBDatabase configured yet. Otherwise, a MariaDBAccount CR is
212-
// created here with a generated username as well as a secret with
213-
// generated password. The MariaDBAccount is created without being
214-
// yet associated with any MariaDBDatabase.
215-
_, _, err = mariadbv1.EnsureMariaDBAccount(
216-
ctx, h, instance.Spec.APIDatabaseAccount,
217-
instance.Namespace, false, "nova_api",
218-
)
219-
220-
if err != nil {
221-
instance.Status.Conditions.Set(condition.FalseCondition(
222-
mariadbv1.MariaDBAccountReadyCondition,
223-
condition.ErrorReason,
224-
condition.SeverityWarning,
225-
mariadbv1.MariaDBAccountNotReadyMessage,
226-
err.Error()))
227-
228-
return ctrl.Result{}, err
229-
}
230-
instance.Status.Conditions.MarkTrue(
231-
mariadbv1.MariaDBAccountReadyCondition,
232-
mariadbv1.MariaDBAccountReadyMessage,
233-
)
234-
235209
// There is a webhook validation that ensures that there is always cell0 in
236210
// the cellTemplates
237211
cell0Template := instance.Spec.CellTemplates[novav1.Cell0Name]
@@ -275,6 +249,32 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
275249
return ctrl.Result{}, err
276250
}
277251

252+
// ensure MariaDBAccount exists. This account record may be created by
253+
// openstack-operator or the cloud operator up front without a specific
254+
// MariaDBDatabase configured yet. Otherwise, a MariaDBAccount CR is
255+
// created here with a generated username as well as a secret with
256+
// generated password. The MariaDBAccount is created without being
257+
// yet associated with any MariaDBDatabase.
258+
_, _, err = mariadbv1.EnsureMariaDBAccount(
259+
ctx, h, instance.Spec.APIDatabaseAccount,
260+
instance.Namespace, false, "nova_api",
261+
)
262+
263+
if err != nil {
264+
instance.Status.Conditions.Set(condition.FalseCondition(
265+
mariadbv1.MariaDBAccountReadyCondition,
266+
condition.ErrorReason,
267+
condition.SeverityWarning,
268+
mariadbv1.MariaDBAccountNotReadyMessage,
269+
err.Error()))
270+
271+
return ctrl.Result{}, err
272+
}
273+
instance.Status.Conditions.MarkTrue(
274+
mariadbv1.MariaDBAccountReadyCondition,
275+
mariadbv1.MariaDBAccountReadyMessage,
276+
)
277+
278278
// We create the API DB separately from the Cell DBs as we want to report
279279
// its status separately and we need to pass the API DB around for Cells
280280
// having up-call support

0 commit comments

Comments
 (0)