From 2490ec86620b1cd2c2ab42b0638089bdd056bc0a Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Sat, 13 Jul 2024 17:25:12 -0500 Subject: [PATCH] Fix cluster-autoscaler priority expander config We were iterating over a map which has undefined ordering, resulting in inconsistent diffs to the manifest during `kops update cluster`. We now sort the instsance groups to ensure the rendered manifest remains consistent. --- upup/pkg/fi/cloudup/template_functions.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/upup/pkg/fi/cloudup/template_functions.go b/upup/pkg/fi/cloudup/template_functions.go index d779c896c678d..3965f7effc8ac 100644 --- a/upup/pkg/fi/cloudup/template_functions.go +++ b/upup/pkg/fi/cloudup/template_functions.go @@ -347,7 +347,9 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap, secretStore fi.SecretS if cluster.Spec.ClusterAutoscaler.CustomPriorityExpanderConfig != nil { priorities = cluster.Spec.ClusterAutoscaler.CustomPriorityExpanderConfig } else { - for name, spec := range tf.GetNodeInstanceGroups() { + igNames := maps.SortedKeys(tf.GetNodeInstanceGroups()) + for _, name := range igNames { + spec := tf.GetNodeInstanceGroups()[name] if spec.Autoscale != nil { priorities[strconv.Itoa(int(spec.AutoscalePriority))] = append(priorities[strconv.Itoa(int(spec.AutoscalePriority))], fmt.Sprintf("%s.%s", name, tf.ClusterName())) }