Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort cell-names in nova_controller #903

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions 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 @@ -305,16 +306,20 @@ func (r *NovaReconciler) Reconcile(ctx context.Context, req ctrl.Request) (resul
return ctrl.Result{}, fmt.Errorf("invalid DatabaseStatus from ensureAPIDB: %d", apiDBStatus)
}

// We need to create a list of cellNames to iterate on and as the map
// 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}
orderedCellNames := []string{}
for cellName := range instance.Spec.CellTemplates {
if cellName != novav1.Cell0Name {
orderedCellNames = append(orderedCellNames, cellName)
}
}

// We need to sort the list of cellNames to iterate on to avoid
// unnecessary reconcile loop runs, as the map iteration order is undefined.
Comment on lines +316 to +317
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not for avoiding reconcile loops. It is for avoiding that different reconcile loops sees a different cell order while the cell creation is in the same state but generate a different condition message due to the different order.

sort.Strings(orderedCellNames)
// Also we need to make sure that cell0 is the first to allow dependency
// handling during ensureCell calls.
orderedCellNames = append([]string{novav1.Cell0Name}, orderedCellNames...)

// 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