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.
This commit is contained in:
Peter Rifel 2024-07-13 17:25:12 -05:00
parent 4008c54823
commit 51530ee8f3
No known key found for this signature in database
1 changed files with 3 additions and 1 deletions

View File

@ -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()))
}