@@ -26,32 +26,32 @@ import (
26
26
"sigs.k8s.io/cluster-api/controllers/noderefutil"
27
27
"sigs.k8s.io/cluster-api/util"
28
28
"sigs.k8s.io/cluster-api/util/conditions"
29
+ ctrl "sigs.k8s.io/controller-runtime"
29
30
"sigs.k8s.io/controller-runtime/pkg/client"
30
- "sigs.k8s.io/controller-runtime/pkg/reconcile"
31
31
)
32
32
33
33
var (
34
34
ErrNodeNotFound = errors .New ("cannot find node with matching ProviderID" )
35
35
)
36
36
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 ) {
38
38
logger := r .Log .WithValues ("machine" , machine .Name , "namespace" , machine .Namespace )
39
39
40
40
// Check that the Machine has a valid ProviderID.
41
41
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" )
43
43
conditions .MarkFalse (machine , clusterv1 .MachineNodeHealthyCondition , clusterv1 .WaitingForNodeRefReason , clusterv1 .ConditionSeverityInfo , "" )
44
- return reconcile .Result {}, nil
44
+ return ctrl .Result {}, nil
45
45
}
46
46
47
47
providerID , err := noderefutil .NewProviderID (* machine .Spec .ProviderID )
48
48
if err != nil {
49
- return reconcile .Result {}, err
49
+ return ctrl .Result {}, err
50
50
}
51
51
52
52
remoteClient , err := r .Tracker .GetClient (ctx , util .ObjectKey (cluster ))
53
53
if err != nil {
54
- return reconcile .Result {}, err
54
+ return ctrl .Result {}, err
55
55
}
56
56
57
57
// 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
62
62
// If Status.NodeRef is not set before, node still can be in the provisioning state.
63
63
if machine .Status .NodeRef != nil {
64
64
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 )
66
66
}
67
67
conditions .MarkFalse (machine , clusterv1 .MachineNodeHealthyCondition , clusterv1 .NodeProvisioningReason , clusterv1 .ConditionSeverityWarning , "" )
68
- return reconcile .Result {Requeue : true }, nil
68
+ return ctrl .Result {Requeue : true }, nil
69
69
}
70
70
logger .Error (err , "Failed to retrieve Node by ProviderID" )
71
71
r .recorder .Event (machine , corev1 .EventTypeWarning , "Failed to retrieve Node by ProviderID" , err .Error ())
72
- return reconcile .Result {}, err
72
+ return ctrl .Result {}, err
73
73
}
74
74
75
75
// Set the Machine NodeRef.
@@ -88,11 +88,11 @@ func (r *MachineReconciler) reconcileNode(ctx context.Context, cluster *clusterv
88
88
status , message := summarizeNodeConditions (node )
89
89
if status == corev1 .ConditionFalse {
90
90
conditions .MarkFalse (machine , clusterv1 .MachineNodeHealthyCondition , clusterv1 .NodeConditionsFailedReason , clusterv1 .ConditionSeverityWarning , message )
91
- return reconcile .Result {}, nil
91
+ return ctrl .Result {}, nil
92
92
}
93
93
94
94
conditions .MarkTrue (machine , clusterv1 .MachineNodeHealthyCondition )
95
- return reconcile .Result {}, nil
95
+ return ctrl .Result {}, nil
96
96
}
97
97
98
98
// 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
162
162
break
163
163
}
164
164
}
165
+
165
166
return nil , ErrNodeNotFound
166
167
}
0 commit comments