Skip to content

Commit da24e61

Browse files
(fix): boxcutter logging
- Use Error level for all error conditions - Move verbose reports to V(1) debug mode unless we face an error.
1 parent b3f85d5 commit da24e61

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

internal/operator-controller/controllers/clusterextensionrevision_controller.go

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
149149

150150
rres, err := c.RevisionEngine.Reconcile(ctx, *revision, opts...)
151151
if err != nil {
152+
if rres != nil {
153+
l.Error(err, "revision reconcile failed", "report", rres.String())
154+
} else {
155+
l.Error(err, "revision reconcile failed")
156+
}
152157
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
153158
Type: ocv1.ClusterExtensionRevisionTypeAvailable,
154159
Status: metav1.ConditionFalse,
@@ -158,12 +163,13 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
158163
})
159164
return ctrl.Result{}, fmt.Errorf("revision reconcile: %v", err)
160165
}
161-
l.Info("reconcile report", "report", rres.String())
166+
// Log detailed reconcile reports only in debug mode (V(1)) to reduce verbosity.
167+
l.V(1).Info("reconcile report", "report", rres.String())
162168

163169
// Retry failing preflight checks with a flat 10s retry.
164170
// TODO: report status, backoff?
165171
if verr := rres.GetValidationError(); verr != nil {
166-
l.Info("preflight error, retrying after 10s", "err", verr.String())
172+
l.Error(verr, "preflight validation failed, retrying after 10s")
167173

168174
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
169175
Type: ocv1.ClusterExtensionRevisionTypeAvailable,
@@ -177,7 +183,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
177183

178184
for i, pres := range rres.GetPhases() {
179185
if verr := pres.GetValidationError(); verr != nil {
180-
l.Info("preflight error, retrying after 10s", "err", verr.String())
186+
l.Error(verr, "phase preflight validation failed, retrying after 10s", "phase", i)
181187

182188
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
183189
Type: ocv1.ClusterExtensionRevisionTypeAvailable,
@@ -197,7 +203,7 @@ func (c *ClusterExtensionRevisionReconciler) reconcile(ctx context.Context, rev
197203
}
198204

199205
if len(collidingObjs) > 0 {
200-
l.Info("object collision error, retrying after 10s", "collisions", collidingObjs)
206+
l.Error(fmt.Errorf("object collision detected"), "object collision, retrying after 10s", "phase", i, "collisions", collidingObjs)
201207

202208
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
203209
Type: ocv1.ClusterExtensionRevisionTypeAvailable,
@@ -300,6 +306,11 @@ func (c *ClusterExtensionRevisionReconciler) teardown(ctx context.Context, rev *
300306

301307
tres, err := c.RevisionEngine.Teardown(ctx, *revision)
302308
if err != nil {
309+
if tres != nil {
310+
l.Error(err, "revision teardown failed", "report", tres.String())
311+
} else {
312+
l.Error(err, "revision teardown failed")
313+
}
303314
meta.SetStatusCondition(&rev.Status.Conditions, metav1.Condition{
304315
Type: ocv1.ClusterExtensionRevisionTypeAvailable,
305316
Status: metav1.ConditionFalse,
@@ -310,7 +321,8 @@ func (c *ClusterExtensionRevisionReconciler) teardown(ctx context.Context, rev *
310321
return ctrl.Result{}, fmt.Errorf("revision teardown: %v", err)
311322
}
312323

313-
l.Info("teardown report", "report", tres.String())
324+
// Log detailed teardown reports only in debug mode (V(1)) to reduce verbosity.
325+
l.V(1).Info("teardown report", "report", tres.String())
314326
if !tres.IsComplete() {
315327
// TODO: If it is not complete, it seems like it would be good to update
316328
// the status in some way to tell the user that the teardown is still

0 commit comments

Comments
 (0)