Retry on enablement failure#151
Conversation
|
We need to retry, if there is some transient error. My understanding is your ( @notandy ) preference is not to let the error get up to the controller loop, so I return now a retry and requeue the reconciliation manually. |
b44993f to
7db3c79
Compare
|
Alternatively, if gophercloud is encapsulating all openstack related errors, you could just check if the bubbling up error is an gophercloud error to retry instead, and throw everything else. |
7db3c79 to
0802f57
Compare
|
I went with the |
0802f57 to
f6bdd81
Compare
f6bdd81 to
5bdc12f
Compare
We will likely encounter transient errors, and we should not stop deleting the eviction because of that.
r.addCondition should aways be true when we don't have the status condition. Still, let's return here a requeue to make sure we do not end up in a dead-end by accident.
|
I start to think, returning the wish to requeue the reconciliation is not a good idea.... type errorRequeue struct {
RequeueAfter time.Duration
}
func (e errorRequeue) Error() string {
return "someone didn't handle the errorRetry case"
}
func requeueAfter(t time.Duration) errorRequeue {
return errorRequeue{RequeueAfter: t}
}
func RetryOnConflict(backoff wait.Backoff, fn func() (ctrl.Result, error)) (ctrl.Result, error) {
err := retry.OnError(backoff, k8serrors.IsConflict, func() error {
result, err := fn()
if err != nil {
return err
}
if result.IsZero() {
return nil
}
return requeueAfter(result.RequeueAfter)
})
var requeueError errorRequeue
if errors.As(err, &requeueError); requeueError.RequeueAfter > 0 {
return ctrl.Result{RequeueAfter: requeueError.RequeueAfter}, nil
}
return ctrl.Result{}, nil
}And somehow it doesn't sit right with me. |
|
You're right, if you really want to propagate a duration, it makes no sense anymore to marshal it into an error. |
No description provided.