-
Notifications
You must be signed in to change notification settings - Fork 356
Too many requests to Bitbucket, scans are really slow (JENKINS-55071) #187
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
Have you tried to enable the cache? |
Period scans ought to be 8 hours or more. You ought to rely on events. |
Right, we don't have to cache for branch indexing 😆 You should enable/setup "Manage hooks" and change periodic scans to 8 hours or more. |
Exactly. |
Surely you can do some webhook magic, some website with a leg on each side of the walls 😆 Hence why #165 was added 🤣 |
If we can avoid setting a custom URL for Bitbucket hook by limiting the requests, that will be nice too 😄 |
#165 was added to specifically allow manage webhooks to work with setups that don't have internet access. |
Yeah just saw #165. I have changed the frequency of the scan to 2mn. No more throttling for the moment but a more proper way will be to use hooks as you said. 2mn should be enough for our use case However, do you have an idea why too many requests are sent to Bitbucket when ? |
It is simple math :) The higher scan frequency will often trigger rate limiting because of that. You could properly ask if you could open a tiny hole in the firewall to bitbucket cloud to make your life easy for Jenkins. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Hi, we should keep this one active |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I am also experiencing this issue. Is it possible to reopen? |
We have the same issue. It came up when we switched from the Git plugin to the Bitbucket plugin. Since these plugins should be doing something similar it indicated to me that the Bitbucket plugin is making many more calls than the Git plugin (or calling with a different mechanism that is throttled differently). I think this should be addressed in the plugin itself. |
It is likely that there is not much to be done in this plugin. As jetersen said:
The rate limit that is being hit is probably the "repository" one which is only 1000 per hour. However, if you can find places where the number of requests can be optimized, PRs are welcome. Another possible solution would be to make this plugin to use |
I think it should just work. Replace all the builders with cache client builders: https://github.com/jenkinsci/bitbucket-branch-source-plugin/search?q=HttpClientBuilder
This will produce "memory bound" caches, good for easy testing: https://github.com/apache/httpcomponents-client/blob/25c124917bb3ea83c2ff00a6c076e12b260d455a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachingHttpClients.java#L58-L60 |
Hi, I'm having this problem too, but it started a few days ago and there was no change in Jenkins, nor the addition of new branchs. After restarting Jenkins, I realized that the problem stopped, and Atlassian support confirmed this. But after a few hours the problem returned. Is there a log that can be activated to track these requests? |
@haidaraM Where did you change the frequency? |
@marianobilli When you create a multibranch pipeline, you can set the frequency at which Jenkins will check if there is a change. |
I am going to close this for now. I don't think this is something this plugin can fix. Scanning is a very expensive process - irrespectively when using Bitbucket Cloud or even Bitbucket Server. It just does not scale by design - no matter how we would try to mitigate the issue. I would recommend building either a proxy or allowing specific webhook endpoints from Bitbucket server IPs (https://support.atlassian.com/organization-administration/docs/ip-addresses-and-domains-for-atlassian-cloud-products/#Outgoing-Connections). |
Just as a drive by comment...jenkins still scans when using the events api, doesn't it? |
it is. :( |
I understand the issue is now closed and not much can be done for it on jenkins' side. Our CI/CD was unusable since our move from self hosted bitbucket server to bitbucket cloud. Polling every minute a big repo with many branches was not a problem when self-hosting. Impossible now with the cloud. There are 2 reasons to prefer polling over webhook triggering:
In the meantime we are experimenting with a hybrid solution, webhook triggering for pushes/merges, and polling with a much lower rate (currently 15 minutes) to retrigger PRs that need to be rebuilt. This is only an ugly workaround as it creates a 'merge window' up to 15 minutes long on every merge during which every PR can be merged untested.... |
Your checklist for this issue
Jenkins version
Plugin version
Bitbucket cloud
Bitbucket server and version
Description
Hello, first thanks for this plugin :-)
We have a Jenkins that scans periodically (every minute) some repositories (5 repositories) on Bitbucket cloud using a technical account that have read access on these repositories. All the repositories are part of a single team. The jobs are multibranch pipelines.
We saw that after some minutes, the scans start to become very slow as described at
https://issues.jenkins-ci.org/browse/JENKINS-55071. In our case, 2mn to scan a repository of 2 branches and a size of 249.7 KB.
After checking the logs (see attached files), looks like Bitbucket is throttling the requests which makes me think that Jenkins or the plugin is making too many requests because the limits of Bitbucket API is very high: 60000 requests per hour (https://confluence.atlassian.com/bitbucket/rate-limits-668173227.html). Is it possible to log the requests made to Bitbucket ? I only get logs about the API rate limit ?
And also, the cache works for the team repositories list when creating a new multibranch Pipeline.
Jenkins: 2.172
Plugin version: 2.4.4
The text was updated successfully, but these errors were encountered: