-
Notifications
You must be signed in to change notification settings - Fork 10
/
0002-Sort-machines-before-syncing.patch
51 lines (47 loc) · 1.84 KB
/
0002-Sort-machines-before-syncing.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
From ab07b60b23d26cc712a65d89abecf3ad495e2929 Mon Sep 17 00:00:00 2001
From: Jan Chaloupka <[email protected]>
Date: Sat, 20 Oct 2018 12:37:52 +0200
Subject: [PATCH 2/2] Sort machines before syncing
---
.../cluster-api/pkg/controller/machineset/controller.go | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go
index 63a8051..ce303ca 100644
--- a/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go
+++ b/vendor/sigs.k8s.io/cluster-api/pkg/controller/machineset/controller.go
@@ -19,6 +19,7 @@ package machineset
import (
"context"
"fmt"
+ "sort"
"strings"
"sync"
"time"
@@ -161,7 +162,8 @@ func (r *ReconcileMachineSet) Reconcile(request reconcile.Request) (reconcile.Re
}
// Filter out irrelevant machines (deleting/mismatch labels) and claim orphaned machines.
- var filteredMachines []*clusterv1alpha1.Machine
+ var machineNames []string
+ machineSetMachines := make(map[string]*clusterv1alpha1.Machine)
for idx := range allMachines.Items {
machine := &allMachines.Items[idx]
if shouldExcludeMachine(machineSet, machine) {
@@ -174,7 +176,16 @@ func (r *ReconcileMachineSet) Reconcile(request reconcile.Request) (reconcile.Re
continue
}
}
- filteredMachines = append(filteredMachines, machine)
+ machineNames = append(machineNames, machine.Name)
+ machineSetMachines[machine.Name] = machine
+ }
+
+ // sort the filteredMachines from the oldest to the youngest
+ sort.Strings(machineNames)
+
+ var filteredMachines []*clusterv1alpha1.Machine
+ for _, machineName := range machineNames {
+ filteredMachines = append(filteredMachines, machineSetMachines[machineName])
}
syncErr := r.syncReplicas(machineSet, filteredMachines)
--
2.7.5