@@ -26,32 +26,32 @@ import (
2626 "sigs.k8s.io/cluster-api/controllers/noderefutil"
2727 "sigs.k8s.io/cluster-api/util"
2828 "sigs.k8s.io/cluster-api/util/conditions"
29+ ctrl "sigs.k8s.io/controller-runtime"
2930 "sigs.k8s.io/controller-runtime/pkg/client"
30- "sigs.k8s.io/controller-runtime/pkg/reconcile"
3131)
3232
3333var (
3434 ErrNodeNotFound = errors .New ("cannot find node with matching ProviderID" )
3535)
3636
37- func (r * MachineReconciler ) reconcileNode (ctx context.Context , cluster * clusterv1.Cluster , machine * clusterv1.Machine ) (reconcile .Result , error ) {
37+ func (r * MachineReconciler ) reconcileNode (ctx context.Context , cluster * clusterv1.Cluster , machine * clusterv1.Machine ) (ctrl .Result , error ) {
3838 logger := r .Log .WithValues ("machine" , machine .Name , "namespace" , machine .Namespace )
3939
4040 // Check that the Machine has a valid ProviderID.
4141 if machine .Spec .ProviderID == nil || * machine .Spec .ProviderID == "" {
42- logger .Info ("Cannot reconcile node, the machine doesn't have a valid ProviderID yet" )
42+ logger .Info ("Cannot reconcile Machine's Node, no valid ProviderID yet" )
4343 conditions .MarkFalse (machine , clusterv1 .MachineNodeHealthyCondition , clusterv1 .WaitingForNodeRefReason , clusterv1 .ConditionSeverityInfo , "" )
44- return reconcile .Result {}, nil
44+ return ctrl .Result {}, nil
4545 }
4646
4747 providerID , err := noderefutil .NewProviderID (* machine .Spec .ProviderID )
4848 if err != nil {
49- return reconcile .Result {}, err
49+ return ctrl .Result {}, err
5050 }
5151
5252 remoteClient , err := r .Tracker .GetClient (ctx , util .ObjectKey (cluster ))
5353 if err != nil {
54- return reconcile .Result {}, err
54+ return ctrl .Result {}, err
5555 }
5656
5757 // Even if Status.NodeRef exists, continue to do the following checks to make sure Node is healthy
@@ -62,14 +62,14 @@ func (r *MachineReconciler) reconcileNode(ctx context.Context, cluster *clusterv
6262 // If Status.NodeRef is not set before, node still can be in the provisioning state.
6363 if machine .Status .NodeRef != nil {
6464 conditions .MarkFalse (machine , clusterv1 .MachineNodeHealthyCondition , clusterv1 .NodeNotFoundReason , clusterv1 .ConditionSeverityError , "" )
65- return reconcile .Result {}, errors .Wrapf (err , "no matching Node for Machine %q in namespace %q" , machine .Name , machine .Namespace )
65+ return ctrl .Result {}, errors .Wrapf (err , "no matching Node for Machine %q in namespace %q" , machine .Name , machine .Namespace )
6666 }
6767 conditions .MarkFalse (machine , clusterv1 .MachineNodeHealthyCondition , clusterv1 .NodeProvisioningReason , clusterv1 .ConditionSeverityWarning , "" )
68- return reconcile .Result {Requeue : true }, nil
68+ return ctrl .Result {Requeue : true }, nil
6969 }
7070 logger .Error (err , "Failed to retrieve Node by ProviderID" )
7171 r .recorder .Event (machine , corev1 .EventTypeWarning , "Failed to retrieve Node by ProviderID" , err .Error ())
72- return reconcile .Result {}, err
72+ return ctrl .Result {}, err
7373 }
7474
7575 // Set the Machine NodeRef.
@@ -88,11 +88,11 @@ func (r *MachineReconciler) reconcileNode(ctx context.Context, cluster *clusterv
8888 status , message := summarizeNodeConditions (node )
8989 if status == corev1 .ConditionFalse {
9090 conditions .MarkFalse (machine , clusterv1 .MachineNodeHealthyCondition , clusterv1 .NodeConditionsFailedReason , clusterv1 .ConditionSeverityWarning , message )
91- return reconcile .Result {}, nil
91+ return ctrl .Result {}, nil
9292 }
9393
9494 conditions .MarkTrue (machine , clusterv1 .MachineNodeHealthyCondition )
95- return reconcile .Result {}, nil
95+ return ctrl .Result {}, nil
9696}
9797
9898// summarizeNodeConditions summarizes a Node's conditions and returns the summary of condition statuses and concatenate failed condition messages:
@@ -162,5 +162,6 @@ func (r *MachineReconciler) getNode(c client.Reader, providerID *noderefutil.Pro
162162 break
163163 }
164164 }
165+
165166 return nil , ErrNodeNotFound
166167}
0 commit comments