From b099bdfa2e2be15a510df5727d372051024bb34c Mon Sep 17 00:00:00 2001 From: zoetrope Date: Fri, 28 Jun 2024 04:46:32 +0000 Subject: [PATCH] Sort namespace in generated configmaps. Because the order of client-go's List is random, ConfigMap will be updated indefinitely. --- controllers/tenant_controller.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/controllers/tenant_controller.go b/controllers/tenant_controller.go index 3cec08b..4de5a49 100644 --- a/controllers/tenant_controller.go +++ b/controllers/tenant_controller.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "fmt" + "slices" "strings" "text/template" @@ -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{ @@ -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{