Skip to content

Commit 2db628a

Browse files
committed
improve error messages
1 parent 160dbdd commit 2db628a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pkg/component/reconcile.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ func (r *Reconciler[T]) Reconcile(ctx context.Context, req ctrl.Request) (result
191191
}
192192
// TODO: allow RetriableError to provide custom reason and message
193193
if component.GetDeletionTimestamp().IsZero() {
194-
status.SetState(StatePending, readyConditionReasonPending, capitalize(err.Error()))
194+
status.SetState(StatePending, readyConditionReasonPending, capitalize(retriableError.Error()))
195195
} else {
196-
status.SetState(StateDeletionPending, readyConditionReasonDeletionPending, capitalize(err.Error()))
196+
status.SetState(StateDeletionPending, readyConditionReasonDeletionPending, capitalize(retriableError.Error()))
197197
}
198198
result = ctrl.Result{RequeueAfter: *retryAfter}
199199
err = nil

pkg/component/reference.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
apitypes "k8s.io/apimachinery/pkg/types"
1818
"sigs.k8s.io/controller-runtime/pkg/client"
1919

20+
"github.com/pkg/errors"
2021
"github.com/sap/component-operator-runtime/internal/walk"
2122
"github.com/sap/component-operator-runtime/pkg/types"
2223
)
@@ -49,9 +50,9 @@ func (r *ConfigMapReference) load(ctx context.Context, clnt client.Client, names
4950
if ignoreNotFound {
5051
return nil
5152
}
52-
return types.NewRetriableError(err, nil)
53+
return types.NewRetriableError(errors.Wrapf(err, "error loading configmap %s/%s", namespace, r.Name), nil)
5354
} else {
54-
return err
55+
return errors.Wrapf(err, "error loading configmap %s/%s", namespace, r.Name)
5556
}
5657
}
5758
r.data = configMap.Data
@@ -101,9 +102,9 @@ func (r *ConfigMapKeyReference) load(ctx context.Context, clnt client.Client, na
101102
if ignoreNotFound {
102103
return nil
103104
}
104-
return types.NewRetriableError(err, nil)
105+
return types.NewRetriableError(errors.Wrapf(err, "error loading configmap %s/%s", namespace, r.Name), nil)
105106
} else {
106-
return err
107+
return errors.Wrapf(err, "error loading configmap %s/%s", namespace, r.Name)
107108
}
108109
}
109110
if r.Key != "" {
@@ -160,9 +161,9 @@ func (r *SecretReference) load(ctx context.Context, clnt client.Client, namespac
160161
if ignoreNotFound {
161162
return nil
162163
}
163-
return types.NewRetriableError(err, nil)
164+
return types.NewRetriableError(errors.Wrapf(err, "error loading secret %s/%s", namespace, r.Name), nil)
164165
} else {
165-
return err
166+
return errors.Wrapf(err, "error loading secret %s/%s", namespace, r.Name)
166167
}
167168
}
168169
r.data = secret.Data
@@ -212,9 +213,9 @@ func (r *SecretKeyReference) load(ctx context.Context, clnt client.Client, names
212213
if ignoreNotFound {
213214
return nil
214215
}
215-
return types.NewRetriableError(err, nil)
216+
return types.NewRetriableError(errors.Wrapf(err, "error loading secret %s/%s", namespace, r.Name), nil)
216217
} else {
217-
return err
218+
return errors.Wrapf(err, "error loading secret %s/%s", namespace, r.Name)
218219
}
219220
}
220221
if r.Key != "" {

0 commit comments

Comments
 (0)