Skip to content

chore: drop github per user rate limit tracking - #12286

Merged
Emyrk merged 4 commits into
mainfrom
stevenmasley/github_rate_limit
Feb 23, 2024
Merged

Emyrk merged 4 commits into
mainfrom
stevenmasley/github_rate_limit

Conversation

@Emyrk

@Emyrk Emyrk commented Feb 23, 2024 •

Copy link
Copy Markdown
Member

Rate limits for authenticated requests are per user. This would be an excessive number of prometheus labels, so we only track the unauthorized limit.

The rate limit labels without a user label make no sense.

Closes: #10853

Unauthenticated Rate Limit

We used to hit the unauthenticated rate limit as our ValidateToken always required an external auth request. With #11830, we no longer waste an external auth request if we know the token is invalid.

Additionally, if we have an invalid token (say it was revoked), #11598 prevents us from constantly making an external auth request with the same invalid token in the "listen" loop. So when requiring a re authentication, we only trigger 1 request.

There is still improvement to be made, as an invalid token can trigger multiple requests if the user hits the same endpoint multiple times. The caching of "invalid" is only in the scope of 1 request atm. We could either persist the cached "invalid" to the db, or delete the link when we get a 401 back?

Rate limits for authenticated requests are per user.
This would be an excessive number of prometheus labels,
so we only track the unauthorized limit.
@Emyrk
Emyrk requested a review from johnstcn February 23, 2024 15:28

@johnstcn johnstcn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this makes sense, and I'm down for dropping unnecessary prom metrics 👍

Just need to make CI happy.

@Emyrk

Emyrk commented Feb 23, 2024

Copy link
Copy Markdown
Member Author

Just need to make CI happy.

Forgot to fix the tests for the rate limits. On it 👍

@Emyrk
Emyrk merged commit 13359aa into main Feb 23, 2024
@Emyrk
Emyrk deleted the stevenmasley/github_rate_limit branch February 23, 2024 17:17
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 23, 2024
# TYPE coderd_oauth2_external_requests_rate_limit_total gauge
coderd_oauth2_external_requests_rate_limit_total{name="primary-github",resource="core"} 5000
coderd_oauth2_external_requests_rate_limit_total{name="secondary-github",resource="core"} 5000
coderd_oauth2_external_requests_rate_limit_total{name="primary-github",resource="core-unauthorized"} 5000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be 60 instead of 5000?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It should be, but it's only used to generate docs. The values are ignored, but the labels are included.

https://coder.com/docs/v2/latest/admin/prometheus#prometheus-configuration

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So it is fine

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitHub Rate Limit

3 participants