Skip to content

Commit 9a2046a

Browse files
committed
refactor: improved logging
1 parent 8c9a98d commit 9a2046a

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

internal/controller/metalstackcluster_controller.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func (r *MetalStackClusterReconciler) clusterToMetalStackCluster(log logr.Logger
167167
return nil
168168
}
169169

170-
log := log.WithValues("cluster", cluster)
170+
log := log.WithValues("cluster", cluster.Name, "namespace", cluster.Namespace)
171171

172172
if cluster.Spec.InfrastructureRef == nil {
173173
return nil
@@ -190,7 +190,7 @@ func (r *MetalStackClusterReconciler) clusterToMetalStackCluster(log logr.Logger
190190
return nil
191191
}
192192

193-
log.Info("cluster watch reconcile", "infraCluster", infraCluster.Name)
193+
log.Info("cluster changed, reconcile", "infraCluster", infraCluster.Name)
194194
return []ctrl.Request{
195195
{
196196
NamespacedName: infraName,
@@ -257,7 +257,7 @@ func (r *MetalStackClusterReconciler) metalStackMachineToMetalStackCluster(log l
257257
return nil
258258
}
259259

260-
log.Info("ms machine watch reconcile", "infraCluster", infraCluster.Name)
260+
log.Info("metalstackmachine changed, reconcile", "infraCluster", infraCluster.Name)
261261
return []ctrl.Request{
262262
{
263263
NamespacedName: client.ObjectKeyFromObject(infraCluster),

internal/controller/metalstackmachine_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ func (r *MetalStackMachineReconciler) clusterToMetalStackMachine(log logr.Logger
210210
return nil
211211
}
212212

213-
log := log.WithValues("cluster", cluster)
213+
log := log.WithValues("cluster", cluster.Name, "namespace", cluster.Namespace)
214214

215215
infraMachineList := &v1alpha1.MetalStackMachineList{}
216216
err := r.Client.List(ctx, infraMachineList, &client.ListOptions{
@@ -226,7 +226,7 @@ func (r *MetalStackMachineReconciler) clusterToMetalStackMachine(log logr.Logger
226226

227227
var reqs []ctrl.Request
228228
for _, infraMachine := range infraMachineList.Items {
229-
log.Info("cluster watch reconcile", "infraMachine", infraMachine.Name)
229+
log.Info("cluster changed, reconcile", "infraMachine", infraMachine.Name)
230230
reqs = append(reqs, ctrl.Request{
231231
NamespacedName: client.ObjectKeyFromObject(&infraMachine),
232232
})
@@ -243,7 +243,7 @@ func (r *MetalStackMachineReconciler) metalStackClusterToMetalStackMachine(log l
243243
return nil
244244
}
245245

246-
log := log.WithValues("infraCluster", infraCluster)
246+
log := log.WithValues("infraCluster", infraCluster.Name, "namespace", infraCluster.Namespace)
247247

248248
clusterName, ok := infraCluster.Labels[clusterv1.ClusterNameLabel]
249249
if !ok {
@@ -264,7 +264,7 @@ func (r *MetalStackMachineReconciler) metalStackClusterToMetalStackMachine(log l
264264

265265
var reqs []ctrl.Request
266266
for _, infraMachine := range infraMachineList.Items {
267-
log.Info("mscluster watch reconcile", "infraMachine", infraMachine.Name)
267+
log.Info("metalstackcluster changed, reconcile", "infraMachine", infraMachine.Name)
268268
reqs = append(reqs, ctrl.Request{
269269
NamespacedName: client.ObjectKeyFromObject(&infraMachine),
270270
})
@@ -281,7 +281,7 @@ func (r *MetalStackMachineReconciler) machineToMetalStackMachine(log logr.Logger
281281
return nil
282282
}
283283

284-
log := log.WithValues("machine", machine)
284+
log := log.WithValues("machine", machine.Name, "namespace", machine.Namespace)
285285

286286
clusterName, ok := machine.Labels[clusterv1.ClusterNameLabel]
287287
if !ok {
@@ -312,7 +312,7 @@ func (r *MetalStackMachineReconciler) machineToMetalStackMachine(log logr.Logger
312312

313313
var reqs []ctrl.Request
314314
for _, infraMachine := range infraMachineList.Items {
315-
log.Info("machine watch reconcile", "infraMachine", infraMachine.Name)
315+
log.Info("machine changed, reconcile", "infraMachine", infraMachine.Name)
316316
reqs = append(reqs, ctrl.Request{
317317
NamespacedName: client.ObjectKeyFromObject(&infraMachine),
318318
})

0 commit comments

Comments
 (0)