-
Notifications
You must be signed in to change notification settings - Fork 886
GitHub Rate Limit #10853
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
Comments
After contacting GitHub support, we were able to see a spike in the number of OAuth requests Coder performed against GitHub API. After talking to the whole team, we didn't perform anything special during this period of time. Can be some edge case in Coder code that performs many OAuth negotiations? If this scenario happens again, we will share Coder logs. |
I don't think there's a scenario where we'd be spamming the API... but maybe we have a bug that could cause a redirect loop or something, and a user just left their browser up? Has this only happened once? Or is there a way we can seemingly trigger it? |
We experienced two times in the last two weeks, but we have not seen any pattern, yet. If we experience again this issue, we will go to Coder logs to retrieve more information and context to be able to understand what is going on. |
@kylecarbs we have experienced this on our deployment today |
I am unable to reproduce this locally. We might want to add some debug/logging/instrumentation and then try to figure it out when we hit it in dogfood. |
I created a PR that will at the very least allow some alerting when this happens from metrics. I think we still need to add some more debugging code to solve this, as there is a few parts of the code we mess with oauth: login, new/update workspace, provisioners, browser user settings page, Lines 67 to 77 in 475be73
This will mainly determine if it is external auth or login |
Some notes Validate Token?
Checking the response headers for githubs yields: ValidateToken counts as a
If it is valid, it looks like this:
We do make quite a few callsJust navigating around the dashboard triggers some calls.
|
Hitting this again now. {"message":"Internal error exchanging Oauth code.","detail":"oauth2: cannot fetch token: 429 Too Many Requests"} |
My hunch is that we are genuinely hitting the rate limits. I think our webpage and some of our cli functions are just a bit demanding. 5k requests an hour is not that many. |
This comment was marked as duplicate.
This comment was marked as duplicate.
Curiously enough, with the new instrumentation it appears that we're hitting the unauthenticated rate limit:
|
@johnstcn This is hit when we try to do a |
Also noticed that "Test Validate" fires off two HTTP requests: Screen.Recording.2024-01-12.at.21.01.07.mov |
I guess most of the tokens also have an expiry. Can't we check expiry before trying to refresh? |
@matifali We should already be doing that, but we should check this on the I am not sure if this will 100% solve it though 🤔 |
Just dropping some more info. We are seeing some spikes in "TokenSource" calls. It's very infrequent (once in the past week). Zooming out to the month is interesting: It looks like it used to be a lot worse? Or someone is doing something in a workspace or something that used to be running more frequently? |
If that is what is going on, a workspace consuming the rate limit, I wonder how we would solve this. Rate limit the usage by the workspace??? |
I was able to reproduce this. See the screenshot. |
Is this still ongoing @Emyrk? |
@bpmct Unfortunately. A lot of positive changes made it into the codebase, but we discovered that at least 1 cause of this was a single workspace that was spamming the external auth api. This is still possible to do, so the issue still remains that a single workspace can consume the external auth rate limit. In practice, because Coder is deployed within known groups, this isn't the biggest security threat IMO since it's just a DOS attack from inside. It is more likely to just be a mistake in some script (that is what is was on our end). |
I will confirm if a single workspace can use the entire rate limit of an app across multiple users. |
I just confirmed that authenticated rate limits are per user: https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/rate-limits-for-oauth-apps
So the rate limit tracking I implemented is a bit moot unless I also label with each user_id. Which feels a bit excessive? |
Agreed, we definitely don't want to label metrics with UUIDs. |
I think we were really hitting the unauthenticated rate limit before. I drastically reduced it, but it is still possible to abuse our api. Although you'd have to be more deliberate now. The PR has the info. |
We are hitting this issue on Coder v2.10.3 We are not sure if users are triggering this aumount of Token Source code 429 and 200. We started to see this issue when we accidentally corrupt our DB and we had to recover it with a daily backup we had of it. Right after the restore, the following day we start too see the issue of oauth too many requests. |
Hey folks,
We have a GitHub App that we used to authenticate our coder users using OAuth. Since few days ago we are receiving many complaints about hitting rate limits. Whenever we try to sign in with GitHub we receive the following error:
It seems we are hitting the "secondary rate limit" but we don't have a way to check its status, neither to know what is causing this. Do you know what could be the issue?
The text was updated successfully, but these errors were encountered: