Skip to content

[WIP] pkg/restmapper: use exponential backoff with DynamicRESTMapper calls #1792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

estroz
Copy link
Member

@estroz estroz commented Aug 7, 2019

Description of the change: add exponential backoff to DynamicRESTMapper.reloadOnErr() calls.

Motivation for the change: see this discussion from #1329.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 7, 2019
@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 7, 2019
return false
}
err = drm.reload()
if err != nil {
// TODO(estroz): HandleError uses a rudimentary backoff by default.
// Should we remove it completely or substitute the default backoff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to have the simple back off as a fall-back before failing completely

"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
"k8s.io/client-go/restmapper"
)

// TODO(estroz): do we want to return a wait.ErrWaitTimeout if backoff duration
// reaches a maximum?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say yes. Backoff duration hitting its maximum is, in the end, a wait timeout.

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm understanding this correctly, we'll block the caller by sleeping for the backoff duration if we attempt a reload and get a NotKindMatchError. Is that correct?

I wonder if a better UX would be for us to be able to return a "you've been rate-limited" error immediately and let the caller have the chance to do other things in the meantime? On the other hand, that would then probably mean we'd need to return an error that the caller is able to recover the wait duration from.

I suppose if they need concurrency around this, they could do it themselves with their own goroutine.

Thoughts?

@estroz
Copy link
Member Author

estroz commented Aug 7, 2019

@joelanford that would be better UX, especially if this is being used in a reconcile loop. We could use the token bucket approach: if the limiter Allows an event to happen, reload; if not, return an ErrRateLimited. We can expose a method on DynamicRESTMapper.Delay() to get the time to wait if ErrRateLimited is returned, or expose a field on ErrRateLimited with that value.

@joelanford
Copy link
Member

@estroz I was thinking the same think about the reconcile loop issue.

@DirectXMan12 This is definitely related to the conversation going in kubernetes-sigs/controller-runtime#321. Any thoughts on the rate-limiting approach?

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 7, 2019
@estroz estroz force-pushed the osdk-469-upstream-dynamicrestmapper branch from 4ddb120 to c6e1229 Compare August 7, 2019 23:34
@estroz estroz force-pushed the osdk-469-upstream-dynamicrestmapper branch from c6e1229 to 6f146c2 Compare August 7, 2019 23:41
@openshift-ci-robot
Copy link

@estroz: The following tests failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/e2e-aws-ansible 6f146c2 link /test e2e-aws-ansible
ci/prow/e2e-aws-go 6f146c2 link /test e2e-aws-go
ci/prow/images 6f146c2 link /test images
ci/prow/e2e-aws-helm 6f146c2 link /test e2e-aws-helm

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@estroz
Copy link
Member Author

estroz commented Aug 8, 2019

Instead of making two PR's with these changes (one for the SDK, one to upstream DynamicRESTMapper), one has been made to controller-runtime (kubernetes-sigs/controller-runtime#554) and a new PR will remove pkg/restmapper from the SDK and make necessary dependency changes once the former is merged and a release made.

@estroz estroz closed this Aug 8, 2019
@estroz estroz deleted the osdk-469-upstream-dynamicrestmapper branch April 1, 2020 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants