Skip to content

Commit

Permalink
Rebase on #2336
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Lipovetsky <dlipovetsky@d2iq.com>
  • Loading branch information
dlipovetsky committed Feb 14, 2020
1 parent 7822367 commit c7648e1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const (
)

type managementCluster interface {
GetMachinesForCluster(ctx context.Context, cluster types.NamespacedName, filters ...func(machine clusterv1.Machine) bool) ([]clusterv1.Machine, error)
GetMachinesForCluster(ctx context.Context, cluster types.NamespacedName, filters ...func(machine *clusterv1.Machine) bool) ([]*clusterv1.Machine, error)
TargetClusterControlPlaneIsHealthy(ctx context.Context, clusterKey types.NamespacedName, controlPlaneName string) error
TargetClusterEtcdIsHealthy(ctx context.Context, clusterKey types.NamespacedName, controlPlaneName string) error
}
Expand Down Expand Up @@ -416,7 +416,7 @@ func (r *KubeadmControlPlaneReconciler) scaleDownControlPlane(ctx context.Contex
return ctrl.Result{}, errors.Wrap(err, "failed to pick control plane Machine to delete")
}

if err := r.Client.Delete(ctx, &machineToDelete); err != nil && !apierrors.IsNotFound(err) {
if err := r.Client.Delete(ctx, machineToDelete); err != nil && !apierrors.IsNotFound(err) {
return ctrl.Result{}, errors.Wrapf(err, "failed to delete control plane Machine %s/%s", machineToDelete.Namespace, machineToDelete.Name)
}

Expand Down Expand Up @@ -721,9 +721,9 @@ func clusterKey(cluster *clusterv1.Cluster) types.NamespacedName {
}
}

func oldestMachine(machines []clusterv1.Machine) (clusterv1.Machine, error) {
func oldestMachine(machines []*clusterv1.Machine) (*clusterv1.Machine, error) {
if len(machines) == 0 {
return clusterv1.Machine{}, errors.New("no machines given")
return &clusterv1.Machine{}, errors.New("no machines given")
}
sort.Sort(util.MachinesByCreationTimestamp(machines))
return machines[0], nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1310,10 +1310,10 @@ func TestKubeadmControlPlaneReconciler_reconcileDelete(t *testing.T) {
type fakeManagementCluster struct {
ControlPlaneHealthy bool
EtcdHealthy bool
Machines []clusterv1.Machine
Machines []*clusterv1.Machine
}

func (f *fakeManagementCluster) GetMachinesForCluster(ctx context.Context, cluster types.NamespacedName, filters ...func(machine clusterv1.Machine) bool) ([]clusterv1.Machine, error) {
func (f *fakeManagementCluster) GetMachinesForCluster(ctx context.Context, cluster types.NamespacedName, filters ...func(machine *clusterv1.Machine) bool) ([]*clusterv1.Machine, error) {
return f.Machines, nil
}

Expand Down Expand Up @@ -1342,15 +1342,15 @@ func TestKubeadmControlPlaneReconciler_scaleUpControlPlane(t *testing.T) {
g.Expect(fakeClient.Create(context.Background(), genericMachineTemplate)).To(Succeed())

fmc := &fakeManagementCluster{
Machines: []clusterv1.Machine{},
Machines: []*clusterv1.Machine{},
ControlPlaneHealthy: true,
EtcdHealthy: true,
}

for i := 0; i < 2; i++ {
m, _ := createMachineNodePair(fmt.Sprintf("test-%d", i), cluster, kcp, true)
g.Expect(fakeClient.Create(context.Background(), m)).To(Succeed())
fmc.Machines = append(fmc.Machines, *m)
fmc.Machines = append(fmc.Machines, m)
}

r := &KubeadmControlPlaneReconciler{
Expand Down
4 changes: 2 additions & 2 deletions controlplane/kubeadm/internal/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ func OwnedControlPlaneMachines(controlPlaneName string) func(machine *clusterv1.

// HasDeletionTimestamp returns a MachineFilter function to find all machines
// that have a deletion timestamp.
func HasDeletionTimestamp() func(machine clusterv1.Machine) bool {
return func(machine clusterv1.Machine) bool {
func HasDeletionTimestamp() func(machine *clusterv1.Machine) bool {
return func(machine *clusterv1.Machine) bool {
return machine.GetDeletionTimestamp() != nil
}
}
Expand Down
2 changes: 1 addition & 1 deletion util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func IsPaused(cluster *clusterv1.Cluster, v metav1.Object) bool {
}

// MachinesByCreationTimestamp sorts a list of Machine by creation timestamp, using their names as a tie breaker.
type MachinesByCreationTimestamp []clusterv1.Machine
type MachinesByCreationTimestamp []*clusterv1.Machine

func (o MachinesByCreationTimestamp) Len() int { return len(o) }
func (o MachinesByCreationTimestamp) Swap(i, j int) { o[i], o[j] = o[j], o[i] }
Expand Down

0 comments on commit c7648e1

Please sign in to comment.