Skip to content

Commit a35c7cc

Browse files
sxdgbartolini
andauthored
chore: added a few debug log (cloudnative-pg#1068)
Add some debug logging when finding conflicts during update, patch or creation of an object. Close cloudnative-pg#1065 Signed-off-by: Jonathan Gonzalez V <jonathan.gonzalez@enterprisedb.com> Signed-off-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com> Co-authored-by: Gabriele Bartolini <gabriele.bartolini@enterprisedb.com>
1 parent 04e4091 commit a35c7cc

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

controllers/cluster_controller.go

+6
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ func (r *ClusterReconciler) reconcile(ctx context.Context, cluster *apiv1.Cluste
217217
if apierrs.IsConflict(err) {
218218
// Requeue a new reconciliation cycle, as in this point we need
219219
// to quickly react the changes
220+
contextLogger.Debug("Conflict error while reconciling resource status", "error", err)
220221
return ctrl.Result{Requeue: true}, nil
221222
}
222223

@@ -239,6 +240,8 @@ func (r *ClusterReconciler) reconcile(ctx context.Context, cluster *apiv1.Cluste
239240
// we update all the cluster status fields that require the instances status
240241
if err := r.updateClusterStatusThatRequiresInstancesState(ctx, cluster, instancesStatus); err != nil {
241242
if apierrs.IsConflict(err) {
243+
contextLogger.Debug("Conflict error while reconciling cluster status nad instance state",
244+
"error", err)
242245
return ctrl.Result{Requeue: true}, nil
243246
}
244247
return ctrl.Result{}, fmt.Errorf("cannot update the instances status on the cluster: %w", err)
@@ -297,6 +300,7 @@ func (r *ClusterReconciler) reconcile(ctx context.Context, cluster *apiv1.Cluste
297300
if apierrs.IsConflict(err) {
298301
// Requeue a new reconciliation cycle, as in this point we need
299302
// to quickly react the changes
303+
contextLogger.Debug("Conflict error while reconciling online update", "error", err)
300304
return ctrl.Result{Requeue: true}, nil
301305
}
302306

@@ -481,6 +485,7 @@ func (r *ClusterReconciler) reconcileResources(
481485
// Reconcile PVC resource requirements
482486
if err := r.ReconcilePVCs(ctx, cluster, resources); err != nil {
483487
if apierrs.IsConflict(err) {
488+
contextLogger.Debug("Conflict error while reconciling PVCs", "error", err)
484489
return ctrl.Result{Requeue: true}, nil
485490
}
486491
return ctrl.Result{}, err
@@ -525,6 +530,7 @@ func (r *ClusterReconciler) deleteEvictedPods(ctx context.Context, cluster *apiv
525530
"podStatus", resources.instances.Items[idx].Status)
526531
if err := r.Delete(ctx, &resources.instances.Items[idx]); err != nil {
527532
if apierrs.IsConflict(err) {
533+
contextLogger.Debug("Conflict error while deleting instances item", "error", err)
528534
return &ctrl.Result{Requeue: true}, nil
529535
}
530536
return nil, err

controllers/pooler_controller.go

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ func (r *PoolerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
110110
if apierrs.IsConflict(err) {
111111
// Requeue a reconciliation loop since the resource
112112
// changed while we were synchronizing it
113+
contextLogger.Debug("Conflict while reconciling pooler status", "error", err)
113114
return ctrl.Result{Requeue: true}, nil
114115
}
115116
}

controllers/scheduledbackup_controller.go

+3
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ func ReconcileScheduledBackup(
142142
if err != nil {
143143
if apierrs.IsConflict(err) {
144144
// Retry later, the cache is stale
145+
contextLogger.Debug("Conflict while reconciling the scheduled backup", "error", err)
145146
return ctrl.Result{}, nil
146147
}
147148
return ctrl.Result{}, err
@@ -218,6 +219,7 @@ func createBackup(
218219
if err := client.Create(ctx, backup); err != nil {
219220
if apierrs.IsConflict(err) {
220221
// Retry later, the cache is stale
222+
contextLogger.Debug("Conflict while creating backup", "error", err)
221223
return ctrl.Result{}, nil
222224
}
223225

@@ -243,6 +245,7 @@ func createBackup(
243245
if err := client.Status().Update(ctx, scheduledBackup); err != nil {
244246
if apierrs.IsConflict(err) {
245247
// Retry later, the cache is stale
248+
contextLogger.Debug("Conflict while updating scheduled backup", "error", err)
246249
return ctrl.Result{}, nil
247250
}
248251
return ctrl.Result{}, err

0 commit comments

Comments
 (0)