Skip to content

Commit

Permalink
Delete next cell irrespective of last deletion
Browse files Browse the repository at this point in the history
Right now when multiple cells gets deleted if any one the cell deletion
fails, the control exits with error msg.
This change stores the errors in a list and let next cells deleted.

Closes #OSPRH-10550
  • Loading branch information
auniyal61 committed Nov 27, 2024
1 parent 42b7b84 commit 832bf37
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions controllers/nova_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,18 +600,26 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
return ctrl.Result{}, err
}

var deleteErrs []error

for _, cr := range novaCellList.Items {
_, ok := instance.Spec.CellTemplates[cr.Spec.CellName]
if !ok {
err := r.ensureCellDeleted(ctx, h, instance,
cr.Spec.CellName, apiTransportURL,
secret, apiDB, cellDBs[novav1.Cell0Name].Database.GetDatabaseHostname(), cells[novav1.Cell0Name])
if err != nil {
return ctrl.Result{}, err
deleteErrs = append(deleteErrs, fmt.Errorf("Cell '%s' deletion failed, because: %w", cr.Spec.CellName, err))

} else {
Log.Info("Cell deleted", "cell", cr.Spec.CellName)
delete(instance.Status.RegisteredCells, cr.Name)
}
Log.Info("Cell deleted", "cell", cr.Spec.CellName)
delete(instance.Status.RegisteredCells, cr.Name)
}
}

if len(deleteErrs) > 0 {
return ctrl.Result{}, fmt.Errorf("errors: %v", deleteErrs)

}

Expand Down

0 comments on commit 832bf37

Please sign in to comment.