Skip to content

Commit

Permalink
Sort namespace in generated configmaps.
Browse files Browse the repository at this point in the history
Because the order of client-go's List is random, ConfigMap will be updated indefinitely.
  • Loading branch information
zoetrope committed Jun 28, 2024
1 parent 66ae9c9 commit b099bdf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/tenant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"slices"
"strings"
"text/template"

Expand Down Expand Up @@ -611,6 +612,7 @@ func (r *TenantReconciler) updateConfigMap(ctx context.Context, controllerName s
namespaces = append(namespaces, ns.Name)
}
}
slices.Sort(namespaces)

op, err := ctrl.CreateOrUpdate(ctx, r.client, cm, func() error {
cm.Labels = map[string]string{
Expand Down Expand Up @@ -665,6 +667,7 @@ func (r *TenantReconciler) updateAllTenantNamespacesConfigMap(ctx context.Contex
allNamespaces = append(allNamespaces, ns.Name)
}
}
slices.Sort(allNamespaces)

op, err := ctrl.CreateOrUpdate(ctx, r.client, cm, func() error {
cm.Labels = map[string]string{
Expand Down

0 comments on commit b099bdf

Please sign in to comment.