Skip to content

Commit

Permalink
Sort cell-names in nova_controller
Browse files Browse the repository at this point in the history
This change sorts the cell-names and also make sure
that the cell0 is the first element in the orderedCellNames
slice.

Closes: #OSPRH-9980
  • Loading branch information
ratailor committed Nov 28, 2024
1 parent dfc4cc1 commit cf41111
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion controllers/nova_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package controllers
import (
"context"
"fmt"
"sort"
"strings"

batchv1 "k8s.io/api/batch/v1"
Expand Down Expand Up @@ -309,12 +310,16 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
// iteration order is undefined we need to make sure that cell0 is the
// first to allow dependency handling during ensureCell calls.
orderedCellNames := []string{novav1.Cell0Name}
sortedCellNames := []string{}
for cellName := range instance.Spec.CellTemplates {
if cellName != novav1.Cell0Name {
orderedCellNames = append(orderedCellNames, cellName)
sortedCellNames = append(sortedCellNames, cellName)
}
}

sort.Strings(sortedCellNames)
orderedCellNames = append(orderedCellNames, sortedCellNames...)

// Create the Cell DBs. Note that we are not returning on error or if the
// DB creation is still in progress. We move forward with whatever we can
// and relay on the watch to get reconciled if some of the resources change
Expand Down

0 comments on commit cf41111

Please sign in to comment.