@@ -69,6 +69,13 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
69
69
log := ctrl .LoggerFrom (ctx )
70
70
71
71
start := time .Now ()
72
+ defer func () {
73
+ // check duration of reconcile. Warn if it took too long.
74
+ duration := time .Since (start )
75
+ if duration > 15 * time .Second {
76
+ log .Info ("Reconcile took too long" , "duration" , duration , "res" , res , "reterr" , reterr )
77
+ }
78
+ }()
72
79
73
80
// Fetch the Hetzner bare metal host instance.
74
81
bmHost := & infrav1.HetznerBareMetalHost {}
@@ -80,18 +87,10 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
80
87
return reconcile.Result {}, err
81
88
}
82
89
83
- log = log .WithValues ("state" , bmHost .Spec .Status .ProvisioningState )
84
- ctx = ctrl .LoggerInto (ctx , log )
85
-
86
90
initialProvisioningState := bmHost .Spec .Status .ProvisioningState
87
91
defer func () {
88
- // check duration of reconcile. Warn if it took too long.
89
- duration := time .Since (start )
90
- if duration > 10 * time .Second {
91
- log .Info ("Reconcile took too long" , "duration" , duration , "res" , res , "reterr" , reterr )
92
- }
93
92
if initialProvisioningState != bmHost .Spec .Status .ProvisioningState {
94
- log .Info ("Provisioning state changed" , "newState " , bmHost .Spec .Status .ProvisioningState , "duration" , duration )
93
+ log .Info ("Provisioning state changed" , "from " , initialProvisioningState , "to" , bmHost .Spec .Status .ProvisioningState )
95
94
}
96
95
}()
97
96
@@ -141,7 +140,6 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
141
140
}
142
141
if err := r .Client .Get (ctx , hetznerClusterName , hetznerCluster ); err != nil {
143
142
if apierrors .IsNotFound (err ) {
144
- log .Info ("HetznerCluster not found. Requeueing" )
145
143
return reconcile.Result {RequeueAfter : 10 * time .Second }, nil
146
144
}
147
145
return reconcile.Result {}, fmt .Errorf ("failed to get HetznerCluster: %w" , err )
@@ -155,6 +153,8 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
155
153
return reconcile.Result {}, fmt .Errorf ("failed to get Cluster: %w" , err )
156
154
}
157
155
156
+ log = log .WithValues ("Cluster" , klog .KObj (cluster ))
157
+
158
158
hetznerBareMetalMachine := & infrav1.HetznerBareMetalMachine {}
159
159
160
160
if bmHost .Spec .ConsumerRef != nil {
@@ -170,6 +170,8 @@ func (r *HetznerBareMetalHostReconciler) Reconcile(ctx context.Context, req ctrl
170
170
171
171
log = log .WithValues ("HetznerBareMetalMachine" , klog .KObj (hetznerBareMetalMachine ))
172
172
173
+ ctx = ctrl .LoggerInto (ctx , log )
174
+
173
175
// Get Hetzner robot api credentials
174
176
secretManager := secretutil .NewSecretManager (log , r .Client , r .APIReader )
175
177
robotCreds , err := getAndValidateRobotCredentials (ctx , req .Namespace , hetznerCluster , secretManager )
0 commit comments