Skip to content

Commit

Permalink
Tidy: fixed typo, unexported methods and removed unused func variable
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Shitrit <[email protected]>
  • Loading branch information
mshitrit committed May 12, 2021
1 parent 56f4f9a commit ae8da03
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions controllers/machinehealthcheck_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ func (r *MachineHealthCheckReconciler) reconcile(ctx context.Context, logger log
m.Status.RemediationsAllowed = remediationCount
conditions.MarkTrue(m, clusterv1.RemediationAllowedCondition)

errList := r.PatchUnhealthyTargets(ctx, logger, unhealthy, cluster, m)
errList = append(errList, r.PatchHealthyTargets(ctx, logger, healthy, cluster, m)...)
errList := r.patchUnhealthyTargets(ctx, logger, unhealthy, cluster, m)
errList = append(errList, r.patchHealthyTargets(ctx, logger, healthy, m)...)

// handle update errors
if len(errList) > 0 {
Expand All @@ -306,8 +306,8 @@ func (r *MachineHealthCheckReconciler) reconcile(ctx context.Context, logger log
return ctrl.Result{}, nil
}

// PatchHealthyTargets patches healthy machines with MachineHealthCheckSuccededCondition.
func (r *MachineHealthCheckReconciler) PatchHealthyTargets(ctx context.Context, logger logr.Logger, healthy []healthCheckTarget, cluster *clusterv1.Cluster, m *clusterv1.MachineHealthCheck) []error {
// patchHealthyTargets patches healthy machines with MachineHealthCheckSucceededCondition.
func (r *MachineHealthCheckReconciler) patchHealthyTargets(ctx context.Context, logger logr.Logger, healthy []healthCheckTarget, m *clusterv1.MachineHealthCheck) []error {
errList := []error{}
for _, t := range healthy {
if m.Spec.RemediationTemplate != nil {
Expand Down Expand Up @@ -337,8 +337,8 @@ func (r *MachineHealthCheckReconciler) PatchHealthyTargets(ctx context.Context,
return errList
}

// PatchUnhealthyTargets patches machines with MachineOwnerRemediatedCondition for remediation.
func (r *MachineHealthCheckReconciler) PatchUnhealthyTargets(ctx context.Context, logger logr.Logger, unhealthy []healthCheckTarget, cluster *clusterv1.Cluster, m *clusterv1.MachineHealthCheck) []error {
// patchUnhealthyTargets patches machines with MachineOwnerRemediatedCondition for remediation.
func (r *MachineHealthCheckReconciler) patchUnhealthyTargets(ctx context.Context, logger logr.Logger, unhealthy []healthCheckTarget, cluster *clusterv1.Cluster, m *clusterv1.MachineHealthCheck) []error {
// mark for remediation
errList := []error{}
for _, t := range unhealthy {
Expand Down
4 changes: 2 additions & 2 deletions controllers/machinehealthcheck_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2617,10 +2617,10 @@ func TestPatchTargets(t *testing.T) {
}

// Target with wrong patch helper will fail but the other one will be patched.
g.Expect(len(r.PatchUnhealthyTargets(context.TODO(), log.NullLogger{}, []healthCheckTarget{target1, target3}, defaultCluster, mhc))).To(BeNumerically(">", 0))
g.Expect(len(r.patchUnhealthyTargets(context.TODO(), log.NullLogger{}, []healthCheckTarget{target1, target3}, defaultCluster, mhc))).To(BeNumerically(">", 0))
g.Expect(cl.Get(ctx, client.ObjectKey{Name: machine2.Name, Namespace: machine2.Namespace}, machine2)).NotTo(HaveOccurred())
g.Expect(conditions.Get(machine2, clusterv1.MachineOwnerRemediatedCondition).Status).To(Equal(corev1.ConditionFalse))

// Target with wrong patch helper will fail but the other one will be patched.
g.Expect(len(r.PatchHealthyTargets(context.TODO(), log.NullLogger{}, []healthCheckTarget{target1, target3}, defaultCluster, mhc))).To(BeNumerically(">", 0))
g.Expect(len(r.patchHealthyTargets(context.TODO(), log.NullLogger{}, []healthCheckTarget{target1, target3}, mhc))).To(BeNumerically(">", 0))
}

0 comments on commit ae8da03

Please sign in to comment.