Skip to content

Commit

Permalink
Don't swallow errors when reconciling noderef
Browse files Browse the repository at this point in the history
Fixes kubernetes-sigs#1104

Signed-off-by: Pires <pjpires@gmail.com>
  • Loading branch information
pires committed Jul 3, 2019
1 parent 2afdb44 commit 3c26acc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/controller/noderef/noderef_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,15 @@ func (r *ReconcileNodeRef) Reconcile(request reconcile.Request) (reconcile.Resul
// Check that the Machine has a valid ProviderID.
if machine.Spec.ProviderID == nil || *machine.Spec.ProviderID == "" {
klog.Warningf("Machine %q in namespace %q doesn't have a valid ProviderID, retrying later", machine.Name, machine.Namespace)
return reconcile.Result{RequeueAfter: 30 * time.Second}, nil
return reconcile.Result{RequeueAfter: 30 * time.Second}, err
}

result, err := r.reconcile(ctx, cluster, machine)
if err != nil {
if err == ErrNodeNotFound {
return result, nil
}

klog.Errorf("Failed to assign NodeRef to Machine %q: %v", request.NamespacedName, err)
r.recorder.Event(machine, apicorev1.EventTypeWarning, "FailedSetNodeRef", err.Error())
return result, err
Expand Down Expand Up @@ -165,8 +169,8 @@ func (r *ReconcileNodeRef) reconcile(ctx context.Context, cluster *v1alpha2.Clus
nodeRef, err := r.getNodeReference(corev1Client, providerID)
if err != nil {
if err == ErrNodeNotFound {
klog.Warningf("Cannot find a matching Node for Machine %q in namespace %q, retrying later", machine.Name, machine.Namespace)
return reconcile.Result{RequeueAfter: 10 * time.Second}, nil
klog.Warningf("Failed to assign NodeRef to Machine %q: cannot find a matching Node in namespace %q, retrying later", machine.Name, machine.Namespace)
return reconcile.Result{RequeueAfter: 10 * time.Second}, err
}
return reconcile.Result{}, err
}
Expand Down

0 comments on commit 3c26acc

Please sign in to comment.