Skip to content

Commit

Permalink
fix: break the potential endless reconcile loop of ServerClasses
Browse files Browse the repository at this point in the history
As list of server names (UUIDs) was not sorted, and listing and
filtering servers is not deterministic, so on each ServerClass reconcile
ServerClass might be changed which triggers another reconcile and so on
until list of server UUIDs on two reconciles stays the same.

Signed-off-by: Andrey Smirnov <[email protected]>
  • Loading branch information
smira authored and talos-bot committed Apr 8, 2021
1 parent 0a52252 commit 9322532
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package controllers
import (
"context"
"fmt"
"sort"

"github.com/go-logr/logr"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -184,6 +185,10 @@ func (r *ServerClassReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error)
avail = append(avail, server.Name)
}

// sort lists to avoid spurious updates due to `map` key ordering
sort.Strings(avail)
sort.Strings(used)

sc.Status.ServersAvailable = avail
sc.Status.ServersInUse = used

Expand Down

0 comments on commit 9322532

Please sign in to comment.