Description
/kind bug
In our code we have some client.Delete
calls that should be ignored, when the respective resources are not available on the API server (e.g. additional CRDs not deployed, because some feature gate is disabled).
Therefore we use meta.IsNoMatchError
and ignore the error, if it returns true.
So basically something like this:
if err := client.Delete(ctx, obj); client.IgnoreNotFound(err) != nil {
if meta.IsNoMatchError(err) {
return nil
}
return err
}
When under high load, we have a lot of these calls in parallel, which might end up with NoKindMatchError
s.
After switching to the dynamic RESTMapper in our clients, meta.IsNoMatchError
can no longer catch this, as the dynamic RESTMapper returns ErrRateLimited
instead of NoKindMatchError
, which is (implicitly) expected from implementations of the meta.RESTMapper
interface.
I went back and forth about how this can be improved and gave these options a thought:
- returning the
NoKindMatchError
directly- is not backwards-compatible but would implement the expected behaviour
- how would folks then detect that they are hitting the rate limit?
- wrapping either the underlying
NoKindMatchError
or theErrRateLimited
withfmt.Errorf("%w...
orerrors.Wrap
- you could then check the error with
errors.As(err, &NoKindMatchError)
- still kind of differing from the expected error and you will not be able to use
meta.IsNoMatchError
as well
- you could then check the error with
I can do it in a PR, if we agree on one approach.
WDYT?
@estroz @DirectXMan12