Skip to content

Commit cf41111

Browse files
committed
Sort cell-names in nova_controller
This change sorts the cell-names and also make sure that the cell0 is the first element in the orderedCellNames slice. Closes: #OSPRH-9980
1 parent dfc4cc1 commit cf41111

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

controllers/nova_controller.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package controllers
1919
import (
2020
"context"
2121
"fmt"
22+
"sort"
2223
"strings"
2324

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

320+
sort.Strings(sortedCellNames)
321+
orderedCellNames = append(orderedCellNames, sortedCellNames...)
322+
318323
// Create the Cell DBs. Note that we are not returning on error or if the
319324
// DB creation is still in progress. We move forward with whatever we can
320325
// and relay on the watch to get reconciled if some of the resources change

0 commit comments

Comments
 (0)