Skip to content

Commit

Permalink
openshift: Sort machines before syncing
Browse files Browse the repository at this point in the history
  • Loading branch information
enxebre committed Jan 30, 2019
1 parent b92647d commit 914f2c7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/controller/machineset/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package machineset
import (
"context"
"fmt"
"sort"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -165,7 +166,8 @@ func (r *ReconcileMachineSet) Reconcile(request reconcile.Request) (reconcile.Re
}

// Filter out irrelevant machines (deleting/mismatch labels) and claim orphaned machines.
var filteredMachines []*machinev1beta1.Machine
var machineNames []string
machineSetMachines := make(map[string]*machinev1beta1.Machine)
for idx := range allMachines.Items {
machine := &allMachines.Items[idx]
if shouldExcludeMachine(machineSet, machine) {
Expand All @@ -178,7 +180,15 @@ 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 []*machinev1beta1.Machine
for _, machineName := range machineNames {
filteredMachines = append(filteredMachines, machineSetMachines[machineName])
}

syncErr := r.syncReplicas(machineSet, filteredMachines)
Expand Down

0 comments on commit 914f2c7

Please sign in to comment.