Skip to content

Dynamic RESTMapper returns ErrRateLimited instead of expected NoKindMatchError #1120

Closed
@timebertt

Description

@timebertt

/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 NoKindMatchErrors.

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:

  1. 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?
  2. wrapping either the underlying NoKindMatchError or the ErrRateLimited with fmt.Errorf("%w... or errors.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

I can do it in a PR, if we agree on one approach.

WDYT?
@estroz @DirectXMan12

Metadata

Metadata

Assignees

Labels

kind/bugCategorizes issue or PR as related to a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions