Skip to content

Conversation

pstibrany
Copy link
Contributor

@pstibrany pstibrany commented Oct 3, 2019

This PR implements Hashicorp's recommendations for using blocking queries at https://www.consul.io/api/features/blocking.html:

  • rate limiting when watching for value changes. Current limit is 1 read/second, with bursts up to 5/second.
  • handle LastIndex value going down or being zero by restarting the blocking loop from 0 or 1 respectively

Fixes issue #1708.

@pstibrany pstibrany changed the title Issue 1708 Implement Hashicorps's recommendations when watching consul key Oct 3, 2019
Copy link
Contributor

@khaines khaines left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @pstibrany. It's a pity we had to fork the rate limiter code vs just referencing it, but other than that it LGTM

@pstibrany
Copy link
Contributor Author

Thanks for your review.

I couldn't find any other fitting rate limiter in dependencies that Cortex already has, and I didn't want to introduce new dependency. I'm open to switching to a different one if you have a good suggestion, although I quite like how simple this one is.

@tomwilkie
Copy link
Contributor

tomwilkie commented Oct 8, 2019

@pstibrany
Copy link
Contributor Author

Replaced with rate limiter from golang.org/x/time/rate. Not as nice, but it works and we avoid copying.

@pstibrany
Copy link
Contributor Author

pstibrany commented Oct 8, 2019

Oh, I guess rate-limit should apply for WatchPrefix as well, not just WatchKey. I missed that.
And not just rate-limit, but index checks too.

Copy link
Contributor

@gouthamve gouthamve left a comment

Choose a reason for hiding this comment

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

Looks good, left some comments.

Copy link
Contributor

@jtlisi jtlisi left a comment

Choose a reason for hiding this comment

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

LGTM

@gouthamve
Copy link
Contributor

@pstibrany Could you add a changelog entry and I'll merge this after that and Jacob's nit.

This makes lint happy.

Signed-off-by: Peter Štibraný <[email protected]>
Removed copy of modified jaegers' rate-limiter

Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
Signed-off-by: Peter Štibraný <[email protected]>
@pstibrany
Copy link
Contributor Author

Added changelog, fixed "Zero" -> "0", and rebased on top of master.

@gouthamve gouthamve merged commit b80d1f6 into cortexproject:master Oct 22, 2019
@pstibrany pstibrany deleted the issue-1708 branch October 22, 2019 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants